Repository navigation
Fix/acp 1.1 - #3735
Open
vvlrff wants to merge 3 commits into
Open
Fix/acp 1.1#3735vvlrff wants to merge 3 commits into
vvlrff wants to merge 3 commits into
Conversation
- 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.
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why are these changes needed?
agent-client-protocol1.1 changes the SDK's Client protocol and adds new request fields, session updates and capabilities. This PR movesag2[acp]toagent-client-protocol>=1.1.0,<2and handles the new protocol surface on both sides of the integration.SDK compatibility
ACPBridge: SDK 1.1 removesconnect_mcp/disconnect_mcp/notify_mcpfrom the Client protocol and changes the signature ofmcp_message. The bridge refusesmcp/messagewithmethod_not_foundand ignores the newauth_status_updatenotification.ag2/acp/types.py: the newSessionUpdatevariants (prompt_suggestions_update,cursor_update,subagent_update,session_message,session_message_chunk) andToolCallContentSessionare added to the unions. The mappers returnNonefor 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_metainto the handler kwargs inacp/utils.py: model_to_kwargs. Request fields that a handler does not declare also land in**kwargs. Python field names are now removed from**kwargsby name, so a field added by a newer SDK is not mistaken for Client metadata. The_metacollision guard (ag2/acp/guard.py) reads field names from the SDK request models, with methods keyed byAGENT_METHODS.Client side (
ACPConfig→ CLI agent)promptand@agent.prompthooks) are sent as ACPsystemPromptinappendmode onsession/new. This happens only when the agent advertisessessionCapabilities.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 advertisessessionCapabilities.options, the client callssession/optionsand sends the model as an initial config option withsession/new, so the session starts on that model. Otherwise it falls back tosession/set_config_optionas before. A model the agent does not offer still raisesValueErrorbefore the first turn.Server side (
ACPAgent)accept_system_prompt: bool = False. It is off by default because a Client'ssystemPromptjoins the agent's instructions at system level, which gives whoever connects more control than a user message has.sessionCapabilities.systemPromptis advertised andappendmode is applied to every turn of the session.overridemode, non-text blocks, an empty prompt, and any prompt while the option is off are all refused withinvalid_params, and no session is created.session/loadwithout a prompt keeps the one the live session already has. A session restored from storage starts without it.configOptionsonsession/new/session/loadare accepted and ignored. ACP requires this for unknown option ids, andACPAgenthas no config options.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 andaccept_system_prompt.Note: the minimum version of
agent-client-protocolgoes from 1.0.0 to 1.1.0.Related issue number
Checks
New tests:
test/acp/test_agent_request_fields.py:systemPromptandconfigOptionson the server side, and_metaextraction.test/acp/test_client_e2e.py:TestInitialModelOptionandTestSystemPrompt.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, andmypy ag2/acp/guard.py ag2/acp/agent.py. CI has not run yet.AI assistance