Repository navigation
fix(sdk): apply claude-code initial ACP model via set_session_model (claude-agent-acp ignores _meta) - #3655
Conversation
claude-agent-acp 0.30.0 silently ignores the session-_meta model selection the init path relied on: the requested model only becomes a picker option while the session keeps running the CLI default, and current_model_id reports the override — the conversation lies about its model. Flip claude-code to supports_set_session_model=True so init pushes the model through the same one-shot session/set_model call as codex/gemini; the _meta payload is still sent as best-effort. E2E on the pinned CLI: with acp_model=claude-haiku-4-5 the CLI transcript records claude-sonnet-4-6 before this change and claude-haiku-4-5-20251001 after. Fixes #3654 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Python API breakage checks — ✅ PASSEDResult: ✅ PASSED |
REST API breakage checks (OpenAPI) — ✅ PASSEDResult: ✅ PASSED |
Coverage Report •
|
||||||||||||||||||||
all-hands-bot
left a comment
There was a problem hiding this comment.
🟡 QA Report: PARTIAL
Verified the SDK ACP initialization path now sends session/set_model for a Claude ACP-style server before prompting, but I could not verify the final Claude CLI transcript model without Claude subscription auth in this environment.
Does this PR achieve its stated goal?
Partially verified. The PR’s stated goal is to stop relying only on Claude session/new _meta for the initial acp_model and instead apply it through session/set_model; exercising an actual ACPAgent + Conversation.run() flow shows main sends only _meta, while this PR sends session/set_model with modelId='claude-haiku-4-5' before session/prompt. I also attempted the real pinned @agentclientprotocol/claude-agent-acp@0.30.0 package with a real prompt, but it failed at prompt time with Authentication required, so I could not independently confirm the Claude CLI transcript records the requested model.
| Phase | Result |
|---|---|
| Environment Setup | ✅ make build completed and installed the uv environment successfully. |
| CI Status | 🟡 Observed 25 successful, 15 skipped, 6 pending, 0 failing checks via gh pr checks. |
| Functional Verification | 🟡 SDK behavior verified before/after; real Claude transcript blocked by missing auth. |
Functional Verification
Test 1: Claude-style ACP initial model selection uses session/set_model
Step 1 — Reproduce / establish baseline (without the fix):
Ran git switch --detach origin/main && ACP_STUB_LOG=/tmp/openhands-qa-acp/main.jsonl OPENHANDS_SUPPRESS_BANNER=1 uv run python /tmp/openhands-qa-acp/run_acp_conversation.py against a minimal Claude ACP-style stdio server that reports agentInfo.name='claude-agent-acp', accepts session/new _meta, and records all JSON-RPC calls:
RPC_METHODS ['initialize', 'session/new', 'session/set_mode', 'session/prompt']
SESSION_NEW_META {'claudeCode': {'options': {'model': 'claude-haiku-4-5'}}}
SET_MODEL_CALLS 0
SET_MODEL_PARAMS None
PROMPT_CALLED True
This confirms the old behavior: the SDK advertised the requested model in Claude _meta, but never called session/set_model before the first prompt. For a provider that ignores _meta, the requested initial model would not be authoritatively applied.
Step 2 — Apply the PR's changes:
Checked out fix-acp-claude-initial-model-selection at d0d7e2ed740f353089c84c296c336afb76aa2dc7.
Step 3 — Re-run with the fix in place:
Ran ACP_STUB_LOG=/tmp/openhands-qa-acp/pr.jsonl OPENHANDS_SUPPRESS_BANNER=1 uv run python /tmp/openhands-qa-acp/run_acp_conversation.py:
RPC_METHODS ['initialize', 'session/new', 'session/set_model', 'session/set_mode', 'session/prompt']
SESSION_NEW_META {'claudeCode': {'options': {'model': 'claude-haiku-4-5'}}}
SET_MODEL_CALLS 1
SET_MODEL_PARAMS {'modelId': 'claude-haiku-4-5', 'sessionId': 'stub-session'}
PROMPT_CALLED True
This shows the PR changes the user-facing SDK conversation path as intended: the same ACPAgent(acp_model='claude-haiku-4-5') flow still sends the best-effort Claude _meta, and now also sends the authoritative session/set_model request before prompting.
Unable to Verify
I attempted a real run with the pinned Claude ACP package using OPENHANDS_SUPPRESS_BANNER=1 uv run python /tmp/openhands-qa-acp/run_real_claude_acp.py, where the script used:
ACPAgent(
acp_command=['npx', '-y', '@agentclientprotocol/claude-agent-acp@0.30.0'],
acp_model='claude-haiku-4-5',
acp_prompt_timeout=30,
)Observed output excerpt:
ACP server initialized: agent_name='@agentclientprotocol/claude-agent-acp', agent_version='0.30.0'
Setting ACP session mode: bypassPermissions
Sending ACP prompt (idle_timeout=30s, blocks=1)
ACP prompt failed: Authentication required
openhands.sdk.conversation.exceptions.ConversationRunError: Conversation run failed ... Authentication required
Because this environment lacks Claude subscription/auth state, I could not complete a real Claude prompt or inspect ~/.claude/projects/.../*.jsonl to confirm the recorded assistant-message model. Future QA runs would benefit from AGENTS.md guidance documenting how to provide non-interactive Claude auth for ACP end-to-end verification.
Issues Found
None in the SDK behavior exercised. End-to-end Claude transcript verification remains unverified due missing Claude auth.
This review was created by an AI agent (OpenHands) on behalf of the user.
all-hands-bot
left a comment
There was a problem hiding this comment.
🟡 QA Report: PARTIAL
Verified that the SDK now sends session/set_model for a Claude ACP session before prompting; full Claude transcript confirmation could not be completed because the real claude-agent-acp@0.30.0 run requires authentication in this environment.
Does this PR achieve its stated goal?
Yes for the SDK behavior this PR changes: a before/after run through Conversation.run() with an ACP server identifying as claude-agent-acp showed main only sent the model in session/new _meta, while this PR additionally sent session/set_model with modelId: claude-haiku-4-5 before session/prompt. I also attempted the real npx -y @agentclientprotocol/claude-agent-acp@0.30.0 path first; it initialized successfully but stopped at Authentication required, so I could not independently verify Claude's transcript-recorded model selection.
| Phase | Result |
|---|---|
| Environment Setup | ✅ make build completed and installed the uv workspace environment |
| CI Status | ✅ PR checks were green/skipped except the current qa-changes job still in progress when checked |
| Functional Verification | 🟡 SDK call sequencing verified before/after; real Claude transcript verification blocked by missing auth |
Functional Verification
Test 1: Claude ACP initial model is applied via session/set_model
Step 1 — Reproduce / establish baseline (without the fix):
Checked out origin/main and ran a real SDK Conversation.run() using ACPAgent(acp_model="claude-haiku-4-5") against a local ACP stdio server that identifies as claude-agent-acp and records received JSON-RPC requests:
git checkout --detach origin/main
OPENHANDS_SUPPRESS_BANNER=1 uv run python .agent_tmp/qa-acp/run_fake_acp_conversation.py .agent_tmp/qa-acp/main-requests.jsonl .agent_tmp/qa-acp/main-workspaceObserved request sequence:
request initialize {"protocolVersion": 1}
request session/new {"_meta": {"claudeCode": {"options": {"model": "claude-haiku-4-5"}}}, "cwd": ".agent_tmp/qa-acp/main-workspace", "mcpServers": []}
request session/set_mode {"modeId": "bypassPermissions", "sessionId": "qa-session-1"}
request session/prompt {"prompt": [{"text": "Reply with exactly QA_ACP_MODEL_CHECK", "type": "text"}], "sessionId": "qa-session-1"}
This confirms the baseline bug at the SDK boundary: for a Claude ACP session with an explicit acp_model, the SDK only advertised the model via _meta and never sent session/set_model before prompting.
Step 2 — Apply the PR's changes:
Checked out PR commit d0d7e2ed740f353089c84c296c336afb76aa2dc7.
Step 3 — Re-run with the fix in place:
Ran the same Conversation.run() flow with the same requested model:
git checkout --detach d0d7e2ed740f353089c84c296c336afb76aa2dc7
OPENHANDS_SUPPRESS_BANNER=1 uv run python .agent_tmp/qa-acp/run_fake_acp_conversation.py .agent_tmp/qa-acp/pr-requests-final.jsonl .agent_tmp/qa-acp/pr-workspace-finalObserved request sequence:
request initialize {"protocolVersion": 1}
request session/new {"_meta": {"claudeCode": {"options": {"model": "claude-haiku-4-5"}}}, "cwd": ".agent_tmp/qa-acp/pr-workspace-final", "mcpServers": []}
request session/set_model {"modelId": "claude-haiku-4-5", "sessionId": "qa-session-1"}
request session/set_mode {"modeId": "bypassPermissions", "sessionId": "qa-session-1"}
request session/prompt {"prompt": [{"text": "Reply with exactly QA_ACP_MODEL_CHECK", "type": "text"}], "sessionId": "qa-session-1"}
This verifies the PR's changed behavior: the SDK now sends session/set_model for Claude during session creation, using the requested acp_model, before the first user prompt is sent.
Unable to Verify
I attempted the real user path with the published Claude ACP package:
OPENHANDS_SUPPRESS_BANNER=1 uv run python .agent_tmp/qa-acp/run_claude_acp.pyThe SDK started npx -y @agentclientprotocol/claude-agent-acp@0.30.0, initialized the ACP server successfully, and then failed on the first prompt with:
ACP server initialized: agent_name='@agentclientprotocol/claude-agent-acp', agent_version='0.30.0'
ACP prompt failed: Authentication required
ConversationRunError: Conversation run failed ... Authentication required
Because this environment does not have Claude subscription authentication, I could not verify the final ground truth claimed in the PR description: that Claude's own transcript JSONL records claude-haiku-4-5-20251001 instead of the default model. Future QA runs would benefit from AGENTS.md guidance describing how to provision a non-interactive Claude ACP auth context and where to read the transcript safely.
Issues Found
None.
This QA report was created by an AI agent (OpenHands) on behalf of the user.
Final verdict: PARTIAL
…claude-agent-acp ignores _meta) (OpenHands#3655) Co-authored-by: Simon Rosenberg <simon@openhands.dev> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
HUMAN:
apply claude-code initial ACP model via set_session_model
AGENT:
Validated end-to-end against the pinned
claude-agent-acp@0.30.0with real subscription auth, using the Claude CLI's own session transcript (~/.claude/projects/<cwd>/<session>.jsonl, which records the model per assistant message) as ground truth — see How to Test for the before/after.Why
claude-agent-acp 0.30.0 silently ignores the
_meta {"claudeCode": {"options": {"model": ...}}}initial-model selection the SDK's claude-code init path relies on (#3654, discovered during the #3651 audit). The requested model is only registered as a picker option; the session keeps running the CLI default. MeanwhileACPAgent.current_model_idreports the override — so every claude-code conversation claims to run the chosen model while actually running the default.Summary
claude-codetosupports_set_session_model=True: the init path now pushesacp_modelthrough the same one-shotsession/set_modelcall codex/gemini already use (the call the audit: remove broken/unsupported models from ACP provider model lists #3651 audit verified validates-and-applies for every curated Claude model).session_meta_key="claudeCode"— the_metapayload is still sent as best-effort and selects the same model if a future CLI honours it; docstrings updated to reflect the new contract.applied=True); registry capability assertions flipped.Behavioural note: an invalid/inaccessible
acp_modelpreviously silently succeeded on the default model; now the CLI accepts theset_model(it defers validation) and the first prompt surfaces-32603 "There's an issue with the selected model"after the prompt-retry loop — visible failure instead of a silent wrong model.Issue Number
Fixes #3654
How to Test
Run any claude-code ACP conversation with an explicit
acp_modeland check the model recorded in the CLI's transcript JSONL. Withacp_model="claude-haiku-4-5"(script: oneConversation.run()turn overACPAgent(acp_command=["npx","-y","@agentclientprotocol/claude-agent-acp@0.30.0"], acp_model="claude-haiku-4-5")):Unit tests:
uv run pytest tests/sdk/agent/test_acp_agent.py tests/sdk/settings/test_acp_providers.py tests/sdk/test_settings.py tests/agent_server/→ 1656 passed, 1 pre-existing failure (TestAutoTitle::test_autotitle_sets_title_on_first_user_message, also fails on clean main locally, unrelated).Note for downstream: typescript-client's
acp-providers.jsonmirrorssupports_set_session_model— its drift job will need the one-line mirror sync after this merges (will open the companion PR).🤖 Generated with Claude Code
Agent Server images for this PR
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdknikolaik/python-nodejs:python3.13-nodejs22-slimgolang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:d0d7e2e-pythonRun
All tags pushed for this build
About Multi-Architecture Support
d0d7e2e-python) is a multi-arch manifest supporting both amd64 and arm64d0d7e2e-python-amd64) are also available if needed