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>Why the model stopped generating on this turn, when the provider reported it. Carried so the blocking surface records the same terminal reason the streamed surface does (rig#2322).
raw: ValueThe provider’s own response for this attempt — see
CompletionResponse::raw. Carried so the blocking
surface records the same payload on its CompletionCall that the
streamed surface records via
AgentRun::record_streamed_completion_call. default because
persisted run state predates the field; Value::Null for a turn built
without a provider response behind it.
Implementations§
Source§impl ModelTurn
impl ModelTurn
Sourcepub fn new(
message_id: Option<String>,
choice: Vec<AssistantContent>,
usage: Usage,
executable_tool_names: BTreeSet<String>,
allowed_tool_names: BTreeSet<String>,
) -> Self
pub fn new( message_id: Option<String>, choice: Vec<AssistantContent>, usage: Usage, executable_tool_names: BTreeSet<String>, allowed_tool_names: BTreeSet<String>, ) -> Self
Create a model turn from response parts and the tool names advertised for the turn.
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.