pub struct AgentHandle { /* private fields */ }Expand description
Request extractor handing handlers a ready-to-run agent.
Autumn resolves it from app state before the handler runs:
use autumn_plugin_agent::plugin::AgentHandle;
use autumn_web::prelude::*;
#[get("/ask")]
async fn ask(agent: AgentHandle) -> String {
agent
.run("Summarize this quarter's plot trends.")
.await
.map(|outcome| format!("{outcome:?}"))
.unwrap_or_else(|err| err.to_string())
}Fails with 503 when the plugin was never installed.
Implementations§
Source§impl AgentHandle
impl AgentHandle
Sourcepub fn agent(&self) -> Agent
pub fn agent(&self) -> Agent
Build an Agent with the plugin’s client, tools, and budgets.
Customize further with the builder methods before calling run.
Sourcepub async fn run(&self, prompt: &str) -> Result<AgentOutcome, AgentError>
pub async fn run(&self, prompt: &str) -> Result<AgentOutcome, AgentError>
Run the agent loop with the plugin’s default settings.
§Errors
Returns AgentError when a provider call fails. Budget exhaustion
is not an error: see Agent::run.
Sourcepub async fn chat(
&self,
session: impl Into<SessionId>,
input: &str,
) -> Result<AgentTurn, AgentError>
pub async fn chat( &self, session: impl Into<SessionId>, input: &str, ) -> Result<AgentTurn, AgentError>
Sourcepub async fn chat_as(
&self,
scope: MemoryScope,
session: impl Into<SessionId>,
input: &str,
) -> Result<AgentTurn, AgentError>
pub async fn chat_as( &self, scope: MemoryScope, session: impl Into<SessionId>, input: &str, ) -> Result<AgentTurn, AgentError>
Like AgentHandle::chat, with memory bound to scope (for
example the signed-in user).
§Errors
Sourcepub async fn resume(
&self,
state: RunState,
decisions: Vec<ApprovalDecision>,
) -> Result<AgentTurn, AgentError>
pub async fn resume( &self, state: RunState, decisions: Vec<ApprovalDecision>, ) -> Result<AgentTurn, AgentError>
Continue a paused run with a reviewer’s decisions, saving the transcript when the run belongs to a session.
§Errors
See Agent::resume.
Sourcepub async fn resume_as(
&self,
scope: MemoryScope,
state: RunState,
decisions: Vec<ApprovalDecision>,
) -> Result<AgentTurn, AgentError>
pub async fn resume_as( &self, scope: MemoryScope, state: RunState, decisions: Vec<ApprovalDecision>, ) -> Result<AgentTurn, AgentError>
Like AgentHandle::resume, with memory bound to scope. Use the
scope the paused run started with (AgentHandle::chat_as).
§Errors
See Agent::resume.
Sourcepub fn runtime(&self) -> &AgentRuntime
pub fn runtime(&self) -> &AgentRuntime
The shared runtime, for stores and settings.
Sourcepub fn tool_names(&self) -> Vec<&str>
pub fn tool_names(&self) -> Vec<&str>
Names of the tools registered on the plugin.
Trait Implementations§
Source§impl Clone for AgentHandle
impl Clone for AgentHandle
Source§impl Debug for AgentHandle
impl Debug for AgentHandle
Source§impl FromRequestParts<AppState> for AgentHandle
impl FromRequestParts<AppState> for AgentHandle
Source§type Rejection = AutumnError
type Rejection = AutumnError
Auto Trait Implementations§
impl !RefUnwindSafe for AgentHandle
impl !UnwindSafe for AgentHandle
impl Forget for AgentHandle
impl Freeze for AgentHandle
impl Send for AgentHandle
impl Sync for AgentHandle
impl Unpin for AgentHandle
impl UnsafeUnpin for AgentHandle
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S, T> FromRequest<S, ViaParts> for T
impl<S, T> FromRequest<S, ViaParts> for T
Source§type Rejection = <T as FromRequestParts<S>>::Rejection
type Rejection = <T as FromRequestParts<S>>::Rejection
Source§fn from_request(
req: Request<Body>,
state: &S,
) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
fn from_request( req: Request<Body>, state: &S, ) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Scoped for T
impl<T> Scoped for T
Source§fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
ScopeQuery for this type. Resolves the
registered scope at .load() time, not here.