Skip to main content

ACP adapter for pydantic-ai agents.

Project description

pydantic-acp

pydantic-acp adapts pydantic_ai.Agent instances to the ACP agent interface.

Public Entry Points

  • run_acp(...)
  • create_acp_agent(...)
  • AdapterConfig
  • AcpSessionContext
  • AgentSource, AgentFactory, StaticAgentSource, FactoryAgentSource
  • AgentBridgeBuilder
  • provider protocols
  • capability bridges
  • hook projection and existing-hook introspection
  • host backends

Implemented Scope

  • Milestone 1-7 scope is implemented
  • the adapter includes session lifecycle, session-local model control, providers, approvals, bridges, projection maps, and host backends
  • slash commands are available for /model, /tools, /hooks, and /mcp-servers

Quick Start

from pydantic_acp import run_acp
from pydantic_ai import Agent

agent = Agent("test", name="demo-agent")
run_acp(agent=agent)

Factory-backed usage:

from pydantic_acp import AcpSessionContext, create_acp_agent
from pydantic_ai import Agent

def build_agent(session: AcpSessionContext) -> Agent[None, str]:
    return Agent("test", name=f"demo-{session.cwd.name}")

acp_agent = create_acp_agent(agent_factory=build_agent)

File-backed session persistence:

from pathlib import Path

from pydantic_acp import AdapterConfig, FileSessionStore, run_acp

run_acp(
    agent=agent,
    config=AdapterConfig(
        session_store=FileSessionStore(base_dir=Path(".acp-sessions")),
    ),
)

Projection map example:

from pydantic_acp import FileSystemProjectionMap, run_acp

run_acp(
    agent=agent,
    projection_maps=(
        FileSystemProjectionMap(
            default_read_tool="read_file",
            default_write_tool="write_file",
            default_bash_tool="execute",
        ),
    ),
)

Hook projection example:

from pydantic_acp import AdapterConfig, HookProjectionMap, run_acp

run_acp(
    agent=agent,
    config=AdapterConfig(
        hook_projection_map=HookProjectionMap(
            hidden_event_ids=frozenset({"after_model_request"}),
        )
    ),
)

Major Features

  • ACP session lifecycle support
  • transcript and model-message history replay
  • generic tool projection with ACP tool updates
  • projection maps for filesystem diffs and bash command previews
  • session-local models, modes, config options, and plan updates
  • deferred approval bridging
  • provider seams for host-owned state
  • capability bridges for hooks, history processors, prepare-tools, and MCP
  • hook introspection and HookProjectionMap rendering for existing Hooks capabilities
  • session-scoped host backends

Examples

See examples/pydantic/ for focused SDK examples covering static agents, factories, providers, bridges, approvals, host-context usage, and hook projection.

Key entry points:

  • examples/pydantic/hook_projection.py
  • examples/pydantic/my_agent.py

For fuller workspace documentation, see the root README.md and the docs/ directory.

Project details


Download files

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

Source Distribution

pydantic_acp-0.2.0.tar.gz (35.0 kB view details)

Uploaded Source

Built Distribution

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

pydantic_acp-0.2.0-py3-none-any.whl (49.3 kB view details)

Uploaded Python 3

File details

Details for the file pydantic_acp-0.2.0.tar.gz.

File metadata

  • Download URL: pydantic_acp-0.2.0.tar.gz
  • Upload date:
  • Size: 35.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","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 pydantic_acp-0.2.0.tar.gz
Algorithm Hash digest
SHA256 dc96aac3dbb4aa645b886a4e91f0dbbd7807a3fd1f6e7c4b0742e645474620ab
MD5 e07371540880f5bc27487bfb040fdf36
BLAKE2b-256 49c91a5524caa38e14c9e0f78cc9a13bdd46291d3287428a283af77bfc9b16f5

See more details on using hashes here.

File details

Details for the file pydantic_acp-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pydantic_acp-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 49.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","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 pydantic_acp-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3e0caa17950598474a16466e0c8b3423476c2a2efb139cfe4a2ae1ab88314c94
MD5 867124d8702d847d130b10407ed725f6
BLAKE2b-256 fafa6e25a9c264fdd98c085d772a9b49b2751c89325f581b28d813ab360b6884

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 Pingdom Monitoring Sentry Error logging StatusPage Status page