From 69f451baaeebd6d0bfb2577ae1ecb1aab2732251 Mon Sep 17 00:00:00 2001 From: Lyon <88232613+pikasTech@users.noreply.github.com> Date: Mon, 22 Jun 2026 17:06:35 +0800 Subject: [PATCH] fix: require session scoped AgentRun PVC (#1906) --- internal/cloud/code-agent-agentrun-adapter.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/cloud/code-agent-agentrun-adapter.ts b/internal/cloud/code-agent-agentrun-adapter.ts index d7bd6857..3525a33a 100644 --- a/internal/cloud/code-agent-agentrun-adapter.ts +++ b/internal/cloud/code-agent-agentrun-adapter.ts @@ -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}`;