🐛 fix: Provision search files for programmatic tool calls

A file_search configured with allowed_callers: ['code_execution'] is reachable
only through run_tools_with_code, whose nested tool names never reach the
provisioning predicate, so the nested search ran before queued attachments were
embedded and silently searched without them. Programmatic tool calls now mark
the turn as needing search.
This commit is contained in:
Danny Avila 2026-08-31 11:24:16 -04:00
parent ed2969a27b
commit b5a274cbb3

View file

@ -473,7 +473,13 @@ const initializeClient = async ({
toolNames.includes(Constants.EDIT_FILE) ||
toolNames.includes(Constants.WRITE_FILE) ||
toolNames.includes(Constants.BASH_PROGRAMMATIC_TOOL_CALLING);
const needsSearch = toolNames.includes('file_search');
/** Programmatic tool calling orchestrates nested tools whose names never reach
* this predicate, so a file_search reachable only through PTC would otherwise
* run before its attachments were embedded. Provision when PTC is invoked. */
const needsSearch =
toolNames.includes('file_search') ||
toolNames.includes(Constants.PROGRAMMATIC_TOOL_CALLING) ||
toolNames.includes(Constants.BASH_PROGRAMMATIC_TOOL_CALLING);
if (!needsCode && !needsSearch) {
return;