🗂️ fix: Route read_file Through the Stateful Code Session (#14259)
Some checks are pending
Docker Dev Branch Images Build / build (Dockerfile, lc-dev, node) (push) Waiting to run
Docker Dev Branch Images Build / build (Dockerfile.multi, lc-dev-api, api-build) (push) Waiting to run
GitNexus Index / index (push) Waiting to run
GitNexus Index / post-index (push) Blocked by required conditions

This commit is contained in:
Danny Avila 2026-07-14 13:17:04 -04:00 committed by GitHub
parent db22188203
commit 1ca7e78f49
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 7 deletions

View file

@ -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']),
);
});
});

View file

@ -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