plans/2025-04-11-tool-call-context-implementation.md
Add a required ToolCallContext parameter to the ExecutableTool trait's call method. This will allow for additional context to be passed to tool implementations at runtime, maintaining an extensible structure for future needs while initially keeping the context empty.
Define the ToolCallContext struct in the domain layer
Priority: High
Complexity: Low
Dependencies: None
Create a new struct in forge_domain (likely in a new file tool_call_context.rs) to represent the context passed to tool calls. Initially, this will be an empty struct with the infrastructure in place for future extension.
Create a helper function for test contexts Priority: High Complexity: Low Dependencies: Step 1
Create a function to easily generate a default test context, such as ToolCallContext::for_tests(). This will make it simpler to update test code.
Update the ExecutableTool trait definition
Priority: High
Complexity: Low
Dependencies: Step 1
Modify the trait definition in crates/forge_domain/src/tool_definition.rs to add the ToolCallContext parameter to the call method.
Modify the JsonTool adapter in forge_domain/src/tool.rs
Priority: High
Complexity: Low
Dependencies: Step 3
Update the JsonTool adapter to pass the ToolCallContext to the wrapped tool's call method.
Modify the ToolService implementation
Priority: High
Complexity: Medium
Dependencies: Step 3
Update crates/forge_services/src/tool_service.rs to create and pass a ToolCallContext when calling tools.
Update all tool implementations Priority: High Complexity: High Dependencies: Step 3
Update all implementations of ExecutableTool across the codebase to accept the new ToolCallContext parameter:
crates/forge_services/src/tools/shell/shell_tool.rs)crates/forge_services/src/tools/show_user.rs)crates/forge_services/src/tools/fs/)crates/forge_services/src/tools/patch/)crates/forge_services/src/tools/fetch.rs)Update test implementations with a systematic approach Priority: High Complexity: High Dependencies: Steps 2, 6
Based on the analysis, there are numerous tests that implement ExecutableTool. Adopt the following systematic approach:
a. Create a test utility module with helper functions for creating test contexts b. Update mock tool implementations in test modules:
SuccessTool and FailureTool in tool_service.rsIncremental compilation verification Priority: Medium Complexity: Medium Dependencies: Steps 3-7
Periodically run cargo check after updating each major component or group of related files to catch compilation errors early.
Final verification and testing Priority: High Complexity: Low Dependencies: All previous steps
Run full test suite to verify that all code compiles and tests pass:
cargo insta test --accept --unreferenced=delete
cargo +nightly fmt --all
cargo +nightly clippy --fix --allow-staged --allow-dirty --workspace
ExecutableTool trait includes ToolCallContext as a parameter in its call methodExecutableTool accept and handle the new parameterToolCallContext optional with a default: Could reduce the impact but wouldn't align with the requirement for it to be required.