Skip to main content

Module tool_service

Module tool_service 

Source
Expand description

The real ToolService for the shared world: bridges an agent’s tool calls to the built-in and MCP executors, applying the same policy / approval / interaction flow the imperative worker used - but with interactions routed through the in-memory leviath_runtime::interaction_hub instead of file polling.

The pipeline already applies context_* tools inline (they need ECS-window access), so those never reach here. Every other call is resolved against the agent’s policy layers and executed; ask_user_* / present_for_review are handled by dispatch_dynamic_interaction. File-tracking result rewriting is deliberately not done here: this executor is ECS-free (no context window), so the shared world’s collect_tools applies the agent’s file_tracking config to these results downstream - where the window is available - via the same path top-level agents use. Every daemon agent, sub-agent included, gets file-tracking whenever its blueprint declares it.

Structs§

AgentToolState
Everything one agent needs to execute a tool call: the executors, its policy layers, and its interaction backend. All fields are cheap Arcs so a clone is moved into each exec_for closure. The stage-scoped fields (stage_perms/stage_name) are shared handles the host updates as the agent changes stage.
CliToolService
The shared-world tool service: maps entities to their AgentToolState and builds a per-call executor closure.
DynamicToolCtx
Re-resolution inputs for a dynamic_tools agent - held so CliToolService can re-scan its tools/ directories and re-filter its stage tool defs mid-run.
WriteBudget
Everything one agent needs to execute a tool call: the executors, its policy layers, and its interaction backend. All fields are cheap Arcs so a clone is moved into each exec_for closure. The stage-scoped fields One run’s write ceilings and what it has spent of them (issue #252).

Functions§

dispatch_tools
Resolve policy, handle approvals / dynamic interactions, and execute a batch of tool calls, returning (tool_call_id, result) pairs in call order.