pub trait RegistryFactory: Send + Sync {
// Required method
fn build<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
agent: &'life1 AgentConfig,
ctx: &'life2 RunContext,
) -> Pin<Box<dyn Future<Output = Arc<ToolRegistry>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
}Expand description
Builds the tool registry a sub-agent is allowed to use for one invocation.
Why: How a sub-agent’s tools are wired (fs/bash scoped to the run’s working
directory, a nested delegate_to_agent, search providers, …) is an
orchestration concern that varies by deployment and must not be hard-coded
into the runner. Injecting a factory keeps the runner policy-free and lets
the orchestrator (#1030) and tests supply exactly the registry they want.
What: build receives the resolved AgentConfig and the per-call
RunContext and returns the full registry of tools available to that
agent before allowlist gating; the runner then applies tools.allowed.
Test: runner::tests use a closure-backed factory; production wiring lives
in the orchestrator / tm meta layer.
Required Methods§
Sourcefn build<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
agent: &'life1 AgentConfig,
ctx: &'life2 RunContext,
) -> Pin<Box<dyn Future<Output = Arc<ToolRegistry>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn build<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
agent: &'life1 AgentConfig,
ctx: &'life2 RunContext,
) -> Pin<Box<dyn Future<Output = Arc<ToolRegistry>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Build the (ungated) tool registry for agent under ctx.
Why: The factory owns tool construction; the runner owns gating. Keeping
them separate means a single factory serves every agent and the runner
applies each agent’s own tools.allowed uniformly.
What: Returns an Arc<ToolRegistry> containing all tools the deployment
offers this agent; the runner narrows it to tools.allowed.
Test: Closure-backed impl in runner::tests.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl<F, Fut> RegistryFactory for Fwhere
F: Fn(AgentConfig, RunContext) -> Fut + Send + Sync,
Fut: Future<Output = Arc<ToolRegistry>> + Send,
Blanket impl so a plain async closure can serve as a RegistryFactory.
Why: Most call sites (and every test) want to supply registry assembly as a
one-line closure rather than declaring a named type; this keeps wiring terse.
What: Any Fn(&AgentConfig, &RunContext) -> Fut returning a future of
Arc<ToolRegistry> implements RegistryFactory.
Test: runner::tests::delegate_runs_engineer_loop constructs the runner from
a closure.