Skip to content

feat(pydantic-acp): auth recovery, public session bootstrap, and clean agent-error propagation#22

Merged
fswair merged 3 commits into
vcoderun:mainfrom
arthrod:feat/pydantic-acp-session-hardening
Jul 24, 2026
Merged

feat(pydantic-acp): auth recovery, public session bootstrap, and clean agent-error propagation#22
fswair merged 3 commits into
vcoderun:mainfrom
arthrod:feat/pydantic-acp-session-hardening

Conversation

@arthrod

@arthrod arthrod commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Description

Hardens the pydantic-acp ACP client/provider so unusable ACP agents fail
legibly instead of returning silent turns or opaque TaskGroup failures. This
ships as the synchronized patch release 1.5.1.

Added

  • AcpProvider recovers from auth_required during session/new by using an
    advertised agent-managed auth method, or an explicit prepared
    auth_method_id, then retrying session creation once. Environment-variable
    and terminal methods remain client-owned.
  • Public AcpProvider.ensure_session() and
    AcpProvider.set_session_mode() bootstrap and configure a session without a
    dummy prompt.
  • raise_on_empty_turn=True raises UnexpectedModelBehavior when a text turn
    produces no visible output. The default remains False.
  • create_acp_model(...) exposes auth_method_id and
    raise_on_empty_turn.

Fixed

  • ACP agent errors escape single-child anyio TaskGroup wrappers without
    discarding unrelated aggregate failures or cancellation.
  • Auth method and session response handling use concrete ACP schema types.
  • The root README, package README, Pydantic ACP guide, compatibility template,
    skill, and changelog document the new behavior.

Type of change

  • Bug fix
  • Backward-compatible public API addition
  • Breaking change
  • Documentation update

Verification

  • make prod
  • 697 full-suite tests passed
  • 603 coverage tests passed
  • 100% line coverage and 100% branch coverage
  • Ruff, ty, and basedpyright passed
  • Strict docs build passed
  • Python 3.11, 3.12, and 3.13 passed
  • Pydantic AI 2.9.0 through 2.16.0 passed
  • LangChain compatibility suite passed
  • Synchronized 1.5.1 release metadata passed

…agate real agent errors

Hardens the pydantic-acp ACP client/provider so an unusable ACP agent fails
legibly instead of silently, and adds the session-bootstrap surface the bridge
was missing.

Added
- Auth recovery: AcpProvider captures initialize's auth_methods and, when
  session/new is rejected with auth_required (-32000), runs the ACP
  authenticate flow (an advertised method, or an explicit auth_method_id=) and
  retries session creation once. Such agents were previously unrecoverable.
- Public session bootstrap: AcpProvider.ensure_session() and
  AcpProvider.set_session_mode() bootstrap a session and select a session mode
  without sending a prompt turn, so callers no longer reach into the private
  _ensure_session.
- Opt-in AcpProvider(raise_on_empty_turn=True) raises UnexpectedModelBehavior
  with an ACP-specific diagnostic when a text-output turn yields no visible
  text. Default False preserves the existing empty-response contract.

Fixed
- request_prompt propagates the agent's real error (rate limit, auth rejection,
  upstream API failure) by unwrapping single-child anyio TaskGroup
  BaseExceptionGroups and dropping TaskGroup __context__ noise, instead of
  surfacing an opaque "ExceptionGroup: unhandled errors in a TaskGroup".

Synchronized workspace bump 1.5.0 -> 1.6.0 with CHANGELOG entry. pydantic-acp
client.py is at 100% line and branch coverage; make check (ruff + ty +
basedpyright), make tests, make check-coverage, and pre-commit all pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CweysdtvG97d28xrbeF9BM
@fswair

fswair commented Jul 24, 2026

Copy link
Copy Markdown
Member

I'll check today, thanks for contribution.

@fswair

fswair commented Jul 24, 2026

Copy link
Copy Markdown
Member

Rebumped to 1.5.1; there aren't any big changes.

@fswair
fswair merged commit e7f58fa into vcoderun:main Jul 24, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants