🐛 fix: Provision unified uploads for bash_tool/read_file code execution

provisionFiles only treated execute_code / run_tools_with_code as code execution,
but that capability now expands into bash_tool / read_file / run_tools_with_bash.
So a unified upload in provisionState.codeEnvFiles was never provisioned before the
first bash_tool/read_file call — the file was missing from the sandbox (Codex P1).

Broaden the needsCode guard to the current tool names. The lazy-provisioning e2e
now emits the actually-advertised code-exec tool (bash_tool) so it exercises the
real path. Removes the temporary diagnostics.
This commit is contained in:
Danny Avila 2026-07-09 11:16:57 -04:00
parent c9051310a6
commit 900778f044
2 changed files with 22 additions and 14 deletions

View file

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

View file

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