pub struct Agent { /* private fields */ }Expand description
The configured system prompt followed by each plugin’s prompt fragments, separated by a blank line. Fragments are additive only: a plugin cannot rewrite or drop the prompt.
Implementations§
Source§impl Agent
impl Agent
pub fn new( provider: Arc<dyn ChatProvider>, tools: Arc<ToolRegistry>, store: SessionStore, system_prompt: String, max_iterations: usize, ) -> Self
Sourcepub fn with_max_iterations(self, iterations: usize) -> Self
pub fn with_max_iterations(self, iterations: usize) -> Self
Stop a run after iterations model <-> tool round-trips. This is the agent’s own
budget ([agent] max_iterations); a single run overrides it with
RunOptions::max_iterations. 0 is read as 1.
Sourcepub fn max_iterations(&self) -> usize
pub fn max_iterations(&self) -> usize
The budget this agent gives a run that asks for none.
Sourcepub fn with_tool_concurrency(self, n: usize) -> Self
pub fn with_tool_concurrency(self, n: usize) -> Self
How many of one turn’s tool calls may be in flight at once. 0 is read as 1; results are committed in the order the model emitted the calls either way.
Sourcepub fn with_trace_content(self, on: bool) -> Self
pub fn with_trace_content(self, on: bool) -> Self
Include prompts, arguments and results in tracing spans. Off by default: the transcript already shows them, and the spans exist for timing and routing.
pub fn trace_content(&self) -> bool
Sourcepub fn with_cassette_recording(self, name: &str, path: PathBuf) -> Self
pub fn with_cassette_recording(self, name: &str, path: PathBuf) -> Self
Record every request and reply of this agent’s next run to a cassette file.
The cassette is taken as <state>/cassettes/<name>.json.
Sourcepub fn with_cassette_replay(self, path: PathBuf) -> Result<Self>
pub fn with_cassette_replay(self, path: PathBuf) -> Result<Self>
Replay every request of this agent’s next run from a cassette file, failing at the first divergence. The cassette is loaded here, so an unreadable one is a build error, not a runtime surprise.
Sourcepub fn take_cassette_recording(
&self,
) -> Option<(Arc<RecordingProvider>, String, PathBuf)>
pub fn take_cassette_recording( &self, ) -> Option<(Arc<RecordingProvider>, String, PathBuf)>
The recorder for the run just finished, if this agent recorded one — with its name and path, for the caller to save. Consumed.
Sourcepub fn tool_concurrency(&self) -> usize
pub fn tool_concurrency(&self) -> usize
The tool gate this agent runs with.
Sourcepub fn with_hooks(self, hooks: LoopHooks) -> Self
pub fn with_hooks(self, hooks: LoopHooks) -> Self
Register the loop hooks this agent runs. Hooks run in the order given; see
crate::hooks for what they may do and why they must be cheap.
Sourcepub fn hook_count(&self) -> usize
pub fn hook_count(&self) -> usize
How many loop hooks are registered.
Sourcepub fn with_max_malformed_calls(self, n: usize) -> Self
pub fn with_max_malformed_calls(self, n: usize) -> Self
Stop the run after n consecutive unusable tool calls. 0 leaves it off.
Sourcepub fn plugins(&self) -> &Plugins
pub fn plugins(&self) -> &Plugins
The plugins this agent loaded, including any that failed to load and why.
Sourcepub fn tool_names(&self) -> Vec<String>
pub fn tool_names(&self) -> Vec<String>
Every tool the model can call, in registry order — what the CLI banner lists.
Sourcepub fn context_reading(&self, used: Option<u64>) -> Reading
pub fn context_reading(&self, used: Option<u64>) -> Reading
The context budget this agent trims to (0 = no budget set).
An explicit provider.context_budget_tokens wins, because a person who wrote a number
The context bar, as this agent’s loop reads it: the model’s window as the denominator,
with the compaction threshold as the tripwire when both numbers are known.
One place, because three surfaces draw it (#264). The dashboard used to divide by the
compaction rail — the only number the stats event carried — so ctx 12.3K/279K claimed a
percentage of something the model had never been told, and the rail’s own share of the
window was drawn nowhere. used is the prompt the turn actually sent; None before the
first turn, which is not the same as zero.
Sourcepub fn reasoning_report(&self) -> InForce
pub fn reasoning_report(&self) -> InForce
What the next request will ask for, in the one wording every surface uses (#264).
From the dial and the route’s own profile — never from [provider] reasoning_effort, which
stops being the answer the moment /reasoning runs.
Sourcepub fn context_budget(&self) -> usize
pub fn context_budget(&self) -> usize
The context budget the loop will use for the next request: provider.context_budget_tokens
when a person wrote a number, else [context] compact_at of the model’s window — advertised
by the endpoint, else window_tokens, else nothing. A window nobody stated is never
guessed at: a request is not shortened on a fiction.
Sourcepub fn context_budget_is_configured(&self) -> bool
pub fn context_budget_is_configured(&self) -> bool
True when a number was written in provider.context_budget_tokens, which wins over
anything a window implies — a person who wrote a rail meant that rail.
Sourcepub fn context_window(&self) -> usize
pub fn context_window(&self) -> usize
The model’s window as this process understands it: what the endpoint advertised, else
what [context] window_tokens says, else 0 = unknown.
Sourcepub fn tool_spec_tokens(&self) -> usize
pub fn tool_spec_tokens(&self) -> usize
Estimated tokens the tool definitions cost in every request. The loop charges this to
the budget before it plans the windows, and eclipse context prints it, so the two
numbers cannot drift apart.
Sourcepub fn set_advertised_window(&self, tokens: usize)
pub fn set_advertised_window(&self, tokens: usize)
Record what the endpoint says it can hold. Called by whoever probes it — startup, and again after a model switch — so a rail derived from a window follows the model.
Sourcepub async fn probe_advertised_window(
&self,
cfg: &Config,
timeout: Duration,
) -> usize
pub async fn probe_advertised_window( &self, cfg: &Config, timeout: Duration, ) -> usize
Ask the endpoint what this model can hold, once, and keep the answer.
Best effort and bounded, so a front end can call it at startup without a server
holding the door open: a server that does not answer leaves the window unknown, and a
window nobody stated is never guessed at. Nothing is asked when the answer cannot change
anything — an explicit provider.context_budget_tokens or a [context] window_tokens
already say what the rail is. Returns Self::context_budget afterwards.
Without this a process has no window, so compact_at has nothing to take a share of and
a long conversation is never compacted — which is why both front ends call it before
their first prompt rather than only the one that prints a meter.
Sourcepub fn with_plugins(self, loaded: Plugins) -> Self
pub fn with_plugins(self, loaded: Plugins) -> Self
Record the plugin set this agent was built with (used by
from_config_with_env and by tests).
Sourcepub fn with_lock_wait(self, wait: Duration) -> Self
pub fn with_lock_wait(self, wait: Duration) -> Self
How long a run waits for another process holding the same session. 0 = fail on the first refusal.
Sourcepub fn with_context_budget(self, tokens: usize) -> Self
pub fn with_context_budget(self, tokens: usize) -> Self
Bound each request to roughly this many estimated tokens (0 = no limit); see
crate::context.
Sourcepub fn with_context_policy(
self,
compact_at: f64,
protect_last_n: usize,
window_tokens: usize,
handoff_chars: usize,
) -> Self
pub fn with_context_policy( self, compact_at: f64, protect_last_n: usize, window_tokens: usize, handoff_chars: usize, ) -> Self
[context]: the share of the model’s window at which a request is compacted, the
turns kept verbatim at the tail, and a window to assume when nobody advertises one.
Sourcepub fn handoff_budget(&self) -> usize
pub fn handoff_budget(&self) -> usize
The character budget for a compiled handoff: [context] handoff_chars, but never more
than a quarter of the request’s own rail. A handoff that competes with the protected tail
for the same window is a second context problem rather than a fix for the first.
Sourcepub fn compress_now(&self)
pub fn compress_now(&self)
Compact this session from now on, whatever the budget says: every request keeps the first
turn and the newest protect_last_n turns verbatim and replaces everything between them
with the compiled handoff. The transcript on disk is untouched, so /compress can never
lose a message — it changes what is sent, and the handoff’s [#N] rows still point at the
rows of the transcript they stand in for.
It is process-wide by design: the thing a person wants when they type /compress is a
smaller session from here on, not one shrunken request followed by a full one again.
Sourcepub fn with_judgement(self, on: bool, timeout: Duration) -> Self
pub fn with_judgement(self, on: bool, timeout: Duration) -> Self
Ask one model one bounded question about the dropped turns, and let its answer into the handoff when it survives the validator. On by default: this pass is compaction’s model half — the document is compiled deterministically, and this is the part that explains why the work went the way it did. Turn it off for a run that must spend nothing.
Sourcepub fn with_approval_judge(self, on: bool) -> Self
pub fn with_approval_judge(self, on: bool) -> Self
#340: let the aux route decide ask-policy calls — allow, deny, or escalate to the
person. Never on unless the config says [cli] approval = "smart".
Sourcepub fn approval_judge(&self) -> bool
pub fn approval_judge(&self) -> bool
Whether this agent is in smart approval mode. Read by the stats row, so a mode that skips
cards cannot be on without saying so.
Sourcepub fn with_autotitle(self, on: bool) -> Self
pub fn with_autotitle(self, on: bool) -> Self
Let sessions be named: the derived name on the turn’s own path, and at most one small call
to replace it. Called by Agent::from_config_with_env from [sessions] autotitle; an
agent built by hand is left off, because the tests that build one are asserting on the
exact requests their provider was given.
Sourcepub fn with_provider_config(self, cfg: ProviderConfig) -> Self
pub fn with_provider_config(self, cfg: ProviderConfig) -> Self
Remember the provider configuration, so a model chosen at runtime can become a
provider again. Called by Agent::from_config_with_env; an agent built any other way
has no configuration to rebuild from and says so if asked to switch model.
Sourcepub fn with_routes(self, routes: Vec<AgentRoute>, source: ChainSource) -> Self
pub fn with_routes(self, routes: Vec<AgentRoute>, source: ChainSource) -> Self
Use a chain of routes. The first is the route this agent’s model, /model and models
listing refer to; with Fallback or Pinned a Router is
built over the chain for each run. Called by Agent::from_config_with_env.
Sourcepub fn selected_config(&self) -> Option<&ProviderConfig>
pub fn selected_config(&self) -> Option<&ProviderConfig>
The settings of the selected route: [provider] unless a pin or a chain says otherwise.
Sourcepub async fn advertised_context_window(
&self,
timeout: Duration,
) -> Option<usize>
pub async fn advertised_context_window( &self, timeout: Duration, ) -> Option<usize>
What the selected route says the model that will answer next can hold. None when it
says nothing usable, which is not an error: the caller keeps whatever budget it had.
Asked after a model switch, because the window belongs to the model, not to the process.
Sourcepub fn chain_source(&self) -> ChainSource
pub fn chain_source(&self) -> ChainSource
Where the route chain came from.
Sourcepub fn route_infos(&self) -> Vec<RouteInfo>
pub fn route_infos(&self) -> Vec<RouteInfo>
The routes a run will try, in order, with the model each serves. A single entry named
default when no chain is configured; empty for an agent built around a bare provider.
Sourcepub fn with_turn_results(self, turn_results: Arc<TurnResults>) -> Self
pub fn with_turn_results(self, turn_results: Arc<TurnResults>) -> Self
Share the per-turn tool-result buffer with the [MemoryTool] in this agent’s registry.
Sourcepub fn with_aux_provider(self, aux: Arc<dyn ChatProvider>) -> Self
pub fn with_aux_provider(self, aux: Arc<dyn ChatProvider>) -> Self
Send the agent’s own auxiliary requests (the trimmed-turn summary) to a different provider. The agent does the rest of the work with the main one.
Sourcepub fn with_aux_route(self, route: AgentRoute) -> Self
pub fn with_aux_route(self, route: AgentRoute) -> Self
Send auxiliary work to the route [provider] aux names. The route’s own settings
(timeout, retries) govern the request: a dead aux route spends its own max_retries,
and the summary then falls back to the plain trim note. It has no router and no chain,
because a summary is not worth walking one.
Sourcepub fn roles(&self) -> Vec<RoleRoute>
pub fn roles(&self) -> Vec<RoleRoute>
Which route each role uses: crate::router::role_table over what this agent holds.
Sourcepub fn with_sight(
self,
vision: VisionConfig,
sight: Option<(AgentRoute, Describe)>,
) -> Self
pub fn with_sight( self, vision: VisionConfig, sight: Option<(AgentRoute, Describe)>, ) -> Self
Record the route [provider] delegate names, for the role table. The delegate tool
is what uses it; this only lets the readouts say so.
[vision], and the provider that describes a picture when the turn’s model cannot see it
(#346). Called by Agent::from_config_with_env from the config; an agent built by hand
keeps auto with no route, which refuses an attach rather than sending bytes anywhere.
The route arrives with the crate::vision::Describe the planner reads, so “is it on this
machine” is answered by whoever resolved the route and never re-guessed here (#356).
pub fn with_delegate_route(self, name: Option<String>) -> Self
Sourcepub fn with_model_cell(self, cell: Arc<Mutex<Option<String>>>) -> Self
pub fn with_model_cell(self, cell: Arc<Mutex<Option<String>>>) -> Self
Share the cell --model / /model writes with whoever else needs to see it. The
delegate tool reads the same cell, built before the agent exists.
pub fn aux_provider(&self) -> &Arc<dyn ChatProvider> ⓘ
Sourcepub fn model(&self) -> Option<String>
pub fn model(&self) -> Option<String>
The model this agent will use next: the one chosen at runtime, else the one the selected route is configured with.
Sourcepub fn set_route(&self, name: Option<&str>) -> Result<()>
pub fn set_route(&self, name: Option<&str>) -> Result<()>
Choose the route the next runs start from, by name. None goes back to the first.
The model chosen for the previous route is cleared with it: a model is a name one endpoint serves, and carrying it to another endpoint is how a run fails with a 404 halfway through. The name is checked here, where the person is, so a typo does not wait for a turn to fail.
Sourcepub async fn list_models_for(&self, route: Option<&str>) -> Result<Vec<String>>
pub async fn list_models_for(&self, route: Option<&str>) -> Result<Vec<String>>
What the endpoint behind route says it serves, or the selected one when None. This is
the provider step of /model: choosing where to look comes before choosing what.
Sourcepub fn set_model(&self, model: Option<String>) -> Result<()>
pub fn set_model(&self, model: Option<String>) -> Result<()>
Use model from the next run on, leaving the configuration file alone. None clears
the choice and goes back to whatever the configuration says.
The provider is built here rather than at the start of the run so that a model the server cannot actually be asked for fails now, where the person is, instead of in the middle of a turn. It does not touch a run already in flight: that one keeps the provider it started with.
Sourcepub async fn list_models(&self) -> Result<Vec<String>>
pub async fn list_models(&self) -> Result<Vec<String>>
What the configured server says it serves. Empty when it answers with nothing usable; an error when it cannot be reached, because “no models” and “wrong address” are different problems and deserve different words.
Sourcepub fn system_prompt(&self) -> &str
pub fn system_prompt(&self) -> &str
The context files gathered for this agent (AGENT.md, USER.md, MEMORY.md) and the skills index, in
injection order, with what was truncated or dropped.
The assembled system prompt this agent sends: the configured prompt, the context files,
the plugin fragments, the skills index, and a bot’s own instructions when it is one
(#509). Read by the Bots tab’s prompt view and by the tests that hold the overlay to it.
pub fn context(&self) -> &Context
pub fn with_context(self, ctx: Context) -> Self
pub fn from_config(cfg: &Config) -> Result<Self>
Sourcepub fn from_config_with_env(cfg: &Config, env: EnvFn<'_>) -> Result<Self>
pub fn from_config_with_env(cfg: &Config, env: EnvFn<'_>) -> Result<Self>
Build the whole agent from config: the provider (with its wire profile), the tool registry (built-ins plus any enabled plugin tools), the plugin hooks, the system prompt (with any plugin prompt fragments) and the session store for this profile.
Sourcepub fn from_config_reporting(
cfg: &Config,
env: EnvFn<'_>,
reporting: Reporting,
) -> Result<Self>
pub fn from_config_reporting( cfg: &Config, env: EnvFn<'_>, reporting: Reporting, ) -> Result<Self>
Agent::from_config_with_env, with the loop hooks of [hooks] reporting where
reporting says rather than on stderr for every run. The one hook set built here goes
to the agent and to every subagent it starts.
Sourcepub fn for_bot(cfg: &Config, env: EnvFn<'_>, name: &str) -> Result<Self>
pub fn for_bot(cfg: &Config, env: EnvFn<'_>, name: &str) -> Result<Self>
#509: the agent one bot’s conversation runs on.
The same config, the same provider, the same store, the same loop — a bot is an identity,
not a second runtime. Three things differ, and only these three: the instructions named by
[bots.<name>].instructions are added to the assembled system prompt (never a
replacement — the run is still the CLI/web agent with the bot’s words in front of it), the
memory tool and the MEMORY.md layer point at the bot’s own file, and skills narrows the
index and the skill_* tools to the names the bot declared.
A bot’s memory file is [bots.<name>].memory, else <profile>/memory/bots/<name>/
alongside the human’s own MEMORY.md name — never the human’s file, which is the one thing
a bot must not be able to write.
Sourcepub fn reasoning(&self) -> Shared
pub fn reasoning(&self) -> Shared
The session’s reasoning dial: /reasoning sets it, every request reads it.
Sourcepub fn describe_effort(&self, level: Option<&str>) -> String
pub fn describe_effort(&self, level: Option<&str>) -> String
What a level becomes on the route the next request will use, in words.
Read here rather than worked out by a front end: the policy comes from the profile the provider will actually be built with (which a manifest may replace), and the model may have its own entry in it. A front end that resolved this itself would be a second guess.
Sourcepub fn reasoning_control(&self) -> Option<Reasoning>
pub fn reasoning_control(&self) -> Option<Reasoning>
The reasoning control the next request’s route resolves to, as data: a front end that keeps it can answer for any level without borrowing the agent.
Sourcepub fn with_reasoning(self, dial: Shared) -> Self
pub fn with_reasoning(self, dial: Shared) -> Self
Use this dial instead of the one Agent::new made. The builder hands in the dial it gave
every route, so the fronts and the providers are looking at the same number.
pub fn store(&self) -> &SessionStore
Sourcepub fn attachments(&self) -> Result<&Store, String>
pub fn attachments(&self) -> Result<&Store, String>
#499: the picture store, or a sentence saying why there is none.
Sourcepub fn with_attachments(self, store: Option<Store>) -> Self
pub fn with_attachments(self, store: Option<Store>) -> Self
Where pictures are kept, when this agent keeps them at all.
Sourcepub fn loop_tick_begin(
&self,
root: &Path,
state: &mut State,
now_ms: i64,
) -> Result<bool>
pub fn loop_tick_begin( &self, root: &Path, state: &mut State, now_ms: i64, ) -> Result<bool>
#173: take a loop tick — or record that it was dropped because the session is busy.
The busy test comes before the run: flock on the session, taken and released at once,
which is what Duration::ZERO means. Ok(true) means the caller may run, and the record
has not been touched; Ok(false) means the tick was recorded as skipped and saved, so a
busy session loses that tick and the next one still fires on schedule.
It lives here, beside the run it guards, because all three fronts tick the same way: the terminal’s interface, the plain REPL and the dashboard’s gateway differ in when they look, never in what a tick is.
Sourcepub async fn loop_tick_end(
&self,
root: &Path,
state: &mut State,
now_ms: i64,
result: Result<Option<String>, String>,
) -> Result<()>
pub async fn loop_tick_end( &self, root: &Path, state: &mut State, now_ms: i64, result: Result<Option<String>, String>, ) -> Result<()>
#173: record what a tick’s run did, and ask the --until question when there is one.
The record is saved before the check, so a process that dies inside the check still has a
truthful fired count on disk. result carries the turn’s last text on success (what the
check reads) and the reason on failure.
Sourcepub async fn goal_after_turn(
&self,
session: &str,
reply: &str,
) -> Result<Option<Goal>>
pub async fn goal_after_turn( &self, session: &str, reply: &str, ) -> Result<Option<Goal>>
#172: judge a finished turn against the session’s standing goal, and record it.
One aux call per judged turn, made here so every front judges the same way. The rules are
the ones in crate::goals: “done” is checked against the goal’s gate before it is
accepted, a gate that fails turns it back into “continue”, and a judge that answers
something else counts as continue once and stops the goal the second time.
The reply is redacted before it leaves, and the goal’s own sentence is the only other thing the judge sees — no transcript.
Nothing happens when the session has no goal, or the goal is paused or finished: a goal is a row, and a session without one costs one read.
Sourcepub fn goal_continuation(&self, session: &str) -> Result<Option<String>>
pub fn goal_continuation(&self, session: &str) -> Result<Option<String>>
#172: the prompt the next turn should carry, when the session’s goal owes one.
A goal owes a turn when it is active and under its budget. The front that owns the session submits it through its own run entry, exactly like a typed prompt — which is why pausing or clearing the goal stops further turns immediately: both are a row this call reads.
Sourcepub async fn until_reached(
&self,
condition: &str,
last_reply: Option<&str>,
) -> Result<Verdict, String>
pub async fn until_reached( &self, condition: &str, last_reply: Option<&str>, ) -> Result<Verdict, String>
#172: ask one model one yes/no question about the reply a loop tick just produced.
It goes to the aux route, on the same provider and the same timeout the judgement pass uses — a check that spends the main model’s context to answer “yes” is not a check. The reply is redacted first, on the same rule as the digest: a tool result that happened to contain a key does not leave this machine because a loop asked a question.
Three answers, not two: crate::loops::Verdict::Unreadable is what a model that explains
itself gets, and the caller keeps looping rather than treating it as a no.
Sourcepub async fn run(
&self,
session_id: Option<&str>,
prompt: &str,
approver: &dyn Approver,
on_event: &(dyn Fn(AgentEvent) + Send + Sync),
) -> Result<RunResult>
pub async fn run( &self, session_id: Option<&str>, prompt: &str, approver: &dyn Approver, on_event: &(dyn Fn(AgentEvent) + Send + Sync), ) -> Result<RunResult>
Run one user prompt to completion, continuing session_id if it exists
(or creating it under that id), otherwise starting a new session.
Not cancellable; see run_cancellable.
Sourcepub async fn run_with(
&self,
session_id: Option<&str>,
prompt: &str,
approver: &dyn Approver,
on_event: &(dyn Fn(AgentEvent) + Send + Sync),
opts: &RunOptions,
) -> Result<RunResult>
pub async fn run_with( &self, session_id: Option<&str>, prompt: &str, approver: &dyn Approver, on_event: &(dyn Fn(AgentEvent) + Send + Sync), opts: &RunOptions, ) -> Result<RunResult>
run with per-run options: today that is the iteration budget, so one
prompt can be given more or fewer turns than the agent’s default without rebuilding
the agent or editing the config.
Sourcepub async fn run_typed<T: DeserializeOwned>(
&self,
session_id: Option<&str>,
prompt: &str,
schema: Value,
approver: &dyn Approver,
on_event: &(dyn Fn(AgentEvent) + Send + Sync),
opts: &RunOptions,
) -> Result<Typed<T>>
pub async fn run_typed<T: DeserializeOwned>( &self, session_id: Option<&str>, prompt: &str, schema: Value, approver: &dyn Approver, on_event: &(dyn Fn(AgentEvent) + Send + Sync), opts: &RunOptions, ) -> Result<Typed<T>>
Run one prompt whose reply must parse into T, against a JSON Schema sent as
response_format. The schema is the caller’s promise to the model; T is the caller’s
promise to itself, and the two are checked separately on purpose — the schema shapes the
request, the parse judges the answer, so a backend that ignores response_format still
gets you either a value or an error that says why not.
One retry, with the parse error as the feedback. Not two: a schema that argues is a schema that gets negotiated down.
Sourcepub async fn run_cancellable(
&self,
session_id: Option<&str>,
prompt: &str,
approver: &dyn Approver,
on_event: &(dyn Fn(AgentEvent) + Send + Sync),
cancel: &Cancel,
) -> Result<RunResult>
pub async fn run_cancellable( &self, session_id: Option<&str>, prompt: &str, approver: &dyn Approver, on_event: &(dyn Fn(AgentEvent) + Send + Sync), cancel: &Cancel, ) -> Result<RunResult>
run with a cancellation signal. The flag is checked before the run
starts, before every provider request, before every tool call and between
iterations; when it is set the run stops and returns Error::Cancelled.
Cancelling is cooperative: a request or tool already in flight is dropped, not finished, and nothing is written for it. The user message stays in the session, so a tool call that was interrupted is answered by the dangling-call repair on the next run.
Runs on the same session are serialised twice: by an in-process mutex, and by an
exclusive lock on <id>.lock that also excludes other processes (the CLI and the
dashboard sharing a state directory). The second one waits up to
LOCK_WAIT.
Sourcepub async fn run_cancellable_with(
&self,
session_id: Option<&str>,
prompt: &str,
approver: &dyn Approver,
on_event: &(dyn Fn(AgentEvent) + Send + Sync),
cancel: &Cancel,
opts: &RunOptions,
) -> Result<RunResult>
pub async fn run_cancellable_with( &self, session_id: Option<&str>, prompt: &str, approver: &dyn Approver, on_event: &(dyn Fn(AgentEvent) + Send + Sync), cancel: &Cancel, opts: &RunOptions, ) -> Result<RunResult>
run_cancellable with per-run options.
Sourcepub async fn run_checked(
&self,
session_id: Option<&str>,
prompt: &str,
approver: &dyn Approver,
on_event: &(dyn Fn(AgentEvent) + Send + Sync),
cancel: &Cancel,
opts: &RunOptions,
validate: Option<&Validator>,
) -> Result<RunResult>
pub async fn run_checked( &self, session_id: Option<&str>, prompt: &str, approver: &dyn Approver, on_event: &(dyn Fn(AgentEvent) + Send + Sync), cancel: &Cancel, opts: &RunOptions, validate: Option<&Validator>, ) -> Result<RunResult>
The run, with an optional parse check for the reply. Every other entry point is this one
plus a decision: an ordinary run passes no check, run_typed passes a Deserialize, and
eclipse run --schema passes “is this JSON” — so there is exactly one loop.