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.

Entry Points

  • run_acp(...)
  • create_acp_agent(...)
  • AdapterConfig
  • AcpSessionContext
  • MemorySessionStore
  • FileSessionStore

What It Covers

pydantic-acp includes:

  • ACP session lifecycle and replay
  • session-local model control
  • providers for host-owned models, modes, config options, and plans
  • native deferred approval bridging
  • projection maps for filesystem diffs and bash previews
  • capability bridges for hooks, history processors, prepare-tools, and MCP metadata
  • hook introspection and HookProjectionMap
  • client-backed filesystem and terminal helpers

Compatibility Policy

pydantic-acp currently pins pydantic-ai-slim==1.83.0.

That pin is still deliberate, but the adapter no longer imports Pydantic AI private history-processor modules directly. ACP Kit defines its own history-processor callable aliases and wires them into the public Agent(..., history_processors=...) surface.

Practical implication:

  • upgrades should still be treated as deliberate compatibility work
  • ACP Kit is no longer coupled to pydantic_ai._history_processor imports
  • history processor integrations should use ACP Kit's exported aliases or plain callable functions, not upstream private modules

Slash commands are available for:

  • /model
  • /tools
  • /hooks
  • /mcp-servers

Quick Start

from pydantic_ai import Agent
from pydantic_acp import run_acp

agent = Agent("openai:gpt-5", name="demo-agent")
run_acp(agent=agent)

Configured Runtime

from pathlib import Path

from pydantic_ai import Agent
from pydantic_acp import (
    AdapterConfig,
    FileSessionStore,
    NativeApprovalBridge,
    run_acp,
)

agent = Agent("openai:gpt-5", name="configured-agent")

run_acp(
    agent=agent,
    config=AdapterConfig(
        session_store=FileSessionStore(root=Path(".acp-sessions")),
        approval_bridge=NativeApprovalBridge(enable_persistent_choices=True),
    ),
)

Projection Maps

Filesystem projection:

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:

from pydantic_acp import HookProjectionMap, run_acp

run_acp(
    agent=agent,
    projection_maps=(
        HookProjectionMap(
            hidden_event_ids=frozenset({"after_model_request"}),
            event_labels={"before_tool_execute": "Starting Tool"},
        ),
    ),
)

Factories, Providers, And Host Backends

Use agent_factory or AgentSource when the session context should influence agent creation. Use providers when models, modes, config options, or plans belong to the host layer. Use ClientHostContext when tools should talk back to the ACP client's filesystem or terminal.

Examples

See examples/pydantic/README.md for focused SDK examples and the full runnable demo.

Key examples:

For full workspace documentation, see:

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.8.0.tar.gz (68.1 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.8.0-py3-none-any.whl (98.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pydantic_acp-0.8.0.tar.gz
  • Upload date:
  • Size: 68.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","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.8.0.tar.gz
Algorithm Hash digest
SHA256 a738ebf52d6c68fddcb4a02a877208d698d2691ceb5051eef9d1bb9d3e2685c3
MD5 b5b65c9da58a45808b4bf1e67811b15e
BLAKE2b-256 c45971819376a58d9a030b6b031d8a4297846c4c9997a442e2c2ba51a0778ca0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pydantic_acp-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 98.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","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.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 346a249f76322ce0f1b906a5eb5b37cf5322236b9fd2fadfb639d12a697067df
MD5 867392f6d65b00c23d3ca0ec3e94ca94
BLAKE2b-256 80979c65b7ef915d108ffa16c4d6dab58164f94385a452331fba82128df5b40f

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