pub struct Resolver { /* private fields */ }Expand description
A named async value source whose inputs come from State and whose result
lands back in State under {name}:result (or {name}:error).
Resolver is the async sibling of the deterministic
Recognizer: both are inputs from State →
value. A Resolver
generalizes call from “a sub-agent” to any async source — a sub-agent
(Resolver::agent) or a system fetch / tool call / MCP request
(Resolver::fetch) — under one result convention, so a Flow step can
complete on it via Guard::resolved
regardless of where the value came from.
Implementations§
Source§impl Resolver
impl Resolver
Sourcepub fn agent(name: impl Into<String>, agent: Arc<dyn TextAgent>) -> Self
pub fn agent(name: impl Into<String>, agent: Arc<dyn TextAgent>) -> Self
Resolve by running a sub-agent. Its String output becomes the result.
Sourcepub fn fetch<F, Fut>(name: impl Into<String>, f: F) -> Self
pub fn fetch<F, Fut>(name: impl Into<String>, f: F) -> Self
Resolve by running an async closure over a clone of State — the seam
for an HTTP fetch, a tool call, or an MCP request. The closure returns
Ok(value) on success or Err(message) to record an error.
Sourcepub fn llm(
name: impl Into<String>,
llm: Arc<dyn BaseLlm>,
prompt: impl Into<String>,
) -> Self
pub fn llm( name: impl Into<String>, llm: Arc<dyn BaseLlm>, prompt: impl Into<String>, ) -> Self
Resolve by running a one-shot OOB LLM over a State-interpolated prompt
({key} placeholders). The completion text becomes the result.
Sourcepub async fn resolve(&self, state: &State) -> Result<Value, String>
pub async fn resolve(&self, state: &State) -> Result<Value, String>
Resolve synchronously (Mode::Call): await the source, write its
value to {name}:result (or its error to {name}:error), record its
provenance under state_meta:{name}:result, and return it.
Sourcepub fn dispatch(self, state: State)
pub fn dispatch(self, state: State)
Resolve detached (Mode::Dispatch): spawn the resolution on the
runtime and return immediately. The conversation does not wait; consumers
observe completion reactively via {name}:result.