fix: require session scoped AgentRun PVC (#1906)

This commit is contained in:
Lyon
2026-06-22 17:06:35 +08:00
committed by GitHub
parent 0da4d42e1e
commit 69f451baae
@@ -2937,12 +2937,18 @@ function withAgentRunRunnerJobCount(mapping = {}) {
return mapping;
}
function hwlabSessionIdForParams(params = {}, traceId) {
return safeSessionId(params.sessionId) || agentRunSessionId(traceId);
function hwlabSessionIdForParams(params = {}) {
return safeSessionId(params.sessionId) || null;
}
function scopedAgentRunSessionIdForParams(params = {}, traceId, backendProfile) {
const baseSessionId = hwlabSessionIdForParams(params, traceId);
if (!safeSessionId(baseSessionId)) {
throw adapterError(
"agentrun_session_id_required",
"AgentRun persistent session/PVC requires params.sessionId; refusing to derive sessionRef.sessionId from traceId because that would create a new PVC per turn."
);
}
const profile = agentRunSessionProfileToken(backendProfile);
const base = String(baseSessionId).replace(/^ses_/u, "").replace(/[^A-Za-z0-9_]+/gu, "_").replace(/^_+|_+$/gu, "") || "session";
return `ses_agentrun_${profile}_${base}`;