The tool system is one of the most important architectural components of Flux-CLI. It provides a unified interface for the agent to interact with the world.
sequenceDiagram participant Agent as Agent participant Registry as Tool Registry participant Safety as Approval Manager participant Hook as Hook System participant Tool as Tool Agent->>Registry: invoke(name, params, cwd) activate Registry Registry->>Registry: Look up tool by name alt Tool not found Registry-->>Agent: ToolResult.error("Unknown tool") end Registry->>Registry: validate_params(params) alt Invalid params Registry-->>Agent: ToolResult.error("Invalid parameters") end Registry->>Hook: trigger_before_tool(name, params) Registry->>Tool: get_confirmation(invocation) Tool-->>Registry: ToolConfirmation Registry->>Safety: check_approval(context) alt Rejected Registry-->>Agent: ToolResult.error("Rejected by safety policy") end alt Needs Confirmation Registry->>Safety: request_confirmation(confirmation) Safety-->>Registry: approved? end Registry->>Tool: execute(invocation) Tool-->>Registry: ToolResult Registry->>Hook: trigger_after_tool(name, params, result) deactivate Registry Registry-->>Agent: ToolResult