Skip to content

fix(sdk): apply claude-code initial ACP model via set_session_model (claude-agent-acp ignores _meta) - #3655

Merged
simonrosenberg merged 2 commits into
mainfrom
fix-acp-claude-initial-model-selection
Jun 11, 2026
Merged

simonrosenberg merged 2 commits into
mainfrom
fix-acp-claude-initial-model-selection

Conversation

@simonrosenberg

@simonrosenberg simonrosenberg commented Jun 11, 2026 •

Copy link
Copy Markdown
Member

HUMAN:

apply claude-code initial ACP model via set_session_model

  • A human has tested these changes.

AGENT:

Validated end-to-end against the pinned claude-agent-acp@0.30.0 with 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. Meanwhile ACPAgent.current_model_id reports the override — so every claude-code conversation claims to run the chosen model while actually running the default.

Summary

  • Flip claude-code to supports_set_session_model=True: the init path now pushes acp_model through the same one-shot session/set_model call 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).
  • Keep session_meta_key="claudeCode" — the _meta payload is still sent as best-effort and selects the same model if a future CLI honours it; docstrings updated to reflect the new contract.
  • Tests: the "claude skips the protocol override at init" test now asserts the opposite (call issued, applied=True); registry capability assertions flipped.

Behavioural note: an invalid/inaccessible acp_model previously silently succeeded on the default model; now the CLI accepts the set_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_model and check the model recorded in the CLI's transcript JSONL. With acp_model="claude-haiku-4-5" (script: one Conversation.run() turn over ACPAgent(acp_command=["npx","-y","@agentclientprotocol/claude-agent-acp@0.30.0"], acp_model="claude-haiku-4-5")):

# main (before):  current_model_id=claude-haiku-4-5  — but transcript records:
   1 "model":"claude-sonnet-4-6"        ← ran on the CLI default, override silently dropped
# this branch:    current_model_id=claude-haiku-4-5  — transcript records:
   2 "model":"claude-haiku-4-5-20251001" ← actually ran on the requested model

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.json mirrors supports_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

Variant Architectures Base Image Docs / Tags
java amd64, arm64 eclipse-temurin:17-jdk Link
python amd64, arm64 nikolaik/python-nodejs:python3.13-nodejs22-slim Link
golang amd64, arm64 golang:1.21-bookworm Link

Pull (multi-arch manifest)

# Each variant is a multi-arch manifest supporting both amd64 and arm64
docker pull ghcr.io/openhands/agent-server:d0d7e2e-python

Run

docker run -it --rm \
  -p 8000:8000 \
  --name agent-server-d0d7e2e-python \
  ghcr.io/openhands/agent-server:d0d7e2e-python

All tags pushed for this build

ghcr.io/openhands/agent-server:d0d7e2e-golang-amd64
ghcr.io/openhands/agent-server:d0d7e2ed740f353089c84c296c336afb76aa2dc7-golang-amd64
ghcr.io/openhands/agent-server:fix-acp-claude-initial-model-selection-golang-amd64
ghcr.io/openhands/agent-server:d0d7e2e-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:d0d7e2e-golang-arm64
ghcr.io/openhands/agent-server:d0d7e2ed740f353089c84c296c336afb76aa2dc7-golang-arm64
ghcr.io/openhands/agent-server:fix-acp-claude-initial-model-selection-golang-arm64
ghcr.io/openhands/agent-server:d0d7e2e-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:d0d7e2e-java-amd64
ghcr.io/openhands/agent-server:d0d7e2ed740f353089c84c296c336afb76aa2dc7-java-amd64
ghcr.io/openhands/agent-server:fix-acp-claude-initial-model-selection-java-amd64
ghcr.io/openhands/agent-server:d0d7e2e-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:d0d7e2e-java-arm64
ghcr.io/openhands/agent-server:d0d7e2ed740f353089c84c296c336afb76aa2dc7-java-arm64
ghcr.io/openhands/agent-server:fix-acp-claude-initial-model-selection-java-arm64
ghcr.io/openhands/agent-server:d0d7e2e-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:d0d7e2e-python-amd64
ghcr.io/openhands/agent-server:d0d7e2ed740f353089c84c296c336afb76aa2dc7-python-amd64
ghcr.io/openhands/agent-server:fix-acp-claude-initial-model-selection-python-amd64
ghcr.io/openhands/agent-server:d0d7e2e-nikolaik_s_python-nodejs_tag_python3.13-nodejs22-slim-amd64
ghcr.io/openhands/agent-server:d0d7e2e-python-arm64
ghcr.io/openhands/agent-server:d0d7e2ed740f353089c84c296c336afb76aa2dc7-python-arm64
ghcr.io/openhands/agent-server:fix-acp-claude-initial-model-selection-python-arm64
ghcr.io/openhands/agent-server:d0d7e2e-nikolaik_s_python-nodejs_tag_python3.13-nodejs22-slim-arm64
ghcr.io/openhands/agent-server:d0d7e2e-golang
ghcr.io/openhands/agent-server:d0d7e2ed740f353089c84c296c336afb76aa2dc7-golang
ghcr.io/openhands/agent-server:fix-acp-claude-initial-model-selection-golang
ghcr.io/openhands/agent-server:d0d7e2e-golang_tag_1.21-bookworm
ghcr.io/openhands/agent-server:d0d7e2e-java
ghcr.io/openhands/agent-server:d0d7e2ed740f353089c84c296c336afb76aa2dc7-java
ghcr.io/openhands/agent-server:fix-acp-claude-initial-model-selection-java
ghcr.io/openhands/agent-server:d0d7e2e-eclipse-temurin_tag_17-jdk
ghcr.io/openhands/agent-server:d0d7e2e-python
ghcr.io/openhands/agent-server:d0d7e2ed740f353089c84c296c336afb76aa2dc7-python
ghcr.io/openhands/agent-server:fix-acp-claude-initial-model-selection-python
ghcr.io/openhands/agent-server:d0d7e2e-nikolaik_s_python-nodejs_tag_python3.13-nodejs22-slim

About Multi-Architecture Support

  • Each variant tag (e.g., d0d7e2e-python) is a multi-arch manifest supporting both amd64 and arm64
  • Docker automatically pulls the correct architecture for your platform
  • Individual architecture tags (e.g., d0d7e2e-python-amd64) are also available if needed

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>
@github-actions

github-actions Bot commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor

Python API breakage checks — ✅ PASSED

Result: ✅ PASSED

Action log

@github-actions

github-actions Bot commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor

REST API breakage checks (OpenAPI) — ✅ PASSED

Result: ✅ PASSED

Action log

@github-actions

github-actions Bot commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-sdk/openhands/sdk/agent
   acp_agent.py114610191%760–762, 999–1000, 1043, 1045, 1049, 1053, 1079, 1142–1143, 1148, 1215, 1529, 1532–1533, 1550–1551, 1587, 1592, 1670, 1675, 2009–2010, 2294–2297, 2301–2303, 2306–2310, 2312, 2530, 2544–2545, 2548–2550, 2558, 2562, 2566–2567, 2573–2574, 2586–2587, 2590, 2624, 2628–2630, 2634–2635, 2667, 2751, 2938–2940, 2943–2944, 2984, 3126, 3130, 3138–3140, 3178–3179, 3182, 3190–3192, 3194, 3196, 3200, 3203, 3212–3214, 3216, 3252–3253, 3271–3274, 3277, 3281–3283, 3285, 3289–3290, 3498–3499
TOTAL30492843572% 

@simonrosenberg simonrosenberg self-assigned this Jun 11, 2026
@simonrosenberg simonrosenberg added the acp About ACP label Jun 11, 2026

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 all-hands-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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-workspace

Observed 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-final

Observed 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.py

The 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

@simonrosenberg
simonrosenberg merged commit f5c0020 into main Jun 11, 2026
59 of 61 checks passed
@simonrosenberg
simonrosenberg deleted the fix-acp-claude-initial-model-selection branch June 11, 2026 14:18
pengzhang-create pushed a commit to Pyromind-Dynamics/software-agent-sdk that referenced this pull request Aug 13, 2026
…claude-agent-acp ignores _meta) (OpenHands#3655)

Co-authored-by: Simon Rosenberg <simon@openhands.dev>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

acp About ACP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ACP claude-code initial model selection via session _meta is silently ignored by claude-agent-acp 0.30.0

3 participants