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)[源代码]#

Model text, reasoning, and complete tool calls.

参数:
  • attributes (dict[str, Any])

  • persist (bool)

  • include_in_messages (bool)

  • content (str)

  • reasoning (str | None)

  • tool_calls (tuple[ToolCall, ...])

  • provider (str | None)

  • model (str | None)

  • replay_blocks (tuple[Mapping[str, Any], ...])

  • stop (StopInfo | None)

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, ...]

备注

replay_blocks are opaque transport state for the same provider and model. They are not portable reasoning text and should not be displayed as part of content.

示例

A tool-only response may have no answer text:

message = AssistantMessage(
    tool_calls=(ToolCall("call-1", "grep", {"pattern": "TODO"}),),
    provider="anthropic",
    model="claude-example",
)

参见

ModelResponse carries this message with normalized usage, and ToolMessage returns 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 on stop.

Type:

Why the model stopped, set by the runtime when it did not finish normally

raise_for_stop()[源代码]#

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 no stop. The runtime never calls it for you.

抛出:

AgentStopError -- If the step was refused, truncated, paused, interrupted, or ended for a reason this library does not know.

返回类型:

Self