pub struct ModelTurn {
pub message_id: Option<String>,
pub response_id: Option<String>,
pub provider_request_id: Option<String>,
pub choice: Vec<AssistantContent>,
pub usage: Usage,
pub executable_tool_names: BTreeSet<String>,
pub allowed_tool_names: BTreeSet<String>,
pub finish_reason: Option<FinishReason>,
pub raw: Value,
}Expand description
A completed model turn fed back to AgentRun::model_response.
Fields§
§message_id: Option<String>Provider-assigned assistant message ID, when available.
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.
executable_tool_names: BTreeSet<String>Executable Rig tools advertised to the provider for this turn.
allowed_tool_names: BTreeSet<String>Tools allowed by the active ToolChoice for this turn.
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 tool sets and the
response’s normalized finish reason. prepared must describe this call.
Sourcepub fn from_response_parts(
resp: &CompletionResponse,
executable_tool_names: BTreeSet<String>,
allowed_tool_names: BTreeSet<String>,
) -> Self
pub fn from_response_parts( resp: &CompletionResponse, executable_tool_names: BTreeSet<String>, allowed_tool_names: BTreeSet<String>, ) -> Self
from_response for a driver that carries the
per-turn tool-name sets by value instead of the whole prepared
request. The sets must originate from the prepared request of the same
attempt.
Sourcepub fn new(
message_id: Option<String>,
choice: Vec<AssistantContent>,
usage: Usage,
executable_tool_names: BTreeSet<String>,
allowed_tool_names: BTreeSet<String>,
raw: Value,
) -> Self
pub fn new( message_id: Option<String>, choice: Vec<AssistantContent>, usage: Usage, executable_tool_names: BTreeSet<String>, allowed_tool_names: BTreeSet<String>, raw: Value, ) -> Self
Create a model turn from response parts, the tool names advertised
for the turn, 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.