-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Problem
Tools currently access config through global state (e.g., OnceLock<AgentContext> in spawn_agent) because the app doesn't create tools directly - they're instantiated via Tool::execute().
This pattern is used by:
spawn_agent.rs:AGENT_CONTEXT: OnceLock<AgentContext>fetch_html(PR Add Chrome profile support to fetch_html tool #45): loads config per-call, should use same pattern for consistency
Current workarounds
- Global
OnceLockinitialized at app startup - Loading config inside the tool handler (inefficient)
Desired solution
Pass config/context through the effect handler system so tools don't need global state. Options:
- Add a
Contextparameter toEffectHandler::call() - Use a trait object for tool context in
ToolExecutor - Dependency injection at tool registration time
Affected code
src/tools/impls/spawn_agent.rs-AGENT_CONTEXTsrc/tools/handlers.rs- effect handlerssrc/tools/exec.rs-ToolExecutor
Metadata
Metadata
Assignees
Labels
No labels