Skip to main content

Agent

Struct Agent 

Source
pub struct Agent {
    pub proc: Option<Arc<DaggerSessionProc>>,
    pub selection: Selection,
    pub graphql_client: DynGraphQLClient,
}

Fields§

§proc: Option<Arc<DaggerSessionProc>>§selection: Selection§graphql_client: DynGraphQLClient

Implementations§

Source§

impl Agent

Source

pub async fn error(&self) -> Result<String, DaggerError>

Why the loop failed, for a FAILED agent; empty otherwise. The snapshot holds the completed prefix — send or resume retries from it.

Source

pub async fn handle(&self) -> Result<String, DaggerError>

The opaque runtime handle minted by the spawn that created this agent. It is the same value the agent’s loop span publishes as dagger.io/agent.id, so a client can correlate the agent with what it discovers in the trace. Two spawns of an identical composition have different handles; a display name is shared freely.

Source

pub async fn id(&self) -> Result<Id, DaggerError>

A unique identifier for this Agent.

Source

pub fn message(&self, ref: impl Into<String>) -> AgentMessage

Look up a previously sent message by its ref. This is the lookup send pins its result’s identity through: the returned handle’s ID is an honest, replayable chain, addressable from any request in the session (the cancel-and-request-again contract). Fails if the agent has no runtime entry in this session, or no record of the given ref.

§Arguments
  • r#ref - The message’s short ref within this agent’s runtime, e.g. “#3”: the token its attribution header shows and a reply’s replyTo names. A bare ordinal (“3”) is accepted too.
Source

pub async fn name(&self) -> Result<String, DaggerError>

Display label for the agent; carries no identity.

Source

pub async fn notify( &self, subscriber: impl IntoID<Id>, ) -> Result<Agent, DaggerError>

Subscribe another agent to this agent’s lifecycle: each transition into one of the given states enqueues an event message to the subscriber — steering its open turn, or waking it if idle, like any other message. This is how a supervisor hears every completion and failure without polling or blocking: subscribe at spawn time, keep working, and events arrive as attributed messages. Events never relaunch a stopped subscriber, and an already-reached state fires immediately at subscribe time, so a fast agent settling before the subscription lands is not missed. Idempotent per subscriber; re-subscribing replaces the state set.

§Arguments
  • subscriber - The agent to deliver event messages to. You must hold its handle: subscriptions are capability-based like everything else.
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub async fn notify_opts( &self, subscriber: impl IntoID<Id>, opts: AgentNotifyOpts, ) -> Result<Agent, DaggerError>

Subscribe another agent to this agent’s lifecycle: each transition into one of the given states enqueues an event message to the subscriber — steering its open turn, or waking it if idle, like any other message. This is how a supervisor hears every completion and failure without polling or blocking: subscribe at spawn time, keep working, and events arrive as attributed messages. Events never relaunch a stopped subscriber, and an already-reached state fires immediately at subscribe time, so a fast agent settling before the subscription lands is not missed. Idempotent per subscriber; re-subscribing replaces the state set.

§Arguments
  • subscriber - The agent to deliver event messages to. You must hold its handle: subscriptions are capability-based like everything else.
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub async fn pause(&self) -> Result<Agent, DaggerError>

Stop draining the mailbox once the in-flight step completes, or immediately with interrupt. Pause takes priority over pending work: a mid-turn pause suspends the turn, which resume continues. Messages sent while paused enqueue with QUEUED delivery until a resume. Pausing a never-started agent leaves it paused for its eventual resume; pausing a failed agent is allowed (resume decides the retry); pausing a stopped agent fails.

§Arguments
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub async fn pause_opts( &self, opts: AgentPauseOpts, ) -> Result<Agent, DaggerError>

Stop draining the mailbox once the in-flight step completes, or immediately with interrupt. Pause takes priority over pending work: a mid-turn pause suspends the turn, which resume continues. Messages sent while paused enqueue with QUEUED delivery until a resume. Pausing a never-started agent leaves it paused for its eventual resume; pausing a failed agent is allowed (resume decides the retry); pausing a stopped agent fails.

§Arguments
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub async fn reseed( &self, conversation: impl IntoID<Id>, ) -> Result<Agent, DaggerError>

Replace this instance’s committed conversation with the given one, keeping the entry: identity, mailbox, and lifecycle state are untouched. A paused suspended turn is abandoned and its consumed messages are resolved before replacement. This is the continuity verb. Compaction, a workspace rebind, a model change, or rewinding an interrupted prompt produce a new conversation value for the SAME agent; reseed swaps it in place, where a stop-and-respawn would mint a successor instance and split the agent across two roster entries. It is the client-facing form of what a continuation tool already does mid-turn: the agent adopts a new conversation without changing who it is. The next turn continues from the reseeded conversation, and queued messages drain onto it. A FAILED agent keeps its error — resume retries from the new conversation. Fails if the instance has no runtime entry in this session (only a spawned or re-hydrated instance holds a conversation to replace), if a step is in flight, or if the agent is stopped.

§Arguments
  • conversation - The conversation that becomes the agent’s committed history, replacing the current one.
Source

pub async fn resume(&self) -> Result<Agent, DaggerError>

Resume draining the mailbox: a suspended turn continues from the last committed step, and queued messages drain. Resuming a never-started agent starts its evaluation loop, detached from the calling request: it steps the conversation while input is pending, then idles awaiting further lifecycle operations. Resuming a FAILED agent retries its pending step. Resuming a STOPPED agent relaunches the same instance from its last committed snapshot. No-op on a running or idle agent.

Source

pub async fn send( &self, message: impl Into<String>, ) -> Result<AgentMessage, DaggerError>

Enqueue a message, on the record: it is consumed at a step boundary, appends to the agent’s history, and steers the running turn or opens a new one. Never blocks, never drops; concurrent sends queue in order. The returned message is pinned through the message lookup field, so its handle is re-addressable from any request in the session: cancel a response request and request it again freely. Sending to a never-started agent starts it (signal-with-start). Sending to a stopped agent restarts the same instance from its last committed snapshot. Sending to a paused or failed agent enqueues with QUEUED delivery, to be drained by a resume.

§Arguments
  • message - The message text, appended to the agent’s history as a prompt when a turn consumes it.
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub async fn send_opts<'a>( &self, message: impl Into<String>, opts: AgentSendOpts<'a>, ) -> Result<AgentMessage, DaggerError>

Enqueue a message, on the record: it is consumed at a step boundary, appends to the agent’s history, and steers the running turn or opens a new one. Never blocks, never drops; concurrent sends queue in order. The returned message is pinned through the message lookup field, so its handle is re-addressable from any request in the session: cancel a response request and request it again freely. Sending to a never-started agent starts it (signal-with-start). Sending to a stopped agent restarts the same instance from its last committed snapshot. Sending to a paused or failed agent enqueues with QUEUED delivery, to be drained by a resume.

§Arguments
  • message - The message text, appended to the agent’s history as a prompt when a turn consumes it.
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub fn snapshot(&self) -> Llm

The conversation as of the last committed step: immutable, branchable, persistable. The seed conversation if the agent never stepped. Branching from it does not affect the agent.

Source

pub async fn state(&self) -> Result<AgentState, DaggerError>

Computed lifecycle state; never stored. An agent that was never started reports IDLE: its mailbox is empty and no turn is open.

Source

pub async fn stop(&self) -> Result<Agent, DaggerError>

Release the agent’s runtime. The tombstone (state, snapshot) stays readable for the rest of the session.

§Arguments
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub async fn stop_opts(&self, opts: AgentStopOpts) -> Result<Agent, DaggerError>

Release the agent’s runtime. The tombstone (state, snapshot) stays readable for the rest of the session.

§Arguments
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub async fn wait(&self) -> Result<Agent, DaggerError>

Block until the agent settles: IDLE, FAILED, or STOPPED. Read which from state afterwards. Unlike waiting for one exact state, this cannot hang merely because the agent settled in a different outcome.

Trait Implementations§

Source§

impl Clone for Agent

Source§

fn clone(&self) -> Agent

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl IntoID<Id> for Agent

Source§

fn into_id( self, ) -> Pin<Box<dyn Future<Output = Result<Id, DaggerError>> + Send>>

Source§

impl Loadable for Agent

Source§

fn graphql_type() -> &'static str

The GraphQL type name (e.g. "Container").
Source§

fn from_query( proc: Option<Arc<DaggerSessionProc>>, selection: Selection, graphql_client: DynGraphQLClient, ) -> Self

Construct this type from a query selection.
Source§

impl Node for Agent

Source§

fn id(&self) -> impl Future<Output = Result<Id, DaggerError>> + Send

Auto Trait Implementations§

§

impl !RefUnwindSafe for Agent

§

impl !UnwindSafe for Agent

§

impl Freeze for Agent

§

impl Send for Agent

§

impl Sync for Agent

§

impl Unpin for Agent

§

impl UnsafeUnpin for Agent

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more