Skip to content

latent.wire.testing.contracts

Canonical wire-contract scenario, normalization, and golden loader.

The contract is a single representative run (:func:canonical_events) covering the spread that matters across the wire: reasoning + text, labelled step boundaries, a tool call and its result, and a data-latent-only event (Usage). :func:normalize_wire strips the per-run-random bits (nanoid block/message ids, ISO timestamps) so the golden is byte-stable; :func:load_contract returns the stored golden for a protocol.

Functions

canonical_events

canonical_events() -> list[AgentEvent]

The fixed run every wire contract is pinned against.

load_contract

load_contract(protocol: str = 'ai-sdk') -> str

Return the normalized golden SSE a protocol emits for canonical_events.

Raises FileNotFoundError if the protocol has no recorded contract.

normalize_wire

normalize_wire(sse: str) -> str

Replace per-run-random ids/timestamps with stable placeholders.

Attributes

AG_UI_PROTOCOL_RANGE

AI_SDK_PROTOCOL_VERSION