diff --git a/api/server/services/Endpoints/agents/initialize.js b/api/server/services/Endpoints/agents/initialize.js index bfe8e00caa..39faef6814 100644 --- a/api/server/services/Endpoints/agents/initialize.js +++ b/api/server/services/Endpoints/agents/initialize.js @@ -256,17 +256,19 @@ const initializeClient = async ({ req, res, signal, endpointOption }) => { ...getSkillToolDeps(), provisionFiles: async (toolNames, agentId) => { const ctx = agentToolContexts.get(agentId); - logger.warn( - `[e2e-diag provisionFiles] agentId=${agentId} tools=${JSON.stringify(toolNames)} hasCtx=${!!ctx} hasProvisionState=${!!ctx?.provisionState} codeEnvFiles=${ctx?.provisionState?.codeEnvFiles?.length ?? 'na'} vectorDBFiles=${ctx?.provisionState?.vectorDBFiles?.length ?? 'na'} codeApiKey=${!!ctx?.provisionState?.codeApiKey}`, - ); if (!ctx?.provisionState) { return; } const { provisionState } = ctx; + /** Code execution expands into bash_tool/read_file (+ their PTC variants); + * the legacy execute_code/run_tools_with_code names are kept for back-compat. */ const needsCode = toolNames.includes(Constants.EXECUTE_CODE) || - toolNames.includes(Constants.PROGRAMMATIC_TOOL_CALLING); + toolNames.includes(Constants.PROGRAMMATIC_TOOL_CALLING) || + toolNames.includes(Constants.BASH_TOOL) || + toolNames.includes(Constants.READ_FILE) || + toolNames.includes(Constants.BASH_PROGRAMMATIC_TOOL_CALLING); const needsSearch = toolNames.includes('file_search'); if (!needsCode && !needsSearch) { diff --git a/e2e/setup/fake-model.js b/e2e/setup/fake-model.js index 6861d12783..27d7b3a35a 100644 --- a/e2e/setup/fake-model.js +++ b/e2e/setup/fake-model.js @@ -47,7 +47,13 @@ const CREATE_SKILL_TOOL_CALL_ID = 'call_e2e_create_skill'; const EDIT_SKILL_TOOL_CALL_ID = 'call_e2e_edit_skill'; const EXECUTE_CODE_MARKER = 'E2E_EXECUTE_CODE:'; const FILE_SEARCH_MARKER = 'E2E_FILE_SEARCH:'; -const EXECUTE_CODE_TOOL_NAME = 'execute_code'; +/** Code Interpreter advertises bash_tool/read_file at runtime (execute_code is legacy); + * emit whichever the agent actually exposes so the tool batch — and provisioning — fires. */ +const CODE_EXEC_TOOLS = [ + { name: 'bash_tool', args: { command: 'echo e2e' } }, + { name: 'read_file', args: { path: '/mnt/data' } }, + { name: 'execute_code', args: { lang: 'py', code: 'print("e2e")' } }, +]; const FILE_SEARCH_TOOL_NAME = 'file_search'; const EXECUTE_CODE_FINAL_TEXT = 'E2E execute_code complete'; const FILE_SEARCH_FINAL_TEXT = 'E2E file_search complete'; @@ -611,14 +617,14 @@ function fileAuthoringResponses(operation, toolNames) { function provisioningToolResponses({ text, toolNames }) { const codeLabel = getMarkerValue(text, EXECUTE_CODE_MARKER); if (codeLabel) { - console.warn( - `[e2e-diag fake-model] execute_code marker; advertised=${toolNames.has( - EXECUTE_CODE_TOOL_NAME, - )} tools=${JSON.stringify([...toolNames])}`, - ); - if (!toolNames.has(EXECUTE_CODE_TOOL_NAME)) { + const codeTool = CODE_EXEC_TOOLS.find((tool) => toolNames.has(tool.name)); + if (!codeTool) { return { - responses: [`E2E execute_code unavailable: ${EXECUTE_CODE_TOOL_NAME} was not advertised.`], + responses: [ + `E2E execute_code unavailable: no code-execution tool advertised (saw ${ + JSON.stringify([...toolNames]) || 'none' + }).`, + ], }; } return { @@ -626,8 +632,8 @@ function provisioningToolResponses({ text, toolNames }) { toolCalls: [ { id: EXECUTE_CODE_TOOL_CALL_ID, - name: EXECUTE_CODE_TOOL_NAME, - args: { lang: 'py', code: 'print("e2e")' }, + name: codeTool.name, + args: codeTool.args, type: 'tool_call', }, ],