pub struct ModelTurn {
pub head: AssistantMessage,
pub response_id: Option<String>,
pub provider_request_id: Option<String>,
pub choice: Vec<AssistantContent>,
pub usage: Usage,
pub policy: TurnPolicy,
pub finish_reason: Option<FinishReason>,
pub raw: Value,
}Expand description
A completed model turn fed back to AgentRun::model_response.
Fields§
§head: AssistantMessageThe turn’s origin, stop and provider message, without content.
response_id: Option<String>Provider-assigned response-scoped ID, when available.
provider_request_id: Option<String>The provider’s transport request id for this attempt, when reported.
choice: Vec<AssistantContent>The assistant content returned by the model.
usage: UsageToken usage reported by the provider for this completion request.
policy: TurnPolicyThe tool policy this attempt was prepared with.
finish_reason: Option<FinishReason>Provider-reported terminal reason for this attempt, when available.
raw: ValueThis attempt’s decoded provider response, recorded on its CompletionCall.
Implementations§
Source§impl ModelTurn
impl ModelTurn
Sourcepub fn from_response(
resp: &CompletionResponse,
prepared: &PreparedRequest,
) -> Self
pub fn from_response( resp: &CompletionResponse, prepared: &PreparedRequest, ) -> Self
Convert a response using the same attempt’s prepared policy and the
response’s normalized finish reason. prepared must describe this call.
Sourcepub fn from_policy(resp: &CompletionResponse, policy: TurnPolicy) -> Self
pub fn from_policy(resp: &CompletionResponse, policy: TurnPolicy) -> Self
from_response for a driver that carries the
turn’s TurnPolicy by value instead of the whole prepared request.
policy must be the PreparedRequest::policy
of this attempt: it alone carries the turn’s tool choice to the Skip
gate and the invalid-call context.
Sourcepub fn new(
head: AssistantMessage,
choice: Vec<AssistantContent>,
usage: Usage,
policy: TurnPolicy,
raw: Value,
) -> Self
pub fn new( head: AssistantMessage, choice: Vec<AssistantContent>, usage: Usage, policy: TurnPolicy, raw: Value, ) -> Self
Create a model turn from response parts, the policy the turn was
prepared with, and the provider’s own response raw (see
Self::raw).
Sourcepub fn with_identity(
self,
response_id: Option<String>,
provider_request_id: Option<String>,
) -> Self
pub fn with_identity( self, response_id: Option<String>, provider_request_id: Option<String>, ) -> Self
Attach the remaining response identity metadata this attempt reported.
Sourcepub fn with_finish_reason(self, finish_reason: Option<FinishReason>) -> Self
pub fn with_finish_reason(self, finish_reason: Option<FinishReason>) -> Self
Attach the terminal finish reason this attempt reported.