Repository navigation
feat(acp): discover an ACP agent's default and available models (and restore Gemini model handling) - #5579
Merged
Conversation
Add POST /api/acp/models: it starts the ACP server through the regular ACPAgent startup path in a throwaway session (same env, secret, file credential, auth and npx-cache handling as a conversation), reads back the server's own default model and model list, and shuts it down. Failures come back as the conversation cold-start codes (ACPAuthRequired, ...). Successful results are cached per command and credential values for five minutes. Also restore the two UNSTABLE model calls agent-client-protocol 0.12.1 dropped (the session/new `models` block and session/set_model). gemini-cli reports and switches models only through them, so since #5122 Gemini sessions listed no models and silently ignored the requested model. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
REST API breakage checks (OpenAPI) — ✅ PASSEDResult: ✅ PASSED |
Closed
1 of 17 tasks
…cp/models Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Coverage Report •
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Clients can now ask an ACP server for its models (POST /api/acp/models), so the curated `ACPProviderInfo.available_models` / `default_model` lists and `ACPModelOption` are deprecated in 1.54.0 and removed in 1.59.0. Reading them warns once that release is out; the TypeScript mirror marks them `@deprecated`. `OPENAI_CODEX_MODELS` (the native agent's ChatGPT-subscription models) no longer derives from the Codex ACP list and keeps its own constant. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
simonrosenberg
marked this pull request as ready for review
October 9, 2026 14:28
all-hands-bot
approved these changes
Oct 9, 2026
all-hands-bot
left a comment
Collaborator
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
Reviewed head 39c7ed822b2972fa0f556c0f5e7646762657016d. The endpoint, the client-ahead declaration, and the deprecations all check out. No blocking findings.
What I verified
POST /api/acp/models— the newacp_router.pyreuses the conversation-startsecretsshape (includingLookupSecretreferences) and the codex stored-login binding, returns errors in the body rather than as HTTP errors on launch/auth failure, and is explicitly 501 whenconversation_runtime == "docker". The cache key covers command/args/session-mode/isolate/file-secrets/resolved-secret-values, so new credentials re-probe (test_new_credentials_ask_the_server_again).- ACP 0.12 regression — worth calling out, since it is the subtle part of this PR. I installed
agent-client-protocol==0.12.1and confirmedClientSideConnection.set_session_modelis gone andNewSessionResponseno longer models amodelsblock. The 0.10.1 signature wasset_session_model(self, model_id, session_id, **kwargs), so the restored keyword-only override (set_session_model(*, model_id, session_id)) matches the existing call site. The pre-0.12 path therefore keeps working. - Deprecations —
ACPProviderInfo.available_models/default_modelare nowcompare=False, repr=Falseand warn via__getattribute__. Grepping the SDK and agent-server, the only internal reads of those names are the dataclass field defaults; the in-conversationACPSessionModelState.available_modelsis a different type and is untouched. MovingOPENAI_CODEX_MODELSto a literal inopenai.pykeeps the ChatGPT-subscription check self-contained. - Structured errors —
discover_acp_modelsmaps failures to the same cold-start codes (ACPAuthRequired/ACPStartupTimeout/ACPSpawnError/ACPInitError) and reuses the existing detail/redaction helpers; the probe directory is torn down infinally.
CI is green. Merging still needs the normal second approval on this repo.
Merged
3 of 6 tasks
10 tasks
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.
HUMAN:
I asked for an Agent Server endpoint that reports which models an ACP agent offers and uses by default, so Agent Canvas can stop hardcoding model lists, and for the registry's curated lists to be deprecated. The HTTP and Agent Canvas end-to-end runs below were done by Claude Code at my request on my laptop, with my own Claude Code and Codex logins.
AGENT:
Why
A client configuring an ACP agent cannot tell which models it offers or which one it uses by default until a conversation has started, so Agent Canvas shows a static, curated list from
ACP_PROVIDERS. That list is wrong whenever the catalogue depends on the user's credentials. Observed on a real machine:gpt-6-astra; 4 modelsgpt-5.5; 5 modelsdefault;default,opus[1m],claude-fable-5[1m],sonnet,haikuopus[1m]; 5 modelsanthropic/claude-opus-4-8; 15 modelsopencode/big-pickle; 11 / ~114 modelsauto; 6 modelsauto; 7 modelsWhile building this I found that Gemini model handling has been broken since #5122 (
agent-client-protocol0.10.1 → 0.12.1, Dependabot). 0.12 dropped the UNSTABLEmodelsblock fromNewSessionResponseand removedClientSideConnection.set_session_model. gemini-cli (0.46, and still the latest 0.63) reports and switches models only through those. So Gemini sessions listed no models, and_apply_acp_modelno-op'd the requested model while reporting it as applied.Summary
POST /api/acp/models(newacp_router.py) takesagent_settingsplus the samesecretsmap as a conversation start (LookupSecretreferences to stored secrets work). It returnsACPModelDiscovery:current_model_id(the server's own default),available_models,agent_name/agent_version,supports_runtime_model_switch, anderror(ACPAuthRequired/ACPStartupTimeout/ACPSpawnError/ACPInitError, in a 200 response).refresh: truebypasses the cache.conversation_runtime="docker").openhands.sdk.agent.acp_model_discovery.discover_acp_modelsruns the regularACPAgent.init_statein a throwaway session, so env assembly, secret injection, file credentials, auth-method selection and the npx cache behave exactly as in a conversation.acp_model, MCP servers and agent context, and removes its directory afterwards.LocalVersionedCredentialBindinga conversation uses, so a token refresh is written back rather than lost.@openhands/typescript-client:ACPClient.discoverModels()plus theACPModelDiscovery*types, withPOST /api/acp/modelsallow-listed as a client-ahead call in the endpoint audit until it ships in a release.ACPProviderInfo.available_models,ACPProviderInfo.default_modelandACPModelOptionare deprecated in 1.54.0 and removed in 1.59.0, so clients ask the server instead.reprof a provider don't. The TypeScript mirror marks them@deprecated.OPENAI_CODEX_MODELS(the native agent's ChatGPT-subscription models) was derived from the Codex ACP list; it now has its own constant with the same five ids.enterprise,default_web_client_config_injector.py) still reads both fields for its legacy frontend; it needs a follow-up before 1.59.0._ACPClientConnectionrestores the two dropped calls. It parses themodelsblock intoACPLegacySessionModels, ignoring a malformed block, and sendssession/set_model. This fixes the in-conversation Gemini picker and model selection too.ClientSideConnectionis@finalfor typing only, hence the targeted pyright ignore.REST API contract changes
Compared with base OpenAPI
69e26889401ffor public/api/**paths.Issue Number
Fixes #5578
How to Test
Unit tests (a real stdio ACP server fixture,
tests/sdk/agent/fake_acp_models_server.py, withconfigOptionsor legacymodelsreporting):The deprecation tests pin the version to 1.54.0: reading either field, or importing
ACPModelOptionfromopenhands.sdk/openhands.sdk.settings, warns, and other uses of a provider don't. Control: with the__getattribute__hook deleted, readingavailable_modelsemits no warning.check_sdk_api_breakage.py,check_deprecations.pyandcheck-acp-drift.pypass.Negative controls:
ClientSideConnectionswapped back in, the 3 legacy-path tests fail (themodelsblock is lost, an unknown requested model is reported as applied, and runtime switching does nothing).Live conformance suite (all 6 built-in providers, pinned CLIs, bogus keys). The Gemini exemption from the "session advertises a model mechanism" check is removed, and the model-acceptance probe now really sends
session/set_modelfor each curated Gemini id:End to end over HTTP against a native agent-server built from this branch (real local logins for claude-code and codex):
Only the shared
npm-cacheremained in the conversations directory afterwards.End to end through Agent Canvas (Canvas branch
acp-model-lookup, stacked on OpenHands/OpenHands#18131;dev:minimalagainst this branch, my real laptop logins):Default (recommended) (agent default) | Opus (1M context) | Fable | Sonnet | Haiku. A conversation launched onclaude-fable-5[1m]and replied; a switch from the chat picker tohaikutook effect and the next turn repliedGPT-6-Astra (agent default) | GPT-5.6-Sol | GPT-5.6-Terra | GPT-5.6-Luna. A conversation launched ongpt-5.6-terraand replied; a switch togpt-5.6-lunatook effect and the next turn repliedACPAuthRequired: Google no longer accepts that login, and Canvas showed the sign-in hintGemini against the live CLI (0.46.0, bogus
GEMINI_API_KEY):session/newnow yieldsautoplus 6 models.acp_model="gemini-2.5-pro"is applied, and a runtime switch togemini-3.5-flashreports the new model.session/set_modelreturns{}, whilesession/set_model_nonexistentreturns "Method not found".Other suites:
tests/sdk/agent,tests/sdk/settings, andtests/agent_serverpass apart from failures that also occur onmainon this machine (canvas-extension sandbox tests and one tmux cleanup test).Type
Notes
acp-model-lookup) adds the pre-conversation lookup once a release shipsACPClient.discoverModels._select_auth_methodstill prefers~/.gemini/oauth_creds.json(read from the host HOME even with isolation on) overGEMINI_API_KEY, and Google no longer accepts that consumer login. This is the Phase 0 item tracked in [Feature]: Add Antigravity CLI as a new, additive ACP provider (alongside gemini-cli) #4624.🤖 Generated with Claude Code
🐳 Agent Server images for this PR — GHCR package, pull/run commands, and all pushed tags (click to expand)
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdkpython-node-runtimepython-node-runtimepython-node-runtimegolang: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:39c7ed8-pythonRun
All tags pushed for this build
About Multi-Architecture Support
39c7ed8-python) is a multi-arch manifest supporting both amd64 and arm6439c7ed8-python-amd64) are also available if needed