pub struct Turn {
pub context: TurnContext,
pub input: TurnInput,
pub metrics: TurnMetrics,
}Expand description
Complete state of a single agent turn from input through metrics capture.
Created at the start of process_user_message, populated through the turn lifecycle,
and consumed at the end for metrics emission and trace completion.
Ownership: Turn is stack-owned — created in begin_turn, passed through sub-methods
by &mut Turn, and consumed in end_turn. It is never stored on the Agent struct.
Phase 1 scope: carries context (id, cancel token, timeouts), input, and metrics.
Fields§
§context: TurnContextPer-turn execution context (id, cancel token, timeouts).
input: TurnInputResolved user input for this turn.
metrics: TurnMetricsPer-turn metrics accumulated during the turn lifecycle.
Implementations§
Source§impl Turn
impl Turn
Sourcepub fn new(context: TurnContext, input: TurnInput) -> Self
pub fn new(context: TurnContext, input: TurnInput) -> Self
Create a new turn with the given context and input.
§Examples
let ctx = TurnContext::new(TurnId(0), CancellationToken::new(), TimeoutConfig::default());
let input = TurnInput::new("hello".to_owned(), vec![]);
let turn = Turn::new(ctx, input);
assert_eq!(turn.id(), TurnId(0));Sourcepub fn cancel_token(&self) -> &CancellationToken
pub fn cancel_token(&self) -> &CancellationToken
Return an immutable reference to the per-turn cancellation token.
Sourcepub fn metrics_snapshot(&self) -> &TurnMetrics
pub fn metrics_snapshot(&self) -> &TurnMetrics
Return an immutable reference to the turn metrics.
Sourcepub fn metrics_mut(&mut self) -> &mut TurnMetrics
pub fn metrics_mut(&mut self) -> &mut TurnMetrics
Return a mutable reference to the turn metrics.
Auto Trait Implementations§
impl Freeze for Turn
impl RefUnwindSafe for Turn
impl Send for Turn
impl Sync for Turn
impl Unpin for Turn
impl UnsafeUnpin for Turn
impl UnwindSafe for Turn
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> 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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request