pub struct Agent { /* private fields */ }Expand description
Stable public entry point for agent execution.
Wraps an AgentRuntime and provides:
Agent::execute()— run the agent loop on a sessionAgent::storage()— access the shared storage backend
Clone is cheap (inner is Arc).
Implementations§
Source§impl Agent
impl Agent
Sourcepub fn from_runtime(runtime: Arc<AgentRuntime>) -> Self
pub fn from_runtime(runtime: Arc<AgentRuntime>) -> Self
Wrap an existing AgentRuntime in an Agent.
Sourcepub fn builder() -> AgentBuilder
pub fn builder() -> AgentBuilder
Return a new builder.
Sourcepub async fn execute(
&self,
session: &mut Session,
req: ExecuteRequest,
) -> Result<()>
pub async fn execute( &self, session: &mut Session, req: ExecuteRequest, ) -> Result<()>
Execute the agent loop with the given request.
Sourcepub async fn execute_direct(
&self,
session: &mut Session,
req: ExecuteRequest,
) -> Result<()>
pub async fn execute_direct( &self, session: &mut Session, req: ExecuteRequest, ) -> Result<()>
Execute a caller-owned session under a complete logical-session activation lifecycle.
Server/child entry points already own an external runner reservation and
therefore use execute plus their existing terminal
handshake. Direct SDK callers have no runner registry, so this wrapper
registers the current run before entering the provider loop, marks it
finalizing immediately after return, migrates any terminal-window legacy
ingress, and lets the router reserve at most one successor for work the
completed reasoning turn did not admit.
Sourcepub async fn begin_direct_execution(
&self,
target_session_id: &str,
) -> Result<DirectExecutionLease>
pub async fn begin_direct_execution( &self, target_session_id: &str, ) -> Result<DirectExecutionLease>
Acquire direct logical-session ownership before an SDK facade performs pre-execution work such as replaying an approved mutating tool.
Sourcepub async fn execute_direct_registered(
&self,
session: &mut Session,
req: ExecuteRequest,
lease: DirectExecutionLease,
) -> Result<()>
pub async fn execute_direct_registered( &self, session: &mut Session, req: ExecuteRequest, lease: DirectExecutionLease, ) -> Result<()>
Execute and finalize a direct run whose ownership was acquired by
begin_direct_execution.
Sourcepub fn persistence(&self) -> &Arc<dyn RuntimeSessionPersistence> ⓘ
pub fn persistence(&self) -> &Arc<dyn RuntimeSessionPersistence> ⓘ
Access the runtime persistence adapter for non-authoritative saves.
pub fn session_inbox(&self) -> Option<&Arc<dyn SessionInboxPort>>
Sourcepub async fn admit_session_inbox_at_safe_boundary(
&self,
session: &mut Session,
) -> usize
pub async fn admit_session_inbox_at_safe_boundary( &self, session: &mut Session, ) -> usize
Execute the same durable SessionInbox boundary used by the agent loop before its first provider call. Actor workers use this after embedding initial RunSpec deliveries, so those messages cannot race the first reasoning context.
pub fn activation_router(&self) -> Option<&Arc<SessionActivationRouter>>
pub fn session_messenger(&self) -> Option<&Arc<SessionMessenger>>
Sourcepub fn default_tools(&self) -> &Arc<dyn ToolExecutor> ⓘ
pub fn default_tools(&self) -> &Arc<dyn ToolExecutor> ⓘ
Access the runtime’s default tool executor (the root/full tool surface assembled at build time).
Exposed so callers can compose additional one-off dispatches against the
SAME executor the loop itself uses — e.g. re-executing a single
previously-gated tool call after a permission approval — without forking
or reaching into AgentLoopConfig (which stays unconstructible outside
the engine). This is a read-only accessor alongside storage() /
persistence(); it does not touch the sealed loop config.