From 1ca7e78f4906d72db80583d749cda3e65214b400 Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Tue, 14 Jul 2026 13:17:04 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=82=EF=B8=8F=20fix:=20Route=20read=5Ff?= =?UTF-8?q?ile=20Through=20the=20Stateful=20Code=20Session=20(#14259)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/src/agents/__tests__/run-codeTools.test.ts | 4 ++-- packages/api/src/agents/run.ts | 14 +++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/api/src/agents/__tests__/run-codeTools.test.ts b/packages/api/src/agents/__tests__/run-codeTools.test.ts index 8fa6783aa4..4df39192ef 100644 --- a/packages/api/src/agents/__tests__/run-codeTools.test.ts +++ b/packages/api/src/agents/__tests__/run-codeTools.test.ts @@ -104,10 +104,10 @@ describe('createRun code-tool eager/session wiring', () => { ); }); - it('declares create_file/edit_file as code-session participants', async () => { + it('declares create_file/edit_file/read_file as code-session participants', async () => { const runConfig = await captureRunConfig(); expect(runConfig.codeSessionToolNames).toEqual( - expect.arrayContaining(['create_file', 'edit_file']), + expect.arrayContaining(['create_file', 'edit_file', 'read_file']), ); }); }); diff --git a/packages/api/src/agents/run.ts b/packages/api/src/agents/run.ts index d3264ee5d6..e55cc4845d 100644 --- a/packages/api/src/agents/run.ts +++ b/packages/api/src/agents/run.ts @@ -1495,13 +1495,17 @@ export async function createRun({ ...agents.flatMap((agent) => agent.backgroundToolNames ?? []), ], }, - // Let host file-authoring tools share the code-execution sandbox session so - // a file created with create_file/edit_file is visible to later + // Let host file tools share the code-execution sandbox session so a file + // created with create_file/edit_file is visible to later // execute_code/bash_tool calls (and vice versa). The SDK folds these tools' // returned exec session/files into the shared code session and injects the - // existing session into their requests. Requires @librechat/agents with - // codeSessionToolNames support (agents#283); older versions ignore it. - codeSessionToolNames: [CREATE_FILE_TOOL_NAME, EDIT_FILE_TOOL_NAME], + // existing session into their requests. Membership here also stamps the + // stateful `runtimeSessionHint` and excludes the tool from eager execution + // — read_file needs both, or its sandbox `cat` runs hintless on the Code + // API's per-user default runtime session and cannot see files bash_tool + // just wrote in the conversation's session. Requires @librechat/agents + // with codeSessionToolNames support (agents#283); older versions ignore it. + codeSessionToolNames: [CREATE_FILE_TOOL_NAME, EDIT_FILE_TOOL_NAME, Constants.READ_FILE], // Derive the Langfuse trace id deterministically from runId so message // feedback can be scored against the trace without a lookup (see the // feedback route in api/server/routes/messages.js). No-op unless Langfuse