Summary
Audit tool definition stability during task execution to prevent cache invalidation and model confusion from mid-task tool changes.
Background: State of the Art
From Philipp Schmid's 5 Practical Tips for Context Engineering:
"Manage Tools Statically: Avoid changing tool order or availability mid-task, if not explicitly needed. This might break context caching and can/will confuse models if used tools in the history are no longer defined."
Two problems arise from dynamic tool changes:
- Cache invalidation: Tool definitions are part of the prompt prefix. Changing them invalidates caching.
- Model confusion: If the model called
tool_X earlier in the conversation but tool_X is no longer in the tool list, the model may hallucinate or reference unavailable capabilities.
The 12-Factor Agents framework also emphasizes: tools should be predictable and consistent within a task's lifecycle.
Current State in CodeFRAME
Each worker type (Backend, Frontend, Test, Review) presumably has role-specific tooling. Questions:
- Tool list consistency: Does a worker's tool list change during task execution?
- Cross-task tool changes: When a worker gets a new task, do available tools shift?
- Dynamic tool injection: Can the Lead Agent add/remove tools from workers mid-task?
- Tool ordering: Is the order of tool definitions consistent across calls?
Even if tools don't change, reordering tool definitions between calls can break caching.
Investigation Tasks
-
Audit tool definition patterns
- Log tool lists sent with each LLM call
- Diff consecutive calls to identify any changes
- Check both tool availability AND ordering
-
Identify dynamic tool scenarios
- Does context promotion/demotion affect tools?
- Are tools added based on task content (e.g., "this task involves DB, add SQL tools")?
- Do quality gates modify available tools?
-
Implement tool stability guarantees
- Freeze tool list at task start
- Ensure consistent ordering (alphabetical, or fixed priority order)
- If tools must change, do so only at explicit task boundaries
-
Handle legitimate dynamic cases
- If some tools ARE task-dependent, document the pattern
- Consider "tool profiles" per task type, selected at start, frozen during execution
- Log tool changes for debugging
Success Criteria
Implementation Notes
Tool ordering convention: Pick a deterministic order (alphabetical by name, or priority-based) and enforce it in the context builder.
Tool profiles: If workers need different tools for different task types:
TOOL_PROFILES = {
"backend_api": ["file_read", "file_write", "test_run", "lint"],
"backend_db": ["file_read", "file_write", "sql_query", "migration_run"],
"frontend_component": ["file_read", "file_write", "npm_run", "browser_preview"],
}
# Select profile at task start, freeze for duration
History consistency: If a tool was used earlier in conversation history, it should remain in the tool list even if "not needed" for current step, until task completes.
References
Summary
Audit tool definition stability during task execution to prevent cache invalidation and model confusion from mid-task tool changes.
Background: State of the Art
From Philipp Schmid's 5 Practical Tips for Context Engineering:
Two problems arise from dynamic tool changes:
tool_Xearlier in the conversation buttool_Xis no longer in the tool list, the model may hallucinate or reference unavailable capabilities.The 12-Factor Agents framework also emphasizes: tools should be predictable and consistent within a task's lifecycle.
Current State in CodeFRAME
Each worker type (Backend, Frontend, Test, Review) presumably has role-specific tooling. Questions:
Even if tools don't change, reordering tool definitions between calls can break caching.
Investigation Tasks
Audit tool definition patterns
Identify dynamic tool scenarios
Implement tool stability guarantees
Handle legitimate dynamic cases
Success Criteria
Implementation Notes
Tool ordering convention: Pick a deterministic order (alphabetical by name, or priority-based) and enforce it in the context builder.
Tool profiles: If workers need different tools for different task types:
History consistency: If a tool was used earlier in conversation history, it should remain in the tool list even if "not needed" for current step, until task completes.
References