AssistantMessage#
Choose message roles and distinguish model input from stored history. See the guide.
- class zett_agent.messages.AssistantMessage(*, attributes=<factory>, persist=True, include_in_messages=True, content='', reasoning=None, tool_calls=(), provider=None, model=None, replay_blocks=(), stop=None)[source]#
Model text, reasoning, and complete tool calls.
- Parameters:
- content#
Final answer text; may be empty for tool-only responses.
- Type:
str
- reasoning#
Provider-reported reasoning, or None when unavailable.
- Type:
str | None
- tool_calls#
Complete invocations, separate from streamed argument deltas.
- Type:
tuple[zett_agent.messages.ToolCall, …]
Note
replay_blocksare opaque transport state for the same provider and model. They are not portable reasoning text and should not be displayed as part ofcontent.Examples
A tool-only response may have no answer text:
message = AssistantMessage( tool_calls=(ToolCall("call-1", "grep", {"pattern": "TODO"}),), provider="anthropic", model="claude-example", )
See also
ModelResponsecarries this message with normalized usage, andToolMessagereturns tool observations.- provider: str | None#
Provider namespace for opaque replay data; prevents cross-provider reuse.
- model: str | None#
Provider model identifier that produced this response. Together with provider, it prevents signed replay data from crossing model boundaries.
- replay_blocks: tuple[Mapping[str, Any], ...]#
Opaque provider-authenticated reasoning/tool blocks that must be persisted and returned structurally unchanged in the next same-provider tool round trip; adapters may still decode and encode their transport representation. They are transport state, not user-visible reasoning or portable content.
- stop: StopInfo | None#
it was refused, cut off, interrupted, or paused. None on a message that finished or asked for tools, which is every message stored before this field existed, so the check is
message.stop is None or message.stop.ok. The stop of a normal step is onstop.- Type:
Why the model stopped, set by the runtime when it did not finish normally
- raise_for_stop()[source]#
Return this message, or raise if the model did not finish normally.
It is the blocking-script counterpart of
response.raise_for_status(). It does nothing for a message that finished or asked for tools, which have nostop. The runtime never calls it for you.- Raises:
AgentStopError – If the step was refused, truncated, paused, interrupted, or ended for a reason this library does not know.
- Return type:
Self