Skip to main content

Agent Stream Protocol

a13n-stream-protocol observes public a13n-harness streams as typed AG-UI events. It maps text, reasoning, tool, and terminal observations to standard AG-UI events, exposes every other public observation through a namespaced CUSTOM fallback, applies an optional Host processor, and accumulates the resulting events for process-local use.

The repository directory is packages/a13n-stream-protocol, the Python distribution is a13n-stream-protocol, and the import package is a13n_stream_protocol.

Usage

from a13n_stream_protocol import HarnessAguiObserver

observers: dict[tuple[str, str], HarnessAguiObserver] = {}

async with executable.stream(input, bindings=bindings) as stream:
    async for item in stream:
        correlation = (item.thread_id, item.run_id)
        observer = observers.get(correlation)
        if observer is None:
            observer = HarnessAguiObserver()
            observers[correlation] = observer

        new_events = observer.observe(item)
        await host.persist_and_publish(new_events)

One observer binds to the Thread and Run correlation on its first successful source item. Use a separate observer for each root or child Run, including child events forwarded through a parent stream. An integration whose source contains exactly one Run can use one observer directly.

A Host that retains the exact public Harness source history can atomically rebuild a fresh observer before continuing with live items:

observer = HarnessAguiObserver()
await observer.resume(host.source_history(run_id=run_id, through=cursor))

async for item in host.live_source(run_id=run_id, after=cursor):
    new_events = observer.observe(item)
    await host.persist_and_publish(new_events)

The history is a finite async iterable for one Run. resume() accumulates its post-processor AG-UI events without returning them for duplicate publication, leaves the observer fresh if reconstruction fails, and knows nothing about storage, cursors, gaps, or replay-to-live cutover. Those remain Host responsibilities.

A Host can filter or adjust converted values before accumulation:

from ag_ui.core import Event
from ag_ui.core.events import CustomEvent
from a13n_harness import HarnessStreamEvent
from a13n_stream_protocol import HarnessAguiObserver


def process_event(
    source: HarnessStreamEvent[object],
    event: Event,
) -> Event | None:
    del source
    if isinstance(event, CustomEvent) and event.name == "a13n.harness.diagnostic":
        return None
    return event


observer = HarnessAguiObserver(processor=process_event)

A replacement must retain the same AG-UI event type and source-derived correlation. The processor is synchronous, replay-stable, and does not retain mutable processing state or persist, publish, or acknowledge events. The Host acts on the complete batch returned by live observe() calls.

Ownership

The package owns only:

  • standard Harness-to-AG-UI conversion;
  • generic CUSTOM fallback for unmapped public events;
  • multipart text, reasoning, and tool-call observation state;
  • optional replay-stable Host processing;
  • atomic process-local reconstruction from supplied source history;
  • detached incremental results and accumulated snapshots.

The Host owns source-history retention and selection, cursors, gaps, replay-to-live cutover, persistence, event identities, fan-out, backpressure, cancellation, transport, and rendering policy. The Harness owns source lifecycle facts and continuation state.

Dependencies

The source manifest declares an unversioned dependency on a13n-harness, so uv resolves Harness from the workspace during repository development. Conversion uses the upstream ag-ui-protocol models, Pydantic serialization, and the lightweight pydantic-ai-slim event runtime. The package does not depend on Harness UI, a Host persistence model, or a transport framework.

Release automation replaces the workspace-oriented Harness dependency in publishable metadata with an exact same-version requirement. Both the sdist and wheel therefore install only the Harness version released with that Stream Protocol artifact.

Versioning

Agent Stream Protocol, a13n-harness, and a13n-environment form the Harness release group. A release/a13n-harness-v<version> tag publishes all three distributions at exactly the same version, where <version> is stable X.Y.Z or RC X.Y.Z-rc.N. Python package metadata represents the RC as X.Y.ZrcN. Published Harness metadata pins the exact Provider version, and this package pins the exact Harness version. Harness UI is versioned and released independently.

The accepted architecture and observation contract are defined in the Agent Stream Protocol specification.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

a13n_stream_protocol-0.0.12.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

a13n_stream_protocol-0.0.12-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file a13n_stream_protocol-0.0.12.tar.gz.

File metadata

  • Download URL: a13n_stream_protocol-0.0.12.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for a13n_stream_protocol-0.0.12.tar.gz
Algorithm Hash digest
SHA256 c6025f4e7f8d1238160dfd55cd184343efc7009bd6d54d7e3e480dff87dfc36f
MD5 fd8d4ad0f905fb7eb3ef01f329d3cf17
BLAKE2b-256 8aa517f72906c090c7e3964e7f1ad2329dc4bbe39b336f6a2cff53c766a77c71

See more details on using hashes here.

File details

Details for the file a13n_stream_protocol-0.0.12-py3-none-any.whl.

File metadata

  • Download URL: a13n_stream_protocol-0.0.12-py3-none-any.whl
  • Upload date:
  • Size: 17.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for a13n_stream_protocol-0.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 6ff9775fdc26ec0c4dd4cb708b4203d164a08acba8ef9588f2a5c04dd2ab4d64
MD5 6e9369fed6c5e19ab29e37ddd6418002
BLAKE2b-256 c951f57cc937467945a4a24e715ff665683cce6ee067d7a4e013eedd3984f2af

See more details on using hashes here.

Release history Release notifications | RSS feed

0.0.17

2 files

0.0.16

2 files

0.0.15

2 files

0.0.14

2 files

0.0.13

2 files

This release

0.0.12 This release

2 files

0.0.10

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page