Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .agents/skills/pydantic-acp/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ When working on this surface, remember:
- keep the direct async-iterable fallback only for tests and compatibility fakes
- `OpenAICompactionBridge` must not pass deprecated `instructions=` into upstream `OpenAICompaction`
- Harness workspace, filesystem, shell, and CodeMode bridges are regression-tested against
`pydantic-ai-harness[code-mode]==0.63.0` through its public imports; include
`pydantic-ai-harness[code-mode]==0.66.0` through its public imports; include
`HarnessLocalWorkspaceBridge` when filesystem or shell capabilities need a workspace, and do not
duplicate unrelated Harness capabilities such as Memory or Guardrails in ACP Kit.
- Harness 0.63.0 requires Pydantic AI 2.63.0; keep Harness
- Harness 0.66.0 requires Pydantic AI 2.66.0; keep Harness
capability tests on the locked development version and use the core adapter
matrix for the full supported range.

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
pydantic-ai-version: ["2.9.0", "2.9.1", "2.10.0", "2.11.0", "2.12.0", "2.13.0", "2.14.0", "2.14.1", "2.15.0", "2.16.0", "2.17.0", "2.18.0", "2.19.0", "2.20.0", "2.21.0", "2.22.0", "2.23.0", "2.24.0", "2.25.0", "2.26.0", "2.27.0", "2.27.1", "2.28.0", "2.29.0", "2.30.0", "2.31.0", "2.31.1", "2.32.0", "2.33.0", "2.34.0", "2.35.0", "2.36.0", "2.37.0", "2.38.0", "2.39.0", "2.40.0", "2.41.0", "2.42.0", "2.43.0", "2.44.0", "2.45.0", "2.46.0", "2.47.0", "2.48.0", "2.49.0", "2.50.0", "2.51.0", "2.52.0", "2.53.0", "2.54.0", "2.55.0", "2.56.0", "2.57.0", "2.58.0", "2.59.0", "2.60.0", "2.61.0", "2.62.0", "2.63.0"]
pydantic-ai-version: ["2.9.0", "2.9.1", "2.10.0", "2.11.0", "2.12.0", "2.13.0", "2.14.0", "2.14.1", "2.15.0", "2.16.0", "2.17.0", "2.18.0", "2.19.0", "2.20.0", "2.21.0", "2.22.0", "2.23.0", "2.24.0", "2.25.0", "2.26.0", "2.27.0", "2.27.1", "2.28.0", "2.29.0", "2.30.0", "2.31.0", "2.31.1", "2.32.0", "2.33.0", "2.34.0", "2.35.0", "2.36.0", "2.37.0", "2.38.0", "2.39.0", "2.40.0", "2.41.0", "2.42.0", "2.43.0", "2.44.0", "2.45.0", "2.46.0", "2.47.0", "2.48.0", "2.49.0", "2.50.0", "2.51.0", "2.52.0", "2.53.0", "2.54.0", "2.55.0", "2.56.0", "2.57.0", "2.58.0", "2.59.0", "2.60.0", "2.61.0", "2.62.0", "2.63.0", "2.64.0", "2.65.0", "2.66.0"]

steps:
- uses: actions/checkout@v7
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@ ACP Kit uses synchronized versions for `acpkit`, `pydantic-acp`, `langchain-acp`

## [Unreleased]

## [1.13.0] - 2026-11-07

### Changed

- `pydantic-acp`, `codex-auth-helper`, and the `acpkit` extras support Pydantic AI through
2.66.0. The Harness bridge pins `pydantic-ai-harness[code-mode]==0.66.0`.

### Fixed

- `codex-auth-helper` async clients now serve requests on successive event loops, such as
repeated `asyncio.run` calls or a host that closes its loop between runs. The HTTP clients
the helper owns for the Codex API and for token refresh are replaced once the loop they last
ran on has stopped; previously the next request reused a connection bound to that loop and
failed with `RuntimeError: Event loop is closed`. Closing a client whose loop has stopped no
longer reports the same error.

## [1.12.0] - 2026-10-30

### Security
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ BLUE := \033[1;34m
GREEN := \033[1;32m
RESET := \033[0m
PYTHON_VERSIONS := 3.11.13 3.12.10 3.13.9
PYDANTIC_AI_VERSIONS := 2.9.0 2.9.1 2.10.0 2.11.0 2.12.0 2.13.0 2.14.0 2.14.1 2.15.0 2.16.0 2.17.0 2.18.0 2.19.0 2.20.0 2.21.0 2.22.0 2.23.0 2.24.0 2.25.0 2.26.0 2.27.0 2.27.1 2.28.0 2.29.0 2.30.0 2.31.0 2.31.1 2.32.0 2.33.0 2.34.0 2.35.0 2.36.0 2.37.0 2.38.0 2.39.0 2.40.0 2.41.0 2.42.0 2.43.0 2.44.0 2.45.0 2.46.0 2.47.0 2.48.0 2.49.0 2.50.0 2.51.0 2.52.0 2.53.0 2.54.0 2.55.0 2.56.0 2.57.0 2.58.0 2.59.0 2.60.0 2.61.0 2.62.0 2.63.0
PYDANTIC_AI_VERSIONS := 2.9.0 2.9.1 2.10.0 2.11.0 2.12.0 2.13.0 2.14.0 2.14.1 2.15.0 2.16.0 2.17.0 2.18.0 2.19.0 2.20.0 2.21.0 2.22.0 2.23.0 2.24.0 2.25.0 2.26.0 2.27.0 2.27.1 2.28.0 2.29.0 2.30.0 2.31.0 2.31.1 2.32.0 2.33.0 2.34.0 2.35.0 2.36.0 2.37.0 2.38.0 2.39.0 2.40.0 2.41.0 2.42.0 2.43.0 2.44.0 2.45.0 2.46.0 2.47.0 2.48.0 2.49.0 2.50.0 2.51.0 2.52.0 2.53.0 2.54.0 2.55.0 2.56.0 2.57.0 2.58.0 2.59.0 2.60.0 2.61.0 2.62.0 2.63.0 2.64.0 2.65.0 2.66.0
LANGCHAIN_VERSION := 1.4.7
LANGGRAPH_VERSION := 1.2.18
DEEPAGENTS_VERSION := 0.7.32
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.12.0
1.13.0
2 changes: 1 addition & 1 deletion docs/getting-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ uv add pydantic-acp
pip install pydantic-acp
```

`pydantic-acp` supports `pydantic-ai-slim>=2.9.0,<=2.63.0` and pins the ACP
`pydantic-acp` supports `pydantic-ai-slim>=2.9.0,<=2.66.0` and pins the ACP
protocol version it integrates against. Pydantic AI V1 and releases before
2.9.0 are not supported.

Expand Down
4 changes: 2 additions & 2 deletions docs/pydantic-acp.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ If you are integrating `pydantic-acp` in a real product:

## Version Compatibility And Private Upstream APIs

`pydantic-acp` supports `pydantic-ai-slim>=2.9.0,<=2.63.0`. Pydantic AI V1 and
`pydantic-acp` supports `pydantic-ai-slim>=2.9.0,<=2.66.0`. Pydantic AI V1 and
Pydantic AI 2.x releases before 2.9.0 are outside the supported range.

Each supported minor is checked against the same adapter runtime suite and
Expand Down Expand Up @@ -429,6 +429,6 @@ aliases and wrapped as `ProcessHistory` capabilities inside
What this means in practice:

- the adapter is less exposed to private upstream type-module churn
- Pydantic AI 2.9.0 through 2.63.0 share one public adapter contract
- Pydantic AI 2.9.0 through 2.66.0 share one public adapter contract
- future Pydantic AI upgrades remain explicit compatibility work
- integration points stay isolated behind ACP Kit bridge and runtime seams
6 changes: 3 additions & 3 deletions docs/pydantic-acp/harness-capabilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ This is the supported path when you want a Pydantic agent to use:
- optional CodeMode execution tools

ACP Kit validates its maintained harness bridge surface against
`pydantic-ai-harness[code-mode]==0.63.0`. The bridges intentionally use the
`pydantic-ai-harness[code-mode]==0.66.0`. The bridges intentionally use the
public `LocalWorkspace`, `FileSystem`, `Shell`, and `CodeMode` imports; newer Harness capabilities
such as Memory and Guardrails remain available to the underlying agent without
being reimplemented as ACP Kit-specific tool bridges.

Harness 0.63.0 itself requires `pydantic-ai-slim==2.63.0`. The core
`pydantic-acp` adapter remains compatible with Pydantic AI 2.9.0 through 2.63.0;
Harness 0.66.0 itself requires `pydantic-ai-slim==2.66.0`. The core
`pydantic-acp` adapter remains compatible with Pydantic AI 2.9.0 through 2.66.0;
install the `harness` extra only when the resolved Pydantic AI version is in the
Harness-supported part of that range.

Expand Down
2 changes: 1 addition & 1 deletion docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ make check-pydantic-ai-matrix
```

This runs the Pydantic adapter runtime tests and type checks independently
against Pydantic AI 2.9.0 through 2.63.0. The same matrix runs
against Pydantic AI 2.9.0 through 2.66.0. The same matrix runs
in CI. Add a version only after both parts pass.

LangChain stack compatibility checks:
Expand Down
2 changes: 1 addition & 1 deletion docs/versioning.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The v1 baseline is:
| Integration | Supported baseline |
|---|---|
| Python | 3.11, 3.12, 3.13 |
| Pydantic AI | 2.9.0 through 2.63.0 |
| Pydantic AI | 2.9.0 through 2.66.0 |
| LangChain | 1.4.7 |
| LangGraph | 1.2.18 |
| DeepAgents | 0.7.32 |
Expand Down
2 changes: 1 addition & 1 deletion packages/adapters/langchain-acp/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.12.0
1.13.0
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

__all__ = ("__version__",)

__version__ = "1.12.0"
__version__ = "1.13.0"
10 changes: 5 additions & 5 deletions packages/adapters/pydantic-acp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ Focused docs recipes:

## Compatibility Policy

`pydantic-acp` supports `pydantic-ai-slim>=2.9.0,<=2.63.0`. Pydantic AI V1 and
`pydantic-acp` supports `pydantic-ai-slim>=2.9.0,<=2.66.0`. Pydantic AI V1 and
Pydantic AI 2.x releases before 2.9.0 are outside the supported range.

The ACP client provider bridge depends on the Pydantic AI v2 `Provider` and `Model` contracts. Upgrades across major Pydantic AI versions should be deliberate because the adapter exposes both server-side ACP translation and client-side ACP provider integration.
Expand All @@ -596,9 +596,9 @@ agent: Agent[None, str] = Agent(

The supported surface includes tool and output-tool preparation, output
validation and processing hooks, deferred tool-call hooks, run metadata,
conversation IDs, and the `run_stream_events()` lifecycle used through 2.63.0.
conversation IDs, and the `run_stream_events()` lifecycle used through 2.66.0.

Harness-backed filesystem, shell, and CodeMode bridges are validated against
`pydantic-ai-harness[code-mode]==0.63.0` using its public capability imports.
Harness 0.63.0 requires `pydantic-ai-slim==2.63.0`; the core adapter itself
remains compatible with Pydantic AI 2.9.0 through 2.63.0.
`pydantic-ai-harness[code-mode]==0.66.0` using its public capability imports.
Harness 0.66.0 requires `pydantic-ai-slim==2.66.0`; the core adapter itself
remains compatible with Pydantic AI 2.9.0 through 2.66.0.
2 changes: 1 addition & 1 deletion packages/adapters/pydantic-acp/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.12.0
1.13.0
4 changes: 2 additions & 2 deletions packages/adapters/pydantic-acp/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ dependencies = [
# Fixed for compliance with the ACP 0.12 public SDK.
"agent-client-protocol==0.12.1",
"anyio>=4.0.0",
"pydantic-ai-slim>=2.9.0,<=2.63.0",
"pydantic-ai-slim>=2.9.0,<=2.66.0",
"pydantic>=2.7",
"typing-extensions>=4.12.0",
]

[project.optional-dependencies]
harness = ["pydantic-ai-harness[code-mode]==0.63.0"]
harness = ["pydantic-ai-harness[code-mode]==0.66.0"]
web = ["agent-client-protocol[http]==0.12.1"]

[project.urls]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

__all__ = ("__version__",)

__version__ = "1.12.0"
__version__ = "1.13.0"
2 changes: 1 addition & 1 deletion packages/helpers/codex-auth-helper/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.12.0
1.13.0
2 changes: 1 addition & 1 deletion packages/helpers/codex-auth-helper/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ classifiers = [
dependencies = [
"httpx>=0.28.1",
"openai>=1.109.1",
"pydantic-ai-slim>=2.9.0,<=2.63.0",
"pydantic-ai-slim>=2.9.0,<=2.66.0",
"typing-extensions>=4.12.0",
]

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from __future__ import annotations as _annotations

import asyncio

__all__ = ("loop_has_stopped",)


def loop_has_stopped(
previous: asyncio.AbstractEventLoop | None, current: asyncio.AbstractEventLoop
) -> bool:
"""Whether an async HTTP client last used on ``previous`` must be replaced on ``current``.

An HTTP connection pool keeps the connections it opened bound to that loop. Once the loop has
stopped, for example after ``asyncio.run`` returned, those connections can neither serve nor
close on another loop. A loop that still runs is left alone: it may be serving the client
concurrently, as Pydantic AI also assumes for the clients its providers own.
"""
return previous is not None and previous is not current and not previous.is_running()
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

__all__ = ("__version__",)

__version__ = "1.12.0"
__version__ = "1.13.0"
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@

import httpx

from .._event_loops import loop_has_stopped
from .config import CodexAuthConfig
from .errors import CodexAuthAccountMismatchError, CodexAuthRefreshError
from .state import CodexAuthState, JsonValue, _extract_account_id
from .store import CodexAuthStore

__all__ = ("CodexTokenManager",)
__all__ = ("CodexTokenManager", "create_auth_http_client")

_REFRESH_LOCKS: WeakValueDictionary[str, Lock] = WeakValueDictionary()
_REFRESH_LOCKS_GUARD = Lock()
Expand All @@ -31,6 +32,11 @@ def _shared_refresh_lock(store: CodexAuthStore) -> Lock:
return lock


def create_auth_http_client(config: CodexAuthConfig) -> httpx.AsyncClient:
"""The HTTP client a token manager owns for refreshing tokens."""
return httpx.AsyncClient(follow_redirects=True, timeout=config.timeout_seconds)


def _now_utc() -> datetime:
return datetime.now(tz=UTC)

Expand All @@ -55,6 +61,9 @@ class CodexTokenManager:
owns_http_client: bool = False
_refresh_lock: Lock = field(init=False, repr=False)
_state: CodexAuthState = field(init=False, repr=False)
_http_client_loop: asyncio.AbstractEventLoop | None = field(
default=None, init=False, repr=False
)

def __post_init__(self) -> None:
self._state = self.store.read_state()
Expand All @@ -69,9 +78,19 @@ def current_account_id(self) -> str | None:
return self._state.account_id

async def close(self) -> None:
if self.owns_http_client:
# A client whose loop has stopped cannot close its connections; they went with the loop.
if self.owns_http_client and not loop_has_stopped(
self._http_client_loop, asyncio.get_running_loop()
):
await self.http_client.aclose()

def _http_client_on_current_loop(self) -> httpx.AsyncClient:
loop = asyncio.get_running_loop()
if self.owns_http_client and loop_has_stopped(self._http_client_loop, loop):
self.http_client = create_auth_http_client(self.config)
self._http_client_loop = loop
return self.http_client

async def get_access_token(self) -> str:
while not self._refresh_lock.acquire(blocking=False):
await asyncio.sleep(0.01)
Expand Down Expand Up @@ -150,7 +169,7 @@ def _should_refresh(self, state: CodexAuthState) -> bool:
return deadline <= _now_utc() + self.config.refresh_margin

async def _refresh_locked(self) -> CodexAuthState:
response = await self.http_client.post(
response = await self._http_client_on_current_loop().post(
f"{self.config.issuer}/oauth/token",
content=str(
httpx.QueryParams(
Expand Down
40 changes: 29 additions & 11 deletions packages/helpers/codex-auth-helper/src/codex_auth_helper/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,18 @@
from uuid import uuid4

import httpx
from openai import AsyncOpenAI, AuthenticationError, NotGiven, Omit, OpenAI
from openai import (
AsyncOpenAI,
AuthenticationError,
DefaultAsyncHttpxClient,
NotGiven,
Omit,
OpenAI,
)
from openai._models import FinalRequestOptions
from typing_extensions import override

from ._event_loops import loop_has_stopped
from ._headers import CODEX_USER_AGENT, codex_request_headers
from ._responses_lite import (
RESPONSES_LITE_HEADER,
Expand All @@ -37,6 +45,7 @@
)
from .auth import CodexAuthConfig, CodexAuthStore, CodexTokenManager
from .auth.errors import CodexAuthAccountMismatchError, CodexAuthRefreshError
from .auth.manager import create_auth_http_client

if TYPE_CHECKING:
from openai.types.websocket_connection_options import WebSocketConnectionOptions
Expand Down Expand Up @@ -135,11 +144,15 @@ def __init__(
self._owns_http_client = owns_http_client
self.responses_transport: CodexResponsesTransport = transport
self.responses_transport_observer = transport_observer
self._http_client_loop: asyncio.AbstractEventLoop | None = None
self._turn_context = ResponsesTurnContext()
super().__init__(
api_key=token_manager.get_access_token,
base_url=base_url,
http_client=http_client,
# An owned client is built here rather than by the SDK, whose default client closes
# itself from its finalizer on whichever loop runs then, including after its own
# loop has stopped. This client is closed by `close`.
http_client=http_client if http_client is not None else DefaultAsyncHttpxClient(),
)
self._http_responses = self.responses
self._responses_session_var: ContextVar[_ResponsesSessionState | None] = ContextVar(
Expand Down Expand Up @@ -504,6 +517,7 @@ async def request(
stream: bool = False,
stream_cls: Any = None,
) -> Any:
self._use_http_client_on_current_loop()
recovery = iter((False, True))
while True:
try:
Expand All @@ -530,9 +544,19 @@ async def _process_response(self, *, response: Any, **kwargs: Any) -> Any:
turn.capture(response.headers)
return await super()._process_response(response=response, **kwargs)

def _use_http_client_on_current_loop(self) -> None:
"""Replace the owned HTTP client once the loop it last ran on has stopped."""
loop = asyncio.get_running_loop()
if self._owns_http_client and loop_has_stopped(self._http_client_loop, loop):
self._client = DefaultAsyncHttpxClient()
self._http_client_loop = loop

@override
async def close(self) -> None:
if self._owns_http_client:
# A client whose loop has stopped cannot close its connections; they went with the loop.
if self._owns_http_client and not loop_has_stopped(
self._http_client_loop, asyncio.get_running_loop()
):
await super().close()
await self.token_manager.close()

Expand Down Expand Up @@ -637,10 +661,7 @@ def create_codex_async_openai(
resolved_config = config or CodexAuthConfig()
owns_http_client = http_client is None
owns_auth_http_client = auth_http_client is None
resolved_auth_http_client = auth_http_client or httpx.AsyncClient(
follow_redirects=True,
timeout=resolved_config.timeout_seconds,
)
resolved_auth_http_client = auth_http_client or create_auth_http_client(resolved_config)
token_manager = CodexTokenManager(
config=resolved_config,
store=CodexAuthStore(resolved_config.auth_path),
Expand All @@ -667,10 +688,7 @@ def create_codex_openai(
resolved_config = config or CodexAuthConfig()
owns_http_client = http_client is None
owns_auth_http_client = auth_http_client is None
resolved_auth_http_client = auth_http_client or httpx.AsyncClient(
follow_redirects=True,
timeout=resolved_config.timeout_seconds,
)
resolved_auth_http_client = auth_http_client or create_auth_http_client(resolved_config)
token_manager = CodexTokenManager(
config=resolved_config,
store=CodexAuthStore(resolved_config.auth_path),
Expand Down
2 changes: 1 addition & 1 deletion packages/transports/acpremote/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.12.0
1.13.0
2 changes: 1 addition & 1 deletion packages/transports/acpremote/src/acpremote/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

__all__ = ("__version__",)

__version__ = "1.12.0"
__version__ = "1.13.0"
Loading
Loading