Skip to content

Fix/acp 1.1 - #3735

Open
vvlrff wants to merge 3 commits into
mainfrom
fix/acp-1.1
Open

vvlrff wants to merge 3 commits into
mainfrom
fix/acp-1.1

Conversation

@vvlrff

@vvlrff vvlrff commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

Why are these changes needed?

agent-client-protocol 1.1 changes the SDK's Client protocol and adds new request fields, session updates and capabilities. This PR moves ag2[acp] to agent-client-protocol>=1.1.0,<2 and handles the new protocol surface on both sides of the integration.

SDK compatibility

  • ACPBridge: SDK 1.1 removes connect_mcp / disconnect_mcp / notify_mcp from the Client protocol and changes the signature of mcp_message. The bridge refuses mcp/message with method_not_found and ignores the new auth_status_update notification.
  • ag2/acp/types.py: the new SessionUpdate variants (prompt_suggestions_update, cursor_update, subagent_update, session_message, session_message_chunk) and ToolCallContentSession are added to the unions. The mappers return None for them, or skip them, because AG2 advertises none of the matching Client capabilities.
  • _request_meta (ag2/acp/agent.py): in 1.1 the router merges _meta into the handler kwargs in acp/utils.py: model_to_kwargs. Request fields that a handler does not declare also land in **kwargs. Python field names are now removed from **kwargs by name, so a field added by a newer SDK is not mistaken for Client metadata. The _meta collision guard (ag2/acp/guard.py) reads field names from the SDK request models, with methods keyed by AGENT_METHODS.

Client side (ACPConfig → CLI agent)

  • The AG2 agent's instructions (prompt and @agent.prompt hooks) are sent as ACP systemPrompt in append mode on session/new. This happens only when the agent advertises sessionCapabilities.systemPrompt. ACP forbids sending the field to an agent that does not advertise it, so in that case the instructions are not sent and a warning is logged.
  • model: when the agent advertises sessionCapabilities.options, the client calls session/options and sends the model as an initial config option with session/new, so the session starts on that model. Otherwise it falls back to session/set_config_option as before. A model the agent does not offer still raises ValueError before the first turn.

Server side (ACPAgent)

  • New accept_system_prompt: bool = False. It is off by default because a Client's systemPrompt joins the agent's instructions at system level, which gives whoever connects more control than a user message has.
    • When it is on, sessionCapabilities.systemPrompt is advertised and append mode is applied to every turn of the session.
    • override mode, non-text blocks, an empty prompt, and any prompt while the option is off are all refused with invalid_params, and no session is created.
    • A session/load without a prompt keeps the one the live session already has. A session restored from storage starts without it.
  • Initial configOptions on session/new / session/load are accepted and ignored. ACP requires this for unknown option ids, and ACPAgent has no config options.
  • The capabilities docs list the newly unsupported methods (session/archive, session/unarchive, session/status, session/options, session/set_title, auth/status).

The docs (website/docs/user-guide/acp/client.mdx, server.mdx) are updated for model selection, instruction delivery and accept_system_prompt.

Note: the minimum version of agent-client-protocol goes from 1.0.0 to 1.1.0.

Related issue number

Checks

New tests:

  • test/acp/test_agent_request_fields.py: systemPrompt and configOptions on the server side, and _meta extraction.
  • test/acp/test_client_e2e.py: TestInitialModelOption and TestSystemPrompt.
  • test/acp/test_bridge.py: unsupported Client methods.
  • test/acp/test_mappers.py: the new update variants.

Local validation: pytest test/acp (560 passed), ruff check, and mypy ag2/acp/guard.py ag2/acp/agent.py. CI has not run yet.

AI assistance

  • I understand the changes in this PR and can explain them in my own words.
  • I have verified that the PR description accurately reflects the actual diff.
  • If AI assistance was used, I reviewed, tested, and validated the generated code/text before submitting.

- Require agent-client-protocol>=1.1.0; adapt to removed mcp/connect,
  mcp/disconnect and PlanUpdateFile, and the new mcp/message signature.
- Client: send the agent's prompt as ACP systemPrompt (append) when the
  agent advertises sessionCapabilities.systemPrompt; warn otherwise.
- Client: pass model with session/new via session/options + configOptions
  when the agent advertises sessionCapabilities.options.
- Server: ACPAgent(accept_system_prompt=True) opts in to client
  systemPrompt in append mode; refused by default and in other modes.
- Keep undeclared request fields out of session _meta; ignore initial
  configOptions per spec.
@github-actions github-actions Bot added area:docs Documentation (website/) area:acp ACP support for CLI coding agents (ag2/acp) area:deps Python dependency updates (pyproject.toml, uv.lock) labels Nov 26, 2026
@github-actions github-actions Bot added the area:tools Tool system, builtin tools, subagents (ag2/tools) label Nov 27, 2026
@codecov

codecov Bot commented Nov 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.71795% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
ag2/acp/guard.py 87.50% 0 Missing and 1 partial ⚠️
Files with missing lines Coverage Δ
ag2/acp/agent.py 93.67% <100.00%> (+0.54%) ⬆️
ag2/acp/bridge.py 93.86% <100.00%> (+1.30%) ⬆️
ag2/acp/client.py 93.70% <ø> (ø)
ag2/acp/executor.py 94.28% <100.00%> (+0.05%) ⬆️
ag2/acp/mappers.py 93.57% <ø> (ø)
ag2/acp/session.py 94.40% <100.00%> (+1.13%) ⬆️
ag2/acp/sessions.py 96.00% <100.00%> (+0.01%) ⬆️
ag2/acp/testing.py 93.98% <100.00%> (+0.16%) ⬆️
ag2/acp/types.py 100.00% <100.00%> (ø)
ag2/acp/guard.py 91.83% <87.50%> (-0.62%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:acp ACP support for CLI coding agents (ag2/acp) area:deps Python dependency updates (pyproject.toml, uv.lock) area:docs Documentation (website/) area:tools Tool system, builtin tools, subagents (ag2/tools)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant