ModelOutputTracker#

Distinguish UI streams, extension notifications, and external replies. See the guide.

class zett_agent.events.ModelOutputTracker(reasoning_started=None, reasoning_completed=None, content_started=None, content_completed=None, _finished=False, _reasoning_open=False, _server_tools=<factory>, _carried_server_tool_ids=<factory>, _paused_server_tools=(), _abandoned_server_tools=())[源代码]#

Validate and publish output boundaries for one model call.

Nonempty deltas open a segment once. Content or local tool arguments close reasoning, but a later reasoning delta opens a new one: a service may answer, run a hosted tool, and then think again, and the order is the same one DeepSeek produces through a Messages gateway. Each segment publishes its own started and completed boundary, so a reader can follow the alternation; reasoning_started keeps the first start and reasoning_completed the last end, which is the span thinking covered. Provider-hosted tools remain inside one model generation and do not close reasoning by themselves. The final response closes content and seals the tracker. Completion requires a matching open segment. Failure and cancellation do not synthesize successful completion events. A paused turn is the one exception to the matching-pair rule: it hands control back mid-tool so the next request can resend the open call and continue it.

参数:
async observe(context, event)[源代码]#

Publish extension boundaries and return their ordered UI event types.

参数:
返回类型:

tuple[AgentEventType, ...]

take_paused_server_tools()[源代码]#

Return hosted calls a paused turn left open, and forget them.

返回类型:

tuple[ServerToolCall, ...]

take_abandoned_server_tools()[源代码]#

Return carried calls a non-paused response left open, and forget them.

返回类型:

tuple[ServerToolCall, ...]

seed_server_tools(calls)[源代码]#

Record calls a paused step already announced, so a continuation can close them.

参数:

calls (Collection[ServerToolCall])

返回类型:

None

message_timing(started, completed)[源代码]#

Build persistable durations from monotonic lifecycle boundaries.

参数:
返回类型:

MessageTiming