ModelResponse#

Implement the model contract and normalize usage and stream output. See the guide.

class zett_agent.model.ModelResponse(message, finish_reason=None, usage=<factory>, stop=None)[source]#

Final normalized response for one model step.

Exactly one response terminates a successful model stream. Its message must contain complete tool calls even if partial tool-call deltas were emitted.

Examples

Complete a text-only stream:

response = ModelResponse(
    message=AssistantMessage(content="The answer is 42."),
    finish_reason="stop",
    usage=ModelUsage(input_tokens=18, output_tokens=6),
)
yield ModelEvent.completed(response)

See also

ModelUsage normalizes provider token counters.

Parameters:
message: AssistantMessage#

Complete assistant output, including any tool calls and replay blocks.

finish_reason: str | None#

Provider completion reason, or None when unavailable. It is the provider’s own value; stop is the normalized form to branch on.

usage: ModelUsage#

Normalized usage for this model call, not the entire conversation.

stop: StopInfo | None#

Why the step stopped, normalized. An adapter that knows more than the bare finish_reason says (a refusal category, an error code) supplies it. When it does not, it is derived from finish_reason and the tool calls, so an adapter written before this field existed still reports a refusal or a truncation.