pub struct Agent {
pub proc: Option<Arc<DaggerSessionProc>>,
pub selection: Selection,
pub graphql_client: DynGraphQLClient,
}Fields§
§proc: Option<Arc<DaggerSessionProc>>§selection: Selection§graphql_client: DynGraphQLClientImplementations§
Source§impl Agent
impl Agent
Sourcepub async fn error(&self) -> Result<String, DaggerError>
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.
Sourcepub async fn handle(&self) -> Result<String, DaggerError>
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.
Sourcepub async fn id(&self) -> Result<Id, DaggerError>
pub async fn id(&self) -> Result<Id, DaggerError>
A unique identifier for this Agent.
Sourcepub fn message(&self, ref: impl Into<String>) -> AgentMessage
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.
Sourcepub async fn name(&self) -> Result<String, DaggerError>
pub async fn name(&self) -> Result<String, DaggerError>
Display label for the agent; carries no identity.
Sourcepub async fn notify(
&self,
subscriber: impl IntoID<Id>,
) -> Result<Agent, DaggerError>
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
Sourcepub async fn notify_opts(
&self,
subscriber: impl IntoID<Id>,
opts: AgentNotifyOpts,
) -> Result<Agent, DaggerError>
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
Sourcepub async fn pause(&self) -> Result<Agent, DaggerError>
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
Sourcepub async fn pause_opts(
&self,
opts: AgentPauseOpts,
) -> Result<Agent, DaggerError>
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
Sourcepub async fn reseed(
&self,
conversation: impl IntoID<Id>,
) -> Result<Agent, DaggerError>
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.
Sourcepub async fn resume(&self) -> Result<Agent, DaggerError>
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.
Sourcepub async fn send(
&self,
message: impl Into<String>,
) -> Result<AgentMessage, DaggerError>
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
Sourcepub async fn send_opts<'a>(
&self,
message: impl Into<String>,
opts: AgentSendOpts<'a>,
) -> Result<AgentMessage, DaggerError>
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
Sourcepub fn snapshot(&self) -> Llm
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.
Sourcepub async fn state(&self) -> Result<AgentState, DaggerError>
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.
Sourcepub async fn stop(&self) -> Result<Agent, DaggerError>
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
Sourcepub async fn stop_opts(&self, opts: AgentStopOpts) -> Result<Agent, DaggerError>
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
Sourcepub async fn wait(&self) -> Result<Agent, DaggerError>
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 Loadable for Agent
impl Loadable for Agent
Source§fn graphql_type() -> &'static str
fn graphql_type() -> &'static str
"Container").Source§fn from_query(
proc: Option<Arc<DaggerSessionProc>>,
selection: Selection,
graphql_client: DynGraphQLClient,
) -> Self
fn from_query( proc: Option<Arc<DaggerSessionProc>>, selection: Selection, graphql_client: DynGraphQLClient, ) -> Self
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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