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=())[source]#
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_startedkeeps the first start andreasoning_completedthe 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.- Parameters:
reasoning_started (ReasoningStartedEvent | None)
reasoning_completed (ReasoningCompletedEvent | None)
content_started (ContentStartedEvent | None)
content_completed (ContentCompletedEvent | None)
_finished (bool)
_reasoning_open (bool)
_server_tools (dict[str, ServerToolCall])
_carried_server_tool_ids (set[str])
_paused_server_tools (tuple[ServerToolCall, ...])
_abandoned_server_tools (tuple[ServerToolCall, ...])
- async observe(context, event)[source]#
Publish extension boundaries and return their ordered UI event types.
- Parameters:
context (PhaseContext)
event (ModelEvent)
- Return type:
tuple[AgentEventType, …]
- take_paused_server_tools()[source]#
Return hosted calls a paused turn left open, and forget them.
- Return type:
tuple[ServerToolCall, …]
- take_abandoned_server_tools()[source]#
Return carried calls a non-paused response left open, and forget them.
- Return type:
tuple[ServerToolCall, …]
- seed_server_tools(calls)[source]#
Record calls a paused step already announced, so a continuation can close them.
- Parameters:
calls (Collection[ServerToolCall])
- Return type:
None
- message_timing(started, completed)[source]#
Build persistable durations from monotonic lifecycle boundaries.
- Parameters:
started (PhaseTransitionEvent)
completed (PhaseTransitionEvent)
- Return type: