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)[源代码]#
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.
示例
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)
参见
ModelUsagenormalizes provider token counters.- 参数:
message (AssistantMessage)
finish_reason (str | None)
usage (ModelUsage)
stop (StopInfo | None)
- 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;
stopis 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_reasonsays (a refusal category, an error code) supplies it. When it does not, it is derived fromfinish_reasonand the tool calls, so an adapter written before this field existed still reports a refusal or a truncation.