pub enum ModelChunk {
TextDelta {
msg_id: String,
delta: String,
},
ThinkingDelta {
thinking_id: String,
delta: String,
signature: Option<String>,
},
ToolCallStart {
id: String,
name: String,
},
ToolCallInputDelta {
id: String,
delta: String,
},
ToolCallEnd {
id: String,
input: Option<Value>,
},
Done {
stop_reason: String,
usage: Option<HarnessUsage>,
},
}Expand description
One token-level event from the model. The harness loop consumes a
Stream<ModelChunk> and forwards TextDelta straight through as
HarnessInternalEvent::AssistantTextChunk so callers see live
generation; tool-call chunks are accumulated internally and only
emitted once ToolCallEnd lands so the harness can dispatch the call
with a complete serde_json::Value input.
Provider-agnostic: OpenAiCompatibleModelClient translates from
OpenAI’s chat-completions SSE shape, and the future Anthropic client
will project Messages-API events into the same enum. ScriptedModelClient
synthesizes whichever sequence its scripted ModelResponse would
have implied.
Variants§
TextDelta
ThinkingDelta
Fields
ToolCallStart
First chunk of a tool call. The harness records (id, name) and
starts buffering ToolCallInputDeltas under this id.
ToolCallInputDelta
Streaming JSON arguments for a previously-announced tool call.
OpenAI emits these as a string that, when concatenated, is valid
JSON. Harness accumulates these into a single string per id, then
parses on ToolCallEnd.
ToolCallEnd
Tool call finalised. input is the parsed JSON value if the
provider sent the full object on this chunk (Anthropic), or a
placeholder if the harness still needs to parse the accumulated
ToolCallInputDelta buffer (OpenAI). Either way the harness
treats input as authoritative when present.
Done
Final chunk. usage carries the provider’s reported token count
for this call (None if the gateway elides it).
Trait Implementations§
Source§impl Clone for ModelChunk
impl Clone for ModelChunk
Source§fn clone(&self) -> ModelChunk
fn clone(&self) -> ModelChunk
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ModelChunk
impl Debug for ModelChunk
Source§impl PartialEq for ModelChunk
impl PartialEq for ModelChunk
Source§fn eq(&self, other: &ModelChunk) -> bool
fn eq(&self, other: &ModelChunk) -> bool
self and other values to be equal, and is used by ==.