Metadata-Version: 2.4
Name: asap-protocol
Version: 1.0.0
Summary: Async Simple Agent Protocol - A streamlined protocol for agent-to-agent communication
Project-URL: Homepage, https://github.com/adriannoes/asap-protocol
Project-URL: Documentation, https://adriannoes.github.io/asap-protocol
Project-URL: Repository, https://github.com/adriannoes/asap-protocol
Project-URL: Issues, https://github.com/adriannoes/asap-protocol/issues
Project-URL: PyPI, https://pypi.org/project/asap-protocol/
Author: ASAP Protocol Contributors
License: Apache-2.0
License-File: LICENSE
Keywords: a2a,agent,async,communication,mcp,protocol
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Distributed Computing
Classifier: Typing :: Typed
Requires-Python: >=3.13
Requires-Dist: brotli>=1.2.0
Requires-Dist: fastapi>=0.128.0
Requires-Dist: httpx[http2]>=0.28.1
Requires-Dist: jsonschema>=4.23.0
Requires-Dist: opentelemetry-api>=1.20
Requires-Dist: opentelemetry-exporter-otlp-proto-grpc>=1.20
Requires-Dist: opentelemetry-instrumentation-fastapi>=0.41
Requires-Dist: opentelemetry-instrumentation-httpx>=0.41
Requires-Dist: opentelemetry-sdk>=1.20
Requires-Dist: packaging>=25.0
Requires-Dist: pydantic>=2.12.5
Requires-Dist: python-ulid>=3.0
Requires-Dist: slowapi>=0.1.9
Requires-Dist: structlog>=24.1
Requires-Dist: typer>=0.21.1
Requires-Dist: uvicorn>=0.34
Requires-Dist: watchfiles>=0.21.0
Provides-Extra: dev
Requires-Dist: brotli>=1.1.0; extra == 'dev'
Requires-Dist: mypy>=1.19.1; extra == 'dev'
Requires-Dist: pip-audit>=2.7; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
Requires-Dist: pytest-benchmark>=5.1; extra == 'dev'
Requires-Dist: pytest-cov>=6.0; extra == 'dev'
Requires-Dist: pytest-xdist>=3.5.0; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.14.14; extra == 'dev'
Requires-Dist: types-jsonschema>=4.0.0; extra == 'dev'
Provides-Extra: docs
Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
Requires-Dist: mkdocstrings[python]>=0.27; extra == 'docs'
Description-Content-Type: text/markdown

# ASAP: Async Simple Agent Protocol

![ASAP Protocol Banner](https://raw.githubusercontent.com/adriannoes/asap-protocol/main/.github/assets/asap-protocol-banner.png)


> A streamlined, scalable, asynchronous protocol for agent-to-agent communication and task coordination. Built as a simpler, more powerful alternative to A2A with native MCP integration and stateful orchestration.

**Quick Info**: `v1.0.0` | `Apache 2.0` | `Python 3.13+` | [Documentation](https://github.com/adriannoes/asap-protocol/blob/main/docs/index.md) | [PyPI](https://pypi.org/project/asap-protocol/1.0.0/) | [Changelog](https://github.com/adriannoes/asap-protocol/blob/main/CHANGELOG.md)

**Stable** — ASAP Protocol v1.0.0 is production-ready. We welcome feedback and contributions. See our [Contributing](https://github.com/adriannoes/asap-protocol#contributing) section to get involved!

## Why ASAP?

Building multi-agent systems today suffers from three core technical challenges that existing protocols like A2A don't fully address:
1. **$N^2$ Connection Complexity**: Most protocols assume static point-to-point HTTP connections that don't scale.
2. **State Drift**: Lack of native persistence makes it impossible to reliably resume long-running agentic workflows.
3. **Fragmentation**: No unified way to handle task delegation, artifact exchange, and tool execution (MCP) in a single envelope.

**ASAP** provides a production-ready communication layer that simplifies these complexities. It introduces a standardized, stateful orchestration framework that ensures your agents can coordinate reliably across distributed environments. → [Spec](https://github.com/adriannoes/asap-protocol/blob/main/.cursor/product-specs/v0-original-specs.md)

### Key Features

- **Stateful orchestration** — Task state machine with snapshotting for resumable workflows.
- **Schema-first** — Pydantic v2 + JSON Schema for cross-agent interoperability.
- **Async-native** — `asyncio` + `httpx`; sync and async handlers supported.
- **MCP integration** — Tool execution and coordination in a single envelope.
- **Observable** — `trace_id` and `correlation_id` for debugging.
- **Security (v1.0.0)** — Bearer auth, replay prevention, HTTPS, rate limiting (100 req/min). Opt-in.

## Installation

We recommend using [uv](https://github.com/astral-sh/uv) for dependency management:

```bash
uv add asap-protocol
```

Or with pip:

```bash
pip install asap-protocol
```

📦 **Available on [PyPI](https://pypi.org/project/asap-protocol/1.0.0/)**

For reproducible environments, prefer `uv` when possible.

## Requirements

- **Python**: 3.13 or higher
- **Dependencies**: Automatically installed via `uv` or `pip`
- **Optional**: For development, see [Contributing](https://github.com/adriannoes/asap-protocol/blob/main/CONTRIBUTING.md).

## Quick Start

### 1. Create an Agent (Server)

```python
from asap.models.entities import Capability, Endpoint, Manifest, Skill
from asap.transport.handlers import HandlerRegistry, create_echo_handler
from asap.transport.server import create_app

manifest = Manifest(
    id="urn:asap:agent:echo-agent",
    name="Echo Agent",
    version="1.0.0",
    description="Echoes task input as output",
    capabilities=Capability(
        asap_version="0.1",
        skills=[Skill(id="echo", description="Echo back the input")],
        state_persistence=False,
    ),
    # Development: HTTP localhost is allowed
    # Production: Always use HTTPS (e.g., "https://api.example.com/asap")
    endpoints=Endpoint(asap="http://127.0.0.1:8001/asap"),
)

registry = HandlerRegistry()
registry.register("task.request", create_echo_handler())

app = create_app(manifest, registry)
```

### 2. Send a Task (Client)

```python
import asyncio
from asap.models.envelope import Envelope
from asap.models.payloads import TaskRequest
from asap.transport.client import ASAPClient

async def main():
    request = TaskRequest(
        conversation_id="conv_01HX5K3MQVN8",
        skill_id="echo",
        input={"message": "hello from client"},
    )
    envelope = Envelope(
        asap_version="0.1",
        sender="urn:asap:agent:client",
        recipient="urn:asap:agent:echo-agent",
        payload_type="task.request",
        payload=request.model_dump(),
    )
    # Development: HTTP localhost is allowed (with warning)
    # Production: Always use HTTPS (e.g., "https://api.example.com")
    async with ASAPClient("http://127.0.0.1:8001") as client:
        response = await client.send(envelope)
        print(response.payload)

if __name__ == "__main__":
    asyncio.run(main())
```

## Try it

**Run the multi-agent demo** (echo agent + coordinator, one round-trip):

```bash
uv run python -m asap.examples.run_demo
```

**Run any of 14+ examples** (auth, MCP, state migration, etc.):

```bash
uv run python -m asap.examples.<module_name> [options]
```

→ Full list: [Examples README](https://github.com/adriannoes/asap-protocol/blob/main/src/asap/examples/README.md)

| Category | Examples |
|----------|----------|
| **Core** | `run_demo`, `echo_agent`, `coordinator`, `secure_handler` |
| **Orchestration** | `orchestration` (multi-agent, task coordination, state tracking) |
| **State** | `long_running` (checkpoints, resume after crash), `state_migration` (move state between agents) |
| **Resilience** | `error_recovery` (retry, circuit breaker, fallback) |
| **Integration** | `mcp_integration` (MCP tools via envelopes) |
| **Auth & limits** | `auth_patterns` (Bearer, validators, OAuth2 concept), `rate_limiting` (per-sender, per-endpoint) |
| **Concepts** | `websocket_concept` (WebSocket design), `streaming_response` (TaskUpdate streaming), `multi_step_workflow` (pipeline) |

## Testing

```bash
uv run pytest -n auto --tb=short
```

With coverage:

```bash
uv run pytest --cov=src --cov-report=term-missing
```

→ [Testing Guide](https://github.com/adriannoes/asap-protocol/blob/main/docs/testing.md) — structure, fixtures, property/load/chaos tests
→ [Contributing](https://github.com/adriannoes/asap-protocol/blob/main/CONTRIBUTING.md) — dev setup, CI

## Benchmarks

→ [Benchmark Results](https://github.com/adriannoes/asap-protocol/blob/main/benchmarks/RESULTS.md) — Load (1,500+ RPS), stress, memory

## API Overview

Core models: `Envelope`, `TaskRequest`/`TaskResponse`/`TaskUpdate`/`TaskCancel`, `MessageSend`, `ArtifactNotify`, `StateQuery`/`StateRestore`, `McpToolCall`/`McpToolResult`/`McpResourceFetch`/`McpResourceData`. → [API Reference](https://github.com/adriannoes/asap-protocol/blob/main/docs/api-reference.md)

Transport: `create_app`, `HandlerRegistry`, `ASAPClient`. → [Transport](https://github.com/adriannoes/asap-protocol/blob/main/docs/transport.md)

## When to Use ASAP?

ASAP is ideal for:
- **Multi-agent orchestration**: Coordinate tasks across multiple AI agents
- **Stateful workflows**: Long-running tasks that need persistence and resumability
- **MCP integration**: Agents that need to execute tools via Model Context Protocol
- **Production systems**: High-performance, type-safe agent communication

If you're building simple point-to-point agent communication, a basic HTTP API might suffice. ASAP shines when you need orchestration, state management and multi-agent coordination.

## Documentation

**Learn**
- [Docs](https://github.com/adriannoes/asap-protocol/blob/main/docs/index.md) | [API Reference](https://github.com/adriannoes/asap-protocol/blob/main/docs/api-reference.md)
- [Tutorials](https://github.com/adriannoes/asap-protocol/tree/main/docs/tutorials) — First agent → production checklist
- [Migration from A2A/MCP](https://github.com/adriannoes/asap-protocol/blob/main/docs/migration.md)

**Deep dive**
- [State Management](https://github.com/adriannoes/asap-protocol/blob/main/docs/state-management.md) | [Error Handling](https://github.com/adriannoes/asap-protocol/blob/main/docs/error-handling.md)
- [Transport](https://github.com/adriannoes/asap-protocol/blob/main/docs/transport.md) | [Security](https://github.com/adriannoes/asap-protocol/blob/main/docs/security.md)
- [Observability](https://github.com/adriannoes/asap-protocol/blob/main/docs/observability.md) | [Testing](https://github.com/adriannoes/asap-protocol/blob/main/docs/testing.md)

**Decisions & ops**
- [ADRs](https://github.com/adriannoes/asap-protocol/tree/main/docs/adr) — 17 Architecture Decision Records
- [Deployment](https://github.com/adriannoes/asap-protocol/blob/main/docs/deployment/kubernetes.md) | [Troubleshooting](https://github.com/adriannoes/asap-protocol/blob/main/docs/troubleshooting.md)

**Release**
- [Changelog](https://github.com/adriannoes/asap-protocol/blob/main/CHANGELOG.md) | [PyPI](https://pypi.org/project/asap-protocol/1.0.0/)

## CLI

`asap --version` | `asap export-schemas` | `asap list-schemas` | `asap show-schema` — [CLI docs](https://github.com/adriannoes/asap-protocol/blob/main/docs/index.md#cli) or `asap --help`

## Contributing

We love contributions! Whether it's fixing a bug, improving documentation or proposing a new feature.. your help is welcome.

**Community feedback and contributions are essential** for ASAP Protocol's evolution. We're actively working on improvements and your input helps shape the future of the protocol. Every contribution, from bug reports to feature suggestions, documentation improvements and code contributions, makes a real difference.

Check out our [Contributing Guidelines](https://github.com/adriannoes/asap-protocol/blob/main/CONTRIBUTING.md) to get started. It's easier than you think! 🚀

## License

This project is licensed under the Apache 2.0 License - see the [LICENSE](https://github.com/adriannoes/asap-protocol/blob/main/LICENSE) file for details.
