ACP adapter for pydantic-ai agents.
Project description
pydantic-acp
pydantic-acp adapts pydantic_ai.Agent instances to the ACP agent interface without rewriting the underlying agent.
The core contract is simple:
- keep the existing
pydantic_ai.Agent - expose it through ACP
- only publish ACP-visible state the runtime can actually honor
Entry Points
run_acp(...)create_acp_agent(...)AdapterConfigAcpSessionContextStaticAgentSourceFactoryAgentSourceMemorySessionStoreFileSessionStore
What It Covers
pydantic-acp includes:
- ACP session lifecycle, replay, resume, and persistence
- session-local model selection
- mode and slash-command control
- native ACP plan state with structured
TaskPlan - approval bridging
- prompt resources including files, embedded resources, images, and audio
- projection maps for filesystem, hooks, web tools, and builtin tool families
- capability bridges for upstream Pydantic AI capabilities
- client-backed filesystem and terminal helpers
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)
If another runtime should own transport lifecycle:
from acp import run_agent
from pydantic_ai import Agent
from pydantic_acp import AdapterConfig, MemorySessionStore, create_acp_agent
agent = Agent("openai:gpt-5", name="composable-agent")
acp_agent = create_acp_agent(
agent=agent,
config=AdapterConfig(session_store=MemorySessionStore()),
)
run_agent(acp_agent)
Native Plan Mode
TaskPlan is the structured native plan output surface.
Use PrepareToolsBridge to expose plan mode:
from pydantic_ai import Agent
from pydantic_ai.tools import RunContext, ToolDefinition
from pydantic_acp import (
AdapterConfig,
PrepareToolsBridge,
PrepareToolsMode,
run_acp,
)
def read_only_tools(
ctx: RunContext[None],
tool_defs: list[ToolDefinition],
) -> list[ToolDefinition]:
del ctx
return list(tool_defs)
agent = Agent("openai:gpt-5", name="plan-agent")
run_acp(
agent=agent,
config=AdapterConfig(
capability_bridges=[
PrepareToolsBridge(
default_mode_id="plan",
default_plan_generation_type="structured",
modes=[
PrepareToolsMode(
id="plan",
name="Plan",
description="Return a structured ACP task plan.",
prepare_func=read_only_tools,
plan_mode=True,
),
],
),
],
),
)
Important behavior:
plan_generation_type="structured"is the default plan-mode behaviorstructuredmode expects structuredTaskPlanoutput instead of exposingacp_set_plan- switch to
plan_generation_type="tools"when you explicitly want tool-based native plan recording - keep
plan_tools=Truewhen you also want progress tools such asacp_update_plan_entry
Projection Maps
Projection maps decide how known tool families render into ACP-visible updates.
Built-in projection helpers:
FileSystemProjectionMapHookProjectionMapWebToolProjectionMapBuiltinToolProjectionMap
Example:
from pydantic_acp import (
AdapterConfig,
BuiltinToolProjectionMap,
FileSystemProjectionMap,
HookProjectionMap,
run_acp,
)
run_acp(
agent=agent,
config=AdapterConfig(
projection_maps=[
FileSystemProjectionMap(
default_read_tool="read_file",
default_write_tool="write_file",
),
HookProjectionMap(
hidden_event_ids=frozenset({"after_model_request"}),
event_labels={"before_model_request": "Preparing Request"},
),
BuiltinToolProjectionMap(),
],
),
)
Capability Bridges
Current built-in bridges include:
ThinkingBridgePrepareToolsBridgeThreadExecutorBridgeSetToolMetadataBridgeIncludeToolReturnSchemasBridgeWebSearchBridgeWebFetchBridgeImageGenerationBridgeMcpCapabilityBridgeToolsetBridgePrefixToolsBridgeOpenAICompactionBridgeAnthropicCompactionBridge
Use bridges when the runtime should gain upstream Pydantic AI capabilities and ACP-visible metadata without rewriting the adapter core.
Factories, Sources, And Host-owned State
Use agent_factory= when the ACP session should influence which agent gets built:
from pydantic_ai import Agent
from pydantic_acp import AcpSessionContext, AdapterConfig, MemorySessionStore, run_acp
def build_agent(session: AcpSessionContext) -> Agent[None, str]:
workspace_name = session.cwd.name
model_name = "openai:gpt-5.4-mini"
if workspace_name.endswith("-deep"):
model_name = "openai:gpt-5.4"
return Agent(model_name, name=f"workspace-{workspace_name}")
run_acp(
agent_factory=build_agent,
config=AdapterConfig(session_store=MemorySessionStore()),
)
Use AgentSource when the agent and its dependencies should be built separately. Use providers when models, modes, config values, plans, or approvals belong to the host layer instead of the adapter.
Maintained Examples
Maintained runnable examples:
Focused docs recipes:
Documentation
- Pydantic ACP Overview
- AdapterConfig
- Plans, Thinking, and Approvals
- Models, Modes, and Slash Commands
- Prompt Resources and Context
- Session State and Lifecycle
- Bridges
- Providers
- Host Backends and Projections
- API Reference
Compatibility Policy
pydantic-acp currently pins pydantic-ai-slim==1.83.0.
That pin is deliberate. The adapter is tested against a specific Pydantic AI surface and should still be upgraded deliberately, but the hook-compatibility seam is now isolated behind ACP Kit’s own compatibility layer instead of scattering private upstream imports through the runtime.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pydantic_acp-0.9.0.tar.gz.
File metadata
- Download URL: pydantic_acp-0.9.0.tar.gz
- Upload date:
- Size: 69.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d6e0c45c8f8e278a6311abab35655324aae91a374635c2f63b227aa1d2c445b
|
|
| MD5 |
9d6777dc0697b33a1cea8be66f258a60
|
|
| BLAKE2b-256 |
8b5b169ce28554d51161a1e49e173ced8756d3d7593538d6b7501d44f0f65b22
|
File details
Details for the file pydantic_acp-0.9.0-py3-none-any.whl.
File metadata
- Download URL: pydantic_acp-0.9.0-py3-none-any.whl
- Upload date:
- Size: 99.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f1254211483674f569d4dc821aee523fb94fb39c0a92a1956a058c8683ea735
|
|
| MD5 |
c1b62d4d554b39e781049b9afc6786e7
|
|
| BLAKE2b-256 |
86f03a5e087726ce079a887259fbaf52ec41da51855600481aa383fbc166a8dc
|