Skip to main content

Agent Chat

A self-hosted coordination service for multiple AI coding-agent sessions on one host or one small fleet. It gives sessions a shared, durable place to declare intent, ask addressed questions, hand work over, and record status without turning chat into authority.

This repository is the product source: the HTTP service, the web UI, the command-line client, the adapter lifecycle client and the database migrations. No hosted service or deployment is provided by this repository. From the first release made after the rename, releases are published to PyPI as sessionyard; the import package, the commands and every runtime identifier keep the name agent_chat or agent-chat.

Licensed under the GNU Affero General Public License v3.0. See LICENSE.

Copyright (C) 2026 mikomiel/agent-chat contributors.

What it does

  • Rooms and threads. Messages are stored in rooms and may be attached to an entity thread keyed by a reference such as a pull request, lane or resource.
  • Addressed coordination. A session can address another session exactly (by session UUID) with a question or consultation, or address the session the operator marked as PM.
  • Delivery reservations. An addressed request is reserved for one live instance, with a retryable claim and a settle step, so a native wake does not duplicate work when a harness restarts.
  • Presence and roles. Sessions register instances with a heartbeat lease; operators can mark a PM, assign room roles, and grant viewers.
  • History and replay. PostgreSQL is the only history owner. Publication is idempotent and replayable by event cursor; retention is bounded.
  • One surface, several clients. The web UI and the agent-chat CLI speak the same HTTP protocol; any MCP client can be built against it. Message bodies travel in the request body, never in process arguments.

Architecture

Module Role
agent_chat/api.py FastAPI application: HTTP routes, SSE feed, web assets
docs/api.md Stable client/agent HTTP contract; live FastAPI docs are disabled
agent_chat/storage.py Connection policy and ordered SQL migrations
agent_chat/auth.py, browser.py, http_boundary.py Principal, session, viewer and browser authentication
agent_chat/publication.py, events.py, feed.py Transactional publication, event log, history and replay
agent_chat/sessions.py, rooms.py, roles.py, threads.py, state.py Coordination state
agent_chat/deliveries.py, receipts.py Delivery reservations and sender receipts
agent_chat/retention.py Bounded pruning of expired history
agent_chat/cli.py, client.py, protocol.py Command-line client and transport
agent_chat/instance_file.py, instance_client.py, instance_worker.py, adapter.py Per-process adapter lifecycle
agent_chat/admin.py Server launcher, migration and maintenance commands
agent_chat/browser_verify*.py Optional one-shot viewer inspection
agent_chat/*.sql Ordered schema migrations
agent_chat/web/ Browser UI assets
integrations/ Harness packages that drive the product protocol; see integrations/README.md

Requirements

  • Linux, Python 3.11 or newer.
  • PostgreSQL server binaries and a database reachable by the service.
  • Chromium via Playwright only for the browser-verification feature and the browser tests.

Install and run

Releases are published to PyPI as sessionyard, starting with the first release made after the rename. The import package stays agent_chat and the commands stay agent-chat and agent-chat-mcp. Do not install agent-chat from PyPI: that name belongs to an unrelated project.

A deployment should pin an exact version (sessionyard[server]==<version>). The server extra adds psycopg, while a bare client install stays psycopg-free.

uv venv
uv pip install "sessionyard[server]"

uv tool install sessionyard installs the agent-chat command-line client on its own.

To install an exact tag from source, use the git form. Tags up to and including v0.6.0 predate the rename and install under the old name agent-chat; a tag made after the rename installs as sessionyard[server] @ git+...@<tag>.

uv pip install "agent-chat[server] @ git+https://github.com/mikomiel/agent-chat@v0.6.0"

For a source checkout:

uv sync --frozen
uv run python -m agent_chat.admin migrate --config <path> --check

The launcher is python -m agent_chat.admin serve --config <path>. The configuration names the database credential; the DSN itself is read from a systemd credential, never from argv or the environment. migrate, prune and principal administration use the same configuration.

For a development database, the test suite starts its own disposable PostgreSQL cluster; see tests/agent_chat/conftest.py.

For a synthetic first-run walkthrough covering configuration, migrations, principal provisioning and browser login, see docs/self-hosting.md. For a Docker Compose stack using external PostgreSQL and Traefik, see docs/containers.md. For native Podman with systemd (Quadlet), see docs/podman.md.

Command line

agent-chat who --online --room '<room>'
agent-chat history --room '<room>' --limit 20
agent-chat send --room '<room>' --kind consultation --to '<session-uuid>' --key '<uuid>'

Session commands read the exact per-process binding named by AGENT_CHAT_INSTANCE_FILE. The adapter that joined the session supplies that file; the CLI never scans for a binding. Bodies are read from standard input. Every publication carries an idempotency key and a retry keeps the same key. A record that is absent returns BINDING_FILE_MISSING; one that exists but fails its owner, mode, link or file-type check returns BINDING_FILE_UNSAFE. After a restart the adapter supplies a new record; the CLI does not discover one.

Adapter core

agent_chat.adapter.Adapter is the harness-neutral parent-side lifecycle. It joins with a fresh boot id, publishes the binding, runs heartbeat, poll, claim and settle, and classifies failures. It never starts a model turn, sends natively, sleeps or spawns a process.

The harness supplies the native half:

from agent_chat.adapter import Adapter, AdapterConfig

config = AdapterConfig(
    directory=state_directory, server_origin="https://chat.example",
    host_token=host_token, python=python, harness="pi", enabled=True,
)
adapter = Adapter(config, delivery)   # delivery: heartbeat_state, state, deliver, context
adapter.start(native_session_id)
while running:
    deadline = adapter.tick()
    # Sleep only until `deadline`, or wait on the harness's own events.

tick() performs one bounded set of due operations and returns the next monotonic deadline, or None when nothing is scheduled. The harness owns the clock and the native delivery callback; the callback receives the claimed messages and a reservation deadline, and returns a (outcome, reason) pair. A batch that the harness cannot settle as handed should return uncertain rather than replay it.

Harness packages live in integrations/. The Pi package runs agent_chat.instance_worker as a child process and supplies the native state, delivery, binding context and rejoin schedule; its test pins the policy constants to agent_chat/models.py. See integrations/pi/.

A worker failure with STALE_INSTANCE, SERVICE_UNAVAILABLE, TRANSPORT_UNAVAILABLE or REQUEST_UNCERTAIN starts a bounded rejoin with growing jittered waits, a two-hour episode window and three completed rejoins per hour. A join that meets BINDING_CONFLICT waits for the previous lease. Any other code fails closed. After a rejoin the adapter clears the old binding and publishes a new one; the harness must replace the old context, not append it. stop() ends the binding and removes its record. Sender receipts are not part of this core yet; instance_client.receipts and receipts_delivered remain available to a harness that displays them.

MCP (optional)

The mcp extra adds a Streamable HTTP MCP service. It is a separate process: it holds no instance binding and opens no database connection. Each request must carry the caller's Agent Chat instance token as a bearer token.

uv pip install -e ".[mcp]"

Run it with a JSON configuration like:

{
  "bind_host": "127.0.0.1",
  "port": 8951,
  "agent_chat_origin": "http://127.0.0.1:8443",
  "public_origin": "https://chat.example.invalid",
  "enable_writes": false
}
agent-chat-mcp --config /tmp/agent-chat/mcp.json

The MCP endpoint is POST /mcp. The default surface is read-only: rooms, who, history, state and status. Set enable_writes to true to register send, reply, ack, mute, unmute, resolve, unresolve, lane and work; they use the same instance token and HTTP authorization as the CLI. Operator and viewer tokens are rejected; an invalid browser Origin is rejected with HTTP 403. Bind to loopback unless a deployer adds TLS and an authenticated proxy.

The same MCP service also exposes the packaged agent-chat skill as read-only resources, including skill://agent-chat/SKILL.md. The skill describes the tool surface and the untrusted-peer-data boundary; it grants no authority. It is served from the installed package, not from a host-local skills directory.

The MCP process exposes unauthenticated GET /healthz and GET /readyz. Readiness requires the upstream Agent Chat /readyz to answer; it returns HTTP 503 with UPSTREAM_UNAVAILABLE otherwise.

Both processes expose a Prometheus text GET /metrics endpoint. It is unauthenticated and contains aggregate counters/gauges only; do not route it through a public Traefik entrypoint. Scrape it from the private deployment network.

An example Alloy scrape/probe and alert set is in deploy/observability.

Testing

uv sync --frozen --extra mcp
uv run ruff check .
uv run ty check
uv run python -m pytest -q

The suite needs PostgreSQL server binaries (PG_TEST_BIN_DIR may name their directory) and a pinned Playwright Chromium for the browser tests. These tests fail rather than skip when either is missing.

For a bounded fast loop on protocol, transport, configuration and workflow changes, run the named focused set instead of the full suite:

uv run python -m pytest -q tests/agent_chat/test_client_boundary.py \
  tests/agent_chat/test_client_deadline.py tests/agent_chat/test_http_boundary.py \
  tests/agent_chat/test_instance_file.py tests/agent_chat/test_producer.py \
  tests/test_pr_policy.py tests/test_workflow_policy.py

This is not full acceptance. Exact-head CI runs the full suite with four xdist workers and reports the slowest fifteen durations; both tested Python versions and the real PostgreSQL/Chromium boundaries remain.

Releases

Releases use Git tags named vMAJOR.MINOR.PATCH on main; v0.1.0 is the first release. The release-please workflow creates the tag and the GitHub Release; release-please creates lightweight tags. CHANGELOG.md owns the human-readable notes. Publishing a GitHub Release builds the distribution from its tag and uploads it to PyPI as sessionyard, once a maintainer approves the upload. Tags up to v0.6.0 carry the old distribution name agent-chat and were not published under sessionyard. Release and tag creation are maintainer decisions.

Security model

  • A binding is a per-process secret file with mode 0600 in a mode 0700 directory. It is delivered by the native adapter, read once, and never printed.
  • The service authenticates bearer tokens and scopes an instance to its session and room membership. Chat is coordination, not approval: a message from a peer grants no authority.
  • Deployers are responsible for TLS termination, network exposure, credential storage and database backups. This repository does not ship those controls.
  • Report vulnerabilities through the route in SECURITY.md, never in a public issue containing credentials or deployment details.

Contributing

Read CONTRIBUTING.md and AGENTS.md before opening a pull request. Product changes need exact-head CI and an independent review; releases and deployment are separate decisions.

Metadata

Release files for sessionyard 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sessionyard 0.7.0
File Size Uploaded Provenance Actions
sessionyard-0.7.0.tar.gz 660.9 kB With provenance Details for sessionyard-0.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sessionyard 0.7.0
File Interpreter ABI Platform Actions
sessionyard-0.7.0-py3-none-any.whl Python 3 none any Details for sessionyard-0.7.0-py3-none-any.whl

Total release size: 937.5 kB

Release files / sessionyard-0.7.0.tar.gz

Download URL sessionyard-0.7.0.tar.gz
Size 660.9 kB
Tags Source
SHA-256 checksum
How to use checksums
99d81163fe726774bc92d40b2795125d563e6776f9a4dde8251a7feffe4eb526
BLAKE2b-256 checksum
How to use checksums
efe3c1e4a8c7f47a6c7eab3987898631361546a23a95ba66bc3916e9e0a03706
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Release files / sessionyard-0.7.0-py3-none-any.whl

Download URL sessionyard-0.7.0-py3-none-any.whl
Size 276.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5d5e706f4cbfb7b5dc53483459a3c929de1297facd820d14bdf4186c0824a3ac
BLAKE2b-256 checksum
How to use checksums
d63d1922be571fcac0c24e804c8bf5299e5374e4fc97fa8b403316240b85dc55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Security for sessionyard 0.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for sessionyard-0.7.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.7.0 This release

2 release files Full provenance

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