From 45c1cd74c6f8617d90f9641a3f6782a1d877467c Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Thu, 9 Jul 2026 10:14:43 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20propagate=20runtime=5Fses?= =?UTF-8?q?sion=5Fhint=20to=20sandbox=20executor=20in=20event-driven=20too?= =?UTF-8?q?l=20path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The event-driven ON_TOOL_EXECUTE handler built config.toolCall without the resolved runtime_session_hint, so BashExecutor/CodeExecutor never sent runtime_session_hint to the Code API. Every conversation then collapsed onto the server-derived default session (no per-conversation isolation). Copy tc.runtimeSessionHint onto toolCallConfig._runtime_session_hint, mirroring the SDK direct-execution path. --- packages/api/src/agents/handlers.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/api/src/agents/handlers.ts b/packages/api/src/agents/handlers.ts index d430af1230..a1c25027fa 100644 --- a/packages/api/src/agents/handlers.ts +++ b/packages/api/src/agents/handlers.ts @@ -3340,6 +3340,18 @@ export function createToolExecuteHandler(options: ToolExecuteOptions): EventHand turn: tc.turn, }; + /* Stateful runtime-session hint: the SDK resolves it onto + * the request for execute_code/bash (orthogonal to the + * transient exec-session below — a first call has a hint but + * no session yet). The remote executors read it off + * `config.toolCall._runtime_session_hint`; without this the + * event-driven ON_TOOL_EXECUTE path drops it and every + * conversation collapses onto the Code API's `default` + * session (no per-conversation isolation). */ + if (tc.runtimeSessionHint != null && tc.runtimeSessionHint !== '') { + toolCallConfig._runtime_session_hint = tc.runtimeSessionHint; + } + if ( tc.codeSessionContext && isCodeSessionAwareToolCall(tc.name, mergedConfigurable)