pub struct Agent { /* private fields */ }Implementations§
Source§impl Agent
impl Agent
pub fn builder(name: impl Into<String>) -> AgentBuilder
pub fn name(&self) -> &str
Sourcepub fn to_builder(&self) -> AgentBuilder
pub fn to_builder(&self) -> AgentBuilder
A builder pre-filled with this agent’s configuration, for deriving variants (another model, journal or tool set).
pub fn worker_id(&self) -> &str
pub fn journal(&self) -> &Arc<dyn Journal> ⓘ
Sourcepub async fn run(
&self,
input: impl Into<String>,
) -> Result<RunOutcome, AgentError>
pub async fn run( &self, input: impl Into<String>, ) -> Result<RunOutcome, AgentError>
Start a new run with a user message and drive it.
pub async fn run_message( &self, input: Message, ) -> Result<RunOutcome, AgentError>
Sourcepub async fn run_with_id(
&self,
run_id: &str,
input: impl Into<String>,
) -> Result<RunOutcome, AgentError>
pub async fn run_with_id( &self, run_id: &str, input: impl Into<String>, ) -> Result<RunOutcome, AgentError>
Start a new run under an id the caller chooses, and drive it.
For a worker serving an outside job queue: derive the id from the job
(e.g. "task-42:1"), and after a crash the run can be found and
resumed without having stored a generated id
anywhere first. Fails with AgentError::RunExists if the id is
already in the journal.
Sourcepub async fn resume(&self, run_id: &str) -> Result<RunOutcome, AgentError>
pub async fn resume(&self, run_id: &str) -> Result<RunOutcome, AgentError>
Continue a run from its journal, e.g. after a crash or an approval. Completed tool calls are never re-executed; a call that was in flight during a crash runs again with the same idempotency key.
Takes the run’s lease first, so two workers never drive the same run;
the loser gets AgentError::Leased.