fix(workbench): scope agentrun pvc by hwlab session (#2035)

This commit is contained in:
Lyon
2026-06-24 10:02:10 +08:00
committed by GitHub
parent 7d80770e40
commit 0ef13fbd6f
2 changed files with 19 additions and 24 deletions
@@ -1336,7 +1336,7 @@ function buildAgentRunCreateRunInput({ params, env, traceId, backendProfile, ses
valuesPrinted: false
},
sessionRef: {
sessionId: sessionId ?? scopedAgentRunSessionIdForParams(params, traceId, backendProfile),
sessionId: sessionId ?? scopedAgentRunSessionIdForParams(params, traceId),
...(safeConversationId(params.conversationId) ? { conversationId: safeConversationId(params.conversationId) } : {}),
...(threadId ? { threadId } : {}),
metadata: {
@@ -1350,7 +1350,7 @@ function buildAgentRunCreateRunInput({ params, env, traceId, backendProfile, ses
threadContinuityPolicy: THREAD_CONTINUITY_POLICY,
sessionPolicy: SESSION_POLICY_RUN_LOCAL,
agentRunSessionProfile: backendProfile,
agentRunSessionPolicy: "backend-profile-scoped",
agentRunSessionPolicy: "hwlab-session-scoped",
valuesPrinted: false
}
},
@@ -3002,7 +3002,7 @@ function hwlabSessionIdForParams(params = {}) {
return safeSessionId(params.sessionId) || null;
}
function scopedAgentRunSessionIdForParams(params = {}, traceId, backendProfile) {
function scopedAgentRunSessionIdForParams(params = {}, traceId) {
const baseSessionId = hwlabSessionIdForParams(params, traceId);
if (!safeSessionId(baseSessionId)) {
throw adapterError(
@@ -3010,13 +3010,8 @@ function scopedAgentRunSessionIdForParams(params = {}, traceId, backendProfile)
"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}`;
}
function agentRunSessionProfileToken(backendProfile) {
return String(backendProfile ?? "deepseek").trim().toLowerCase().replace(/[^a-z0-9]+/gu, "_").replace(/^_+|_+$/gu, "") || "default";
return `ses_agentrun_${base}`;
}
function agentRunSessionId(traceId) {