pub struct BuiltAgent { /* private fields */ }Expand description
An agent that passed every build check, ready to run many times.
Cheap to clone and safe to share across tasks; each run gets its own
state, and in-memory checkpoints are dropped after the run.
Implementations§
Source§impl BuiltAgent
impl BuiltAgent
Sourcepub async fn start(&self, input: impl Into<Input>) -> Result<RunId, KitError>
pub async fn start(&self, input: impl Into<Input>) -> Result<RunId, KitError>
Starts a run on input: checks it, saves the first checkpoint and
returns the run id, with no model call. Continue it with resume
or resume_for. Needs Storage::sqlite(..) or Storage::custom(..).
Sourcepub async fn resume_for(
&self,
run_id: RunId,
budget: Duration,
) -> Result<Progress, KitError>
pub async fn resume_for( &self, run_id: RunId, budget: Duration, ) -> Result<Progress, KitError>
Continues run run_id for about budget, saving after every step.
A step in flight finishes, so leave one model call of slack in a
background window. Fails with Failed, Paused or Retries as
resume does; a retry wait that would pass the budget is Pending
and is saved, so the next window waits out what is left of it.
Source§impl BuiltAgent
impl BuiltAgent
Sourcepub async fn stream(
&self,
input: impl Into<Input>,
) -> Result<RunStream, KitError>
pub async fn stream( &self, input: impl Into<Input>, ) -> Result<RunStream, KitError>
Starts a run on input and returns its event stream once the run
id is known, with the default buffer. Fails at the call on a bad
input or setup, as start does. Needs no durable storage.
Sourcepub async fn stream_with(
&self,
input: impl Into<Input>,
settings: StreamSettings,
) -> Result<RunStream, KitError>
pub async fn stream_with( &self, input: impl Into<Input>, settings: StreamSettings, ) -> Result<RunStream, KitError>
Starts a streamed run on input with settings. Events also reach
the agent’s own .events(..) sink. Fails with Config when the
capacity is out of range, else as stream.
Source§impl BuiltAgent
impl BuiltAgent
Sourcepub fn trace_path(&self) -> Option<&Path>
pub fn trace_path(&self) -> Option<&Path>
Returns the trace file this agent writes, one root span per run.
None when tracing is off or goes to a custom sink.
The file is created at build.
Sourcepub async fn run(&self, input: impl Into<Input>) -> Result<String, KitError>
pub async fn run(&self, input: impl Into<Input>) -> Result<String, KitError>
Runs the agent once on input and returns the answer as text.
Retries transient provider failures; fails with Failed,
Paused or Retries when the run ends without an answer.
Sourcepub async fn run_with(
&self,
input: impl Into<Input>,
) -> Result<RunOutcome, KitError>
pub async fn run_with( &self, input: impl Into<Input>, ) -> Result<RunOutcome, KitError>
Runs the agent once on input and returns the full outcome.
Same failures as run.
The run id in the outcome works with resume.
Sourcepub async fn resume(&self, run_id: RunId) -> Result<String, KitError>
pub async fn resume(&self, run_id: RunId) -> Result<String, KitError>
Continues run run_id from its latest checkpoint, after a crash
or restart, and returns the answer. A finished run returns its
answer again. Needs Storage::sqlite(..) or Storage::custom(..).
Refuses another agent’s run; limits become the stricter of the
run’s and this agent’s, and the retry budget counts across resumes.