pub struct RequestContext {
pub message: Message,
pub task_id: TaskId,
pub context_id: String,
pub stored_task: Option<Task>,
pub metadata: Option<Value>,
pub cancellation_token: CancellationToken,
}Expand description
Context for a single agent execution request.
Built by the RequestHandler and passed to
AgentExecutor::execute.
The cancellation_token allows executors to
observe cancellation requests and abort work cooperatively.
Fields§
§message: MessageThe incoming user message.
task_id: TaskIdThe task identifier for this execution.
context_id: StringThe conversation context identifier.
stored_task: Option<Task>The previously stored task snapshot, if this is a continuation.
metadata: Option<Value>Arbitrary metadata from the request.
cancellation_token: CancellationTokenCancellation token for cooperative task cancellation.
Executors should check CancellationToken::is_cancelled or
.cancelled().await to stop work when the task is cancelled.
Implementations§
Source§impl RequestContext
impl RequestContext
Sourcepub fn new(message: Message, task_id: TaskId, context_id: String) -> Self
pub fn new(message: Message, task_id: TaskId, context_id: String) -> Self
Creates a new RequestContext.
Sourcepub fn with_stored_task(self, task: Task) -> Self
pub fn with_stored_task(self, task: Task) -> Self
Sets the stored task snapshot for continuation requests.
Sourcepub fn with_metadata(self, metadata: Value) -> Self
pub fn with_metadata(self, metadata: Value) -> Self
Sets request metadata.
Trait Implementations§
Source§impl Clone for RequestContext
impl Clone for RequestContext
Source§fn clone(&self) -> RequestContext
fn clone(&self) -> RequestContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for RequestContext
impl RefUnwindSafe for RequestContext
impl Send for RequestContext
impl Sync for RequestContext
impl Unpin for RequestContext
impl UnsafeUnpin for RequestContext
impl UnwindSafe for RequestContext
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
Mutably borrows from an owned value. Read more