feat(tools): defer low-frequency built-in tools to reduce initial prompt size (#4022)
* feat(tools): defer low-frequency built-in tools to reduce initial prompt size
Mark Monitor, SendMessage, Skill, TaskStop, TodoWrite, and WebFetch as
shouldDefer=true so their full schemas are excluded from the initial
function-declaration list. The model discovers them on demand via
ToolSearch, aligning with Claude Code's deferral strategy for
infrequently used tools.
* fix(tools): don't defer TodoWrite/Skill — they're required by the system prompt
TodoWrite is mandated as high-frequency by the core system prompt
("Use VERY frequently", "IMPORTANT: Always use the TODO_WRITE tool to
plan and track tasks throughout the conversation"). Deferring it forces
a ToolSearch round-trip before every required call, adding latency and
hurting prompt compliance.
SkillTool's full description carries the dynamically generated
<available_skills> listing and the BLOCKING invocation rules
("invoke the relevant Skill tool BEFORE generating any other response").
The deferred-tool summary truncates this, so the model loses both the
list of skills and the activation contract from the initial prompt.
Keep Monitor / SendMessage / TaskStop / WebFetch deferred — those are
genuinely infrequent and have no system-prompt requirement.
This commit is contained in:
parent
0a05ea8004
commit
b949ae070c
@ -677,6 +677,11 @@ export class MonitorTool extends BaseDeclarativeTool<
|
||||
required: ['command'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
true, // isOutputMarkdown
|
||||
false, // canUpdateOutput
|
||||
true, // shouldDefer — monitoring is infrequent
|
||||
false, // alwaysLoad
|
||||
'monitor watch tail log stream background',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -129,6 +129,11 @@ export class SendMessageTool extends BaseDeclarativeTool<
|
||||
required: ['task_id', 'message'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
true, // isOutputMarkdown
|
||||
false, // canUpdateOutput
|
||||
true, // shouldDefer — sending messages to tasks is infrequent
|
||||
false, // alwaysLoad
|
||||
'send message task communicate notify',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -247,6 +247,11 @@ export class TaskStopTool extends BaseDeclarativeTool<
|
||||
required: ['task_id'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
true, // isOutputMarkdown
|
||||
false, // canUpdateOutput
|
||||
true, // shouldDefer — stopping tasks is infrequent
|
||||
false, // alwaysLoad
|
||||
'task stop cancel kill background',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -289,6 +289,11 @@ export class WebFetchTool extends BaseDeclarativeTool<
|
||||
required: ['url', 'prompt'],
|
||||
type: 'object',
|
||||
},
|
||||
true, // isOutputMarkdown
|
||||
false, // canUpdateOutput
|
||||
true, // shouldDefer — web fetching is infrequent
|
||||
false, // alwaysLoad
|
||||
'web fetch url http download content',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user