Skip to main content

agentsparty

Protocol-first orchestration for AI agents.
Declarative multiparty session types for AI agents

What it is

You describe one typed global choreography between named roles. agentsparty projects it onto every role, rejects alts a role cannot observe, and runs the session. A language model fills a typed payload or picks a declared branch — it does not route the workflow, invent roles, or call arbitrary code. The protocol owns control; the model owns content.

What it catches

A role that must behave differently on two branches of a alt it never saw fails before any model call:

>>> from agentsparty.kernel.errors import ProjectionError
>>> from agentsparty import Nothing, Text
>>> from agentsparty.protocol import alt, msg, project
>>> from agentsparty.kernel.role import roles
>>> A, B, C = roles("A", "B", "C")
>>> broken = alt[A, B] (
...     Nothing("Yes") >> msg[A, C] ("Y", Text),
...     Nothing("No") >> msg[C, A] ("N", Text),
... ).close()
>>> try:
...     project(broken, C)
... except ProjectionError as err:
...     print("role" in str(err).lower() and "Yes" in str(err))
True

Install

pip install agentsparty
pip install "agentsparty[openai]"   # optional OpenAI Responses backend

Quickstart

Minimal agent session with the OpenAI gpt-5.6-luna model:

import asyncio

from openai import AsyncOpenAI

from agentsparty.agent import Agent
from agentsparty.human import Human, ScriptedHumanIo
from agentsparty import OpenAIModel
from agentsparty import Text
from agentsparty.protocol import msg, render
from agentsparty.kernel.role import roles
from agentsparty.runtime import AgentRuntime

A, B = roles('Writer', 'Reader')
proto = msg[A, B]('Note', Text).close()
print(render(proto))
model = OpenAIModel('gpt-5.6-luna', AsyncOpenAI(max_retries=0, timeout=30.0))
writer = Agent(model, A, 'send a short note', proto)
reader = Human(B, proto, ScriptedHumanIo([]))


async def main() -> None:
    trace = await AgentRuntime(proto, [writer, reader]).run()
    print(trace[0].payload)


asyncio.run(main())

Examples — live in 10 seconds

export OPENAI_API_KEY=...
pip install 'agentsparty[openai]'
uv run python examples/online/hello.py

Sample output:

=== protocol ===
Writer -> Reviewer : Note(str)
Reviewer -> Writer : Ack(str)
end
=== conversation ===
Writer:Note -> Reviewer 'Ship the typed choreography first.'
Reviewer:Ack -> Writer 'Received.'

Catch a projection error without a key: uv run python examples/offline/projection_error.py. Full ladder: examples/README.md.

When to use — and when not to

Use when

  • the allowed interaction shape is known up front
  • every role must only act on messages it actually receives
  • you need projection to fail closed before the first model call
  • tools are roles with a protocol surface, not free function-calling
  • sessions must resume from recorded decisions without re-asking

Do not use when

  • one agent with a free tool set is enough (use a simpler agent SDK)
  • the route must be discovered at runtime by the model
  • you need a large catalogue of vendor integrations out of the box
  • you require a stable API before 1.0 (this project is research / 0.x)
  • you need multi-process or multi-machine transport (runtime is in-process)

Links

Status

Research framework at 0.1.x. What agentsparty proves, checks at run time, and deliberately leaves to the application — including the non-guarantees (no deadlock-freedom, no liveness, no exactly-once) — is the guarantee table. Public surface is the union of tier-1/2 __all__ exports; see tests/public_api.txt. Exception types are stable; message text and journal formats are not.

Security

Untrusted payloads and web content are data, not instructions. User-written tools run with the host process privileges — sandbox them and validate paths or commands before any effect. Give AsyncOpenAI a finite transport timeout (the model wrapper does not add one). Deadline, Allowance, and Metered bound branch windows, protocol steps, and token spend. Journals and tracers persist payloads and model output in plaintext.

Private reports: SECURITY.md. Guidance: security.

Development

uv sync --all-groups
just all    # or: uv run nox -t ci

Agent conventions for contributors live in AGENTS.md.

License

MIT — see LICENSE.

Download files

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

Source Distribution

agentsparty-0.1.1.tar.gz (110.2 kB view details)

Uploaded Source

Built Distribution

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

agentsparty-0.1.1-py3-none-any.whl (142.1 kB view details)

Uploaded Python 3

File details

Details for the file agentsparty-0.1.1.tar.gz.

File metadata

  • Download URL: agentsparty-0.1.1.tar.gz
  • Upload date:
  • Size: 110.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"NixOS","version":"25.11","id":"xantusia","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for agentsparty-0.1.1.tar.gz
Algorithm Hash digest
SHA256 16a80d4c5613940ee55b7c6c592e9b05dc9f8cd9ba09f3d2c7ee2d119a00b441
MD5 0f4b9937dfcc93597c0a2222237ebce3
BLAKE2b-256 c4a1a76f8b5651043155ce574d21d9a16178f9d4ffdcdda42c130ee9c60e3a03

See more details on using hashes here.

File details

Details for the file agentsparty-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: agentsparty-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 142.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"NixOS","version":"25.11","id":"xantusia","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for agentsparty-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 45c60762a3ffe313d2a4442d6ef9022c73303fc2018e659b9037a34f86f624ca
MD5 d451da8d22d25a4211824a96202268c9
BLAKE2b-256 0b07684c7a669c053388dd5656952e3878d9e50cf3b6598a3c60ab46ecd639b4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page