Repository navigation
feat(acp): prompt-free auth-status probe + GET /acp/auth-status - #3452
simonrosenberg wants to merge 9 commits into
Conversation
Phase 1 SDK side of OpenHands/agent-canvas#964 — server-side detection of
an existing ACP subscription/login so onboarding can show "✓ already
logged in" instead of unconditionally asking for an API key.
Detection rides the ACP protocol handshake rather than sniffing
credentials per-OS/topology: `session/new` succeeding means the CLI found
working credentials (subscription *or* API key); an `auth_required` error
(JSON-RPC -32000) means it is not logged in. No prompt is sent, so no model
tokens are spent. Because the probe runs inside the agent-server, it reports
the truth for wherever the agent actually runs.
SDK (openhands-sdk):
- Factor the spawn + initialize/authenticate handshake out of
`_start_acp_server` into shared helpers (`_spawn_acp_connection`,
`_acp_initialize`, `_apply_env_conflict_rules`).
- Add `ACPAgent.probe_auth(command, *, args, env, cwd, timeout)`: spawn →
initialize → best-effort authenticate → session/new → classify → tear
down. Returns `ACPAuthProbeResult(authenticated, auth_methods,
agent_name, agent_version)`. The handshake is timeout-bounded and teardown
is guaranteed on the same event loop, so a wedged subprocess can't leak.
agent-server (openhands-agent-server):
- Add `GET /acp/auth-status?server=<key>` (acp_auth_router): resolves the
command/env for a provider key from ACP_PROVIDERS + persisted settings +
stored global secrets, runs probe_auth in a threadpool, and returns
{server, status: authenticated|unauthenticated|unknown, auth_methods,
agent_name, agent_version}. A probe that can't run is reported as
`unknown` (200), so the canvas falls back to the API-key fields rather
than falsely claiming "not logged in".
Tests: probe_auth classification/teardown/timeout (transport mocked) and
endpoint authenticated/unauthenticated/unknown + command/secret resolution.
Refs OpenHands/agent-canvas#964
Co-Authored-By: Claude Opus 4.8 (1M context) <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: PASS WITH ISSUES
The new ACP auth-status endpoint works end-to-end for the claimed authenticated, unauthenticated, unknown, and validation paths; I found one minor direct-SDK teardown warning.
Does this PR achieve its stated goal?
Yes. On main, GET /api/acp/auth-status?server=claude-code returned 404 Not Found; on this PR branch, the same user-facing API exists and returns the expected status payload. I exercised the endpoint against the real claude-code ACP provider available in this environment, plus a local ACP subprocess that simulates both session/new success and auth_required (-32000), and verified no prompt method was sent.
| Phase | Result |
|---|---|
| Environment Setup | ✅ make build completed successfully |
| CI Status | agent-server-tests failing, several build checks still pending, and many checks passing |
| Functional Verification |
Functional Verification
Test 1: Endpoint is newly available and probes a real provider
Step 1 — Establish baseline on main:
Ran the agent server from main on port 8791 and requested the new route:
GET /api/acp/auth-status?server=claude-code
HTTP/1.1 404 Not Found
{"detail":"Not Found"}This confirms the endpoint did not exist before this PR.
Step 2 — Apply the PR branch:
Checked out feat-acp-auth-status-probe at d5a15b45605c4701ec4b729570153ef829ef5b06, ran make build, and started the agent server on port 8790.
Step 3 — Re-run with the PR:
GET /api/acp/auth-status?server=claude-code
HTTP/1.1 200 OK
{"server":"claude-code","status":"authenticated","auth_methods":[],"agent_name":"@agentclientprotocol/claude-agent-acp","agent_version":"0.39.0","detail":null}This shows the new endpoint runs the actual ACP handshake and reports the already-authenticated provider in this environment.
Test 2: Endpoint maps ACP handshake outcomes correctly without prompts
Configured persisted ACP settings through PATCH /api/settings to launch a local ACP subprocess, then called the endpoint twice:
GET /api/acp/auth-status?server=claude-code
HTTP/1.1 200 OK
{"server":"claude-code","status":"authenticated","auth_methods":[],"agent_name":"qa-fake-acp","agent_version":"1.0","detail":null}
GET /api/acp/auth-status?server=claude-code
HTTP/1.1 200 OK
{"server":"claude-code","status":"unauthenticated","auth_methods":[],"agent_name":"qa-fake-acp","agent_version":"1.0","detail":null}The fake ACP subprocess recorded exactly these JSON-RPC methods:
authenticated:initialize
authenticated:session/new
unauthenticated:initialize
unauthenticated:session/new
This confirms the endpoint classifies session/new success as authenticated, auth_required as unauthenticated, and does not send any prompt method.
Test 3: Validation and fallback behavior
GET /api/acp/auth-status
HTTP/1.1 422 Unprocessable Content
{"detail":[{"type":"missing","loc":["query","server"],"msg":"Field required","input":null}]}
GET /api/acp/auth-status?server=bogus
HTTP/1.1 422 Unprocessable Content
{"detail":"Unknown ACP server 'bogus'. Known providers: claude-code, codex, gemini-cli."}After configuring acp_command to /tmp/does-not-exist-acp through PATCH /api/settings:
GET /api/acp/auth-status?server=claude-code
HTTP/1.1 200 OK
{"server":"claude-code","status":"unknown","auth_methods":[],"agent_name":"","agent_version":"","detail":"FileNotFoundError: [Errno 2] No such file or directory: '/tmp/does-not-exist-acp'"}This matches the PR goal of returning unknown instead of a hard HTTP failure when the probe cannot run.
Test 4: Direct SDK probe behavior
Ran ACPAgent.probe_auth() against the same local ACP subprocess:
authenticated {'authenticated': True, 'auth_methods': [], 'agent_name': 'qa-fake-acp', 'agent_version': '1.0'}
unauthenticated {'authenticated': False, 'auth_methods': [], 'agent_name': 'qa-fake-acp', 'agent_version': '1.0'}
pgrep -af qa_fake_acp_server.py showed no remaining fake ACP subprocesses afterward.
Issues Found
- 🟡 Minor: Direct standalone
ACPAgent.probe_auth()calls returned the correct values and did not leak the fake subprocess, but emittedasynciowarnings during teardown (Loop <_UnixSelectorEventLoop ...> that handles pid ... is closed). The agent-server endpoint path did not emit this warning in my run, so this is not blocking.
This review was created by an AI agent (OpenHands) on behalf of the user.
Verdict: PASS WITH ISSUES
Address QA review feedback: _teardown_acp_connection signalled terminate()/kill() but never awaited process.wait(), so standalone SDK/CLI callers saw a noisy "Loop ... that handles pid ... is closed" asyncio child-watcher warning once their event loop closed. Reap the subprocess (bounded by _ACP_TEARDOWN_TIMEOUT) after signalling it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
✅ Review complete. This review was performed through OpenHands Cloud Automation. You can log in and view the conversation here. |
all-hands-bot
left a comment
There was a problem hiding this comment.
The protocol-handshake-as-probe design is the right architecture here: it avoids brittle per-OS credential sniffing and reports the truth for wherever the agent server actually runs. The refactoring of shared ACP helpers (_spawn_acp_connection, _acp_initialize, _apply_env_conflict_rules) is clean and reduces duplication well. Test coverage is thorough. A couple of targeted issues below.
Rate-limiting note: GET /acp/auth-status spins up an ACP subprocess (potentially npx -y …, a cold run can take 10–30 s) and holds it for up to _ACP_AUTH_PROBE_TIMEOUT (60 s default). There is no per-client concurrency cap in this PR. For the onboarding canvas flow—a single user, a single request—this is fine. If the endpoint is ever exposed more broadly, concurrent flood of probe requests could exhaust process slots. Worth a comment or a follow-up issue tracking that.
This review was generated by an AI agent (OpenHands) on behalf of the user through OpenHands Automation. View conversation
all-hands-bot
left a comment
There was a problem hiding this comment.
🟡 QA Report: PARTIAL
I verified the new ACP auth-status endpoint and SDK probe end-to-end with a real subprocess-backed ACP protocol shim; real vendor subscription credential detection could not be exercised in this environment.
Does this PR achieve its stated goal?
Yes for the SDK/agent-server behavior I could exercise; not fully verified against real Claude/Codex/Gemini credential stores. The PR set out to add a prompt-free session/new auth-status probe and expose it through GET /api/acp/auth-status?server=...; running the actual FastAPI server showed the route is new versus main, returns authenticated, unauthenticated, and unknown correctly, and uses initialize + optional authenticate + session/new without any prompt call. I could not verify an actual third-party subscription login because this QA environment does not have Claude/Codex/Gemini ACP credentials.
| Phase | Result |
|---|---|
| Environment Setup | ✅ make build completed successfully. |
| CI Status | 🟡 Observed 19 successful, 3 skipped, 9 pending, 0 failing checks at review time. |
| Functional Verification | 🟡 Core endpoint/probe behavior verified with real subprocess and HTTP requests; real vendor login stores unavailable. |
Functional Verification
Test 1: Baseline route absence on main, new route present on PR
Step 1 — Establish baseline without the feature:
Started the FastAPI app from a temporary origin/main worktree and requested the new route:
PYTHONPATH=/tmp/qa-main-worktree/openhands-agent-server:/tmp/qa-main-worktree/openhands-sdk:/tmp/qa-main-worktree/openhands-tools:/tmp/qa-main-worktree/openhands-workspace \
OH_PERSISTENCE_DIR=/tmp/qa-base-persist... QA_SERVER_PORT=8122 \
.venv/bin/python /tmp/run_agent_server.py &
curl -i 'http://127.0.0.1:8122/api/acp/auth-status?server=claude-code'Observed:
HTTP/1.1 404 Not Found
{"detail":"Not Found"}This confirms the endpoint did not exist on main.
Step 2 — Apply the PR changes:
Used the checked-out PR head b273cc14b5c80e85375312bb4d0f44913e32ca91, persisted ACPAgentSettings for claude-code with a real executable ACP shim, and started the FastAPI app on port 8123.
Step 3 — Re-run with the feature in place:
curl -i 'http://127.0.0.1:8123/api/acp/auth-status?server=claude-code'Observed:
HTTP/1.1 200 OK
{"server":"claude-code","status":"authenticated","auth_methods":["openai-api-key"],"agent_name":"fake-acp","agent_version":"1.0","detail":null}The fake ACP subprocess log showed only handshake/probe calls:
method="initialize"
method="authenticate"
method="session/new" params.cwd="/tmp/acp-auth-probe-..."
This verifies the PR adds the HTTP route and performs a prompt-free ACP handshake in a throwaway probe cwd.
Test 2: Endpoint status classification
With the PR server still running, I switched the persisted fake ACP mode and made real HTTP requests:
curl -i 'http://127.0.0.1:8123/api/acp/auth-status?server=claude-code'Observed for session/new returning auth_required:
HTTP/1.1 200 OK
{"server":"claude-code","status":"unauthenticated","auth_methods":["openai-api-key"],"agent_name":"fake-acp","agent_version":"1.0","detail":null}Observed for non-auth protocol error:
HTTP/1.1 200 OK
{"server":"claude-code","status":"unknown","auth_methods":[],"agent_name":"","agent_version":"","detail":"RequestError: Internal error"}Observed invalid inputs:
HTTP/1.1 422 Unprocessable Content
{"detail":"Unknown ACP server 'bogus'. Known providers: claude-code, codex, gemini-cli."}
HTTP/1.1 422 Unprocessable Content
{"detail":[{"type":"missing","loc":["query","server"],"msg":"Field required","input":null}]}This verifies the endpoint maps authenticated/unauthenticated/unknown and invalid server cases as described.
Test 3: SDK ACPAgent.probe_auth direct subprocess behavior
Ran the SDK method directly against the same executable ACP shim:
uv run python - <<'PY'
# calls ACPAgent.probe_auth(["/tmp/fake_acp_server.py"], env=..., timeout=1.0)
# with modes: authenticated, unauthenticated, protocol_error, hang
PYObserved:
mode=authenticated -> {"authenticated": true, "auth_methods": ["openai-api-key"], "agent_name": "fake-acp", "agent_version": "1.0"}
mode=unauthenticated -> {"authenticated": false, "auth_methods": ["openai-api-key"], "agent_name": "fake-acp", "agent_version": "1.0"}
mode=protocol_error -> RequestError: Internal error
mode=hang -> TimeoutError
The subprocess log for successful and unauthenticated cases contained initialize, authenticate, and session/new, with no session/prompt, confirming the probe does not send a prompt.
Unable to Verify
I could not verify detection against actual Claude Code, Codex, or Gemini CLI subscription/API-key credential stores because this QA environment does not have those provider logins or real ACP credentials available. The protocol-level behavior and agent-server API were verified using a real subprocess speaking ACP JSON-RPC, but not against live vendor CLIs.
Issues Found
None.
Final verdict: PARTIAL — the implemented SDK and API behavior works in functional QA, but live third-party credential detection remains unverified due to unavailable credentials.
This QA review was created by an AI agent (OpenHands) on behalf of the user.
- Cancel the stdout filter task in probe teardown. _spawn_acp_connection now returns the reader task; the probe cancels it (it only ends on stdout EOF, so a short-lived caller leaked it as a destroyed-pending task). Use get_running_loop() instead of get_event_loop(). - Real graceful subprocess teardown: SIGTERM -> bounded wait/reap -> escalate to SIGKILL -> reap, instead of firing terminate()+kill() back-to-back with no wait. - Classify auth_required from authenticate() (not just session/new) as unauthenticated. Wrap the whole probe handshake in the auth_required guard so codex-style "auth on authenticate" reports unauthenticated rather than bubbling up to unknown. Fix the "best-effort authenticate" wording and document the -32000 reliability assumption. - Bound subprocess spawn under the probe timeout (was outside it). - Scrub stored secret values from the router's 'unknown' detail before truncating, in case a provider error echoes a key. - Document the env precedence divergence (stored secrets override the process env in the probe; a real run fills them missing). Tests: graceful-vs-escalate teardown, reader-task cancellation, authenticate->unauthenticated, and detail secret-scrubbing. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Addressed the auth-probe review feedback in bfce9f3:
Added tests for graceful-vs-escalate teardown, reader-task cancellation, authenticate→unauthenticated, and detail secret-scrubbing. Two items need follow-up that code alone can't close: real-CLI validation of the |
|
✅ Review complete. This review was performed through OpenHands Cloud Automation. You can log in and view the conversation here. |
The router relied on probe_auth's default timeout, so a slow/hung ACP CLI could pin a FastAPI threadpool worker for the full default. Forward an explicit, env-configurable ceiling (_PROBE_TIMEOUT_SECONDS, default 60s) and document why the generous default is intentional (cold ``npx -y`` first-run download). Addresses PR review feedback. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
all-hands-bot
left a comment
There was a problem hiding this comment.
The protocol-handshake-as-probe design is the right architecture: OS- and topology-agnostic, zero model tokens spent, and the auth_required (-32000) signal is exactly what the ACP protocol offers as a reliable logged-in indicator. The factoring of _spawn_acp_connection, _acp_initialize, and _apply_env_conflict_rules into shared module-level helpers is clean — both _start_acp_server and probe_auth now share identical subprocess-spawn and handshake paths, so fixes in one apply to the other automatically.
All previously flagged issues have been addressed in follow-up commits: asyncio.get_running_loop() is used (no deprecation warning), _teardown_acp_connection does a proper SIGTERM → bounded process.wait() → escalate to SIGKILL sequence, and the router explicitly forwards timeout=_PROBE_TIMEOUT_SECONDS to bound FastAPI threadpool workers.
Test coverage is thorough. TestACPProbeAuth covers the full classification matrix (session/new success, auth_required from session/new, auth_required from explicit authenticate(), non-auth error propagation, spawn failure, and timeout). TestTeardownACPConnection directly unit-tests the SIGTERM/SIGKILL escalation logic. test_acp_auth_router.py covers the HTTP layer end-to-end including command resolution from registry vs. persisted settings, stored-secret folding, settings-precedence override, and secret scrubbing in the unknown detail.
Known limitation carried forward (flagged by an earlier review, still unresolved): GET /acp/auth-status has no per-client concurrency cap. Each call may launch an ACP subprocess and hold a FastAPI threadpool worker for up to 60 s. For the targeted onboarding canvas use-case (single user, infrequent call) this is fine, but worth tracking as a follow-up if the endpoint gets broader exposure.
One small env-constant duplication and one minor test-coverage gap noted inline.
This review was generated by an AI agent (OpenHands) on behalf of the user through OpenHands Automation. View conversation
all-hands-bot
left a comment
There was a problem hiding this comment.
⚠️ QA Report: PASS WITH ISSUES
The new auth-status API and SDK probe work end-to-end for the main onboarding signal, with one metadata-loss issue on the authenticate → auth_required path.
Does this PR achieve its stated goal?
Yes, for the primary goal. I started the agent-server and made real HTTP requests to GET /api/acp/auth-status; the endpoint did not exist on main, exists on this PR, returns 422 for invalid input, and returns authenticated / unauthenticated / unknown from actual ACP handshakes without sending session/prompt. I also called ACPAgent.probe_auth() against real subprocess ACP stubs and observed only initialize, optional authenticate, and session/new calls.
| Phase | Result |
|---|---|
| Environment Setup | ✅ make build completed successfully |
| CI Status | 🟡 20 successful, 7 pending, 0 failing at observation time |
| Functional Verification | authenticate returns auth_required |
Functional Verification
Test 1: Baseline vs PR HTTP endpoint
Step 1 — Establish baseline on origin/main:
Ran uv run python -m openhands.agent_server --host 127.0.0.1 --port 8765 and queried:
GET /api/acp/auth-status?server=claude-code
HTTP/1.1 404 Not Found
{"detail":"Not Found"}
Also ran a direct SDK import check:
has_probe_auth= False
probe_auth_error= AttributeError: probe_auth
This confirms the endpoint and SDK probe are new behavior in this PR.
Step 2 — Apply the PR changes:
Checked out bfce9f319cbc7861e8eff00887b4a1e4d4a6ce9d.
Step 3 — Re-run with the PR:
Started uv run python -m openhands.agent_server --host 127.0.0.1 --port 8766 and queried:
GET /api/acp/auth-status?server=bogus
HTTP/1.1 422 Unprocessable Content
{"detail":"Unknown ACP server 'bogus'. Known providers: claude-code, codex, gemini-cli."}
GET /api/acp/auth-status
HTTP/1.1 422 Unprocessable Content
{"detail":[{"type":"missing","loc":["query","server"],"msg":"Field required","input":null}]}
GET /api/acp/auth-status?server=claude-code
HTTP/1.1 200 OK
{"server":"claude-code","status":"authenticated","auth_methods":[],"agent_name":"@agentclientprotocol/claude-agent-acp","agent_version":"0.39.0","detail":null}
This shows the new endpoint is mounted, validates user input, and can perform a real provider handshake from the running agent-server environment.
Test 2: SDK probe classification with real subprocesses
Step 1 — Baseline:
On main, ACPAgent.probe_auth was absent as shown above.
Step 2 — Apply the PR changes:
Used a temporary ACP subprocess that speaks JSON-RPC over stdio and logs every received ACP method.
Step 3 — Run the SDK probe:
Ran ACPAgent.probe_auth(['python', '/tmp/qa_fake_acp_server.py'], ...) for success and auth_required modes:
success {'authenticated': True, 'auth_methods': [], 'agent_name': 'fake-acp', 'agent_version': '1.0.0'}
auth_required {'authenticated': False, 'auth_methods': [], 'agent_name': 'fake-acp', 'agent_version': '1.0.0'}
method_log:
initialize
session/new
initialize
session/new
This confirms the SDK probe classifies session/new success vs JSON-RPC -32000 correctly and does not send a prompt.
Test 3: Endpoint status mapping, no-prompt behavior, and redaction
Step 1 — Configure the running server like a user would:
Patched /api/settings to use an ACP agent command pointing at the fake ACP subprocess, then called /api/acp/auth-status?server=claude-code.
Step 2 — Verify unauthenticated and authenticated states:
fake auth_required response:
{"server":"claude-code","status":"unauthenticated","auth_methods":[],"agent_name":"fake-acp","agent_version":"1.0.0","detail":null}
method log: initialize, session/new
fake success response:
{"server":"claude-code","status":"authenticated","auth_methods":[],"agent_name":"fake-acp","agent_version":"1.0.0","detail":null}
method log: initialize, session/new
This confirms the endpoint maps probe results correctly and remains prompt-free.
Step 3 — Verify unknown failures redact stored secrets:
Stored a fake global secret through PUT /api/settings/secrets, configured the fake ACP subprocess to echo it in a non-auth error, then queried the endpoint:
auth_status_http 200
auth_status_body {"server":"claude-code","status":"unknown","auth_methods":[],"agent_name":"","agent_version":"","detail":"RequestError: rejected key ***"}
method_log
initialize
session/new
This confirms failed probes return unknown with HTTP 200 and redact the stored secret value from detail.
Test 4: Authenticate-time auth_required edge case
Configured the fake ACP subprocess to advertise an API-key auth method from initialize, then return JSON-RPC -32000 from authenticate:
auth_status_http 200
auth_status_body {"server":"claude-code","status":"unauthenticated","auth_methods":[],"agent_name":"","agent_version":"","detail":null}
method_log
initialize
authenticate
This confirms the status classification works, but the initialized authMethods and agentInfo are lost on this path.
Issues Found
- 🟠 Issue: When
auth_requiredis raised byauthenticaterather thansession/new, the endpoint still returns the correctstatus: "unauthenticated", but dropsauth_methods,agent_name, andagent_versioneven thoughinitializealready provided them. See inline comment.
This review was created by an AI agent (OpenHands) on behalf of the user.
Bot review (validated against a real ACP subprocess) caught that the codex-style authenticate->-32000 path returned status=unauthenticated but with empty agent_name/agent_version/auth_methods: wrapping _acp_initialize in the auth_required guard meant an auth failure discarded the metadata learned at initialize. Split _acp_initialize (initialize only, returns the discovered name/version + advertised auth methods) from a new _acp_authenticate. The probe now captures that metadata before the guarded authenticate + session/new, so the not-logged-in result still reports the agent identity and offered methods. _start_acp_server calls the two in sequence. Also assert teardown runs on the spawn/initialize failure path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
✅ Review complete. This review was performed through OpenHands Cloud Automation. You can log in and view the conversation here. |
all-hands-bot
left a comment
There was a problem hiding this comment.
Review: feat(acp): prompt-free auth-status probe + GET /acp/auth-status
This is a clean, well-structured implementation. The protocol-handshake approach to auth detection — instead of per-OS credential sniffing — is the right design: it stays topology-agnostic and zero-token. The extraction of _spawn_acp_connection, _acp_initialize, and _acp_authenticate as shared helpers also improves DRY-ness and makes both the live path and the probe path auditable at a glance.
A few issues worth addressing below, ranging from one silent-leak risk down to minor cleanups.
Env precedence note (no change needed, just flagging): probe_auth documents a known divergence — stored secrets passed through env override os.environ, while in a real conversation os.environ wins for registry/agent-context secrets. This is a real edge case (a user with ANTHROPIC_API_KEY set in both process env and stored settings could see probe-authenticated / conversation-unauthenticated). The comment is clear; just worth keeping in mind if future false-positive reports surface.
This review was generated by an AI agent (OpenHands) on behalf of the user through OpenHands Automation. View conversation
all-hands-bot
left a comment
There was a problem hiding this comment.
❌ QA Report: FAIL
The new /api/acp/auth-status endpoint is present and can return a real Claude ACP probe result, but it falsely reports authenticated in an isolated environment where Claude's own diagnostic says there is no OAuth token or subscriber auth.
Does this PR achieve its stated goal?
No. The PR's goal is to let onboarding accurately show “already logged in” when an ACP provider is authenticated, using initialize + session/new as the signal. I verified the new endpoint exists and returns 200 for claude-code, but when I started the PR server with an empty HOME and nearly empty environment, /api/acp/auth-status?server=claude-code still returned status: "authenticated"; Claude Code doctor in that same environment reported ✗ claude.ai OAuth token present and ✗ claude.ai subscriber auth active. That means the feature can show the “already logged in” banner to users who are not logged in, so the primary goal is not met.
| Phase | Result |
|---|---|
| Environment Setup | ✅ make build completed; base and PR servers started locally with agent-server |
| CI Status | 🟡 27 success, 3 skipped, 4 in progress at review time; no failed checks observed |
| Functional Verification | ❌ Endpoint exists, but empty-auth real-user scenario returns a false authenticated result |
Functional Verification
Test 1: Endpoint availability before/after
Step 1 — Establish baseline on origin/main:
Ran a base-branch server on port 18080, then:
GET /api/acp/auth-status?server=claude-code
HTTP/1.1 404 Not Found
{"detail":"Not Found"}This confirms the route did not exist on the base branch.
Step 2 — Apply the PR's changes:
Checked out the PR commit e81445483b5f047d902663f9424a3e6b9337510f, bootstrapped with make build, and started agent-server on port 18081.
Step 3 — Re-run with the PR:
GET /api/acp/auth-status?server=claude-code
HTTP/1.1 200 OK
{"server":"claude-code","status":"authenticated","auth_methods":[],"agent_name":"@agentclientprotocol/claude-agent-acp","agent_version":"0.39.0","detail":null}This confirms the new endpoint is wired into the running API and can execute a real Claude ACP handshake.
Test 2: Request validation
With the PR server running:
GET /api/acp/auth-status
HTTP/1.1 422 Unprocessable Content
{"detail":[{"type":"missing","loc":["query","server"],"msg":"Field required","input":null}]}
GET /api/acp/auth-status?server=bogus
HTTP/1.1 422 Unprocessable Content
{"detail":"Unknown ACP server 'bogus'. Known providers: claude-code, codex, gemini-cli."}This confirms missing and unknown provider inputs are rejected as described.
Test 3: Empty-auth Claude environment false positive
Step 1 — Establish the environment has no Claude subscription login:
Ran Claude Code's own diagnostic with a nearly empty environment and isolated home:
env -i PATH="$PATH" HOME=/tmp/oh-empty-home2 XDG_CONFIG_HOME=/tmp/oh-empty-home2/.config npx -y @anthropic-ai/claude-code doctor
Remote Control
└ ✗ claude.ai OAuth token present
└ ✗ claude.ai subscriber auth active
└ ✗ OAuth token has user:profile scope
└ Remote Control requires a claude.ai subscription. Run `claude auth login` to sign in with your claude.ai account.
I also checked /tmp/oh-empty-home2/.claude.json; it contained only non-auth config keys (firstStartTime, migrationVersion, seenNotifications, userID, etc.), with no token/key/auth/credential/session-looking top-level keys.
Step 2 — Apply the PR's endpoint in the same empty-auth environment:
Started the PR agent-server with:
env -i PATH="$PATH" HOME=/tmp/oh-empty-home2 XDG_CONFIG_HOME=/tmp/oh-empty-home2/.config OPENHANDS_SUPPRESS_BANNER=1 OH_PERSISTENCE_DIR=/tmp/oh-qa-pr-empty-persist ACP_AUTH_PROBE_TIMEOUT=30 ./.venv/bin/agent-server --host 127.0.0.1 --port 18082Step 3 — Query the endpoint:
GET /api/acp/auth-status?server=claude-code
HTTP/1.1 200 OK
{"server":"claude-code","status":"authenticated","auth_methods":[],"agent_name":"@agentclientprotocol/claude-agent-acp","agent_version":"0.39.0","detail":null}This contradicts Claude's own diagnostic in the same isolated environment and demonstrates the PR's session/new succeeded => authenticated signal is a false positive for the real Claude ACP CLI.
Test 4: SDK probe API directly
Called the new SDK API directly with the real provider command:
command= ['npx', '-y', '@agentclientprotocol/claude-agent-acp']
{'authenticated': True, 'auth_methods': [], 'agent_name': '@agentclientprotocol/claude-agent-acp', 'agent_version': '0.39.0'}
This matches the endpoint behavior and shows the false-positive signal originates in the shared ACPAgent.probe_auth path.
Issues Found
- 🔴 Blocker: In a real empty-auth Claude Code environment, the probe and endpoint return
authenticatedeven though Claude Code reports no OAuth token and no subscriber auth. This defeats the onboarding goal because users can be told they are already logged in when they are not.
Final verdict: FAIL.
This QA review was created by an AI agent (OpenHands) on behalf of the user.
Ran the probe against the real gemini-cli 0.43.0 in both states: - logged out (no API key, empty HOME so no oauth_creds.json): session/new returned -32000 auth_required → authenticated=False (~12s) - logged in (real OAuth creds): authenticate(oauth-personal) + session/new succeeded → authenticated=True (~16s) So the -32000 contract holds for gemini too; update the reliability caveat to reflect that claude-code and gemini-cli are confirmed against real CLIs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Closed the gemini real-CLI validation gapRan
Logged-out trace: No hang (the concern was gemini's OAuth-first flow might block instead of returning So the |
|
✅ Review complete. This review was performed through OpenHands Cloud Automation. You can log in and view the conversation here. |
all-hands-bot
left a comment
There was a problem hiding this comment.
Review: feat(acp): prompt-free auth-status probe + GET /acp/auth-status
This is a well-architected, thoughtfully implemented feature. Using the ACP protocol handshake (initialize + session/new) as the authentication signal — rather than sniffing credential files per-OS/topology — is exactly the right design: it stays topology-agnostic, spends zero tokens, and reports truth for the environment where the agent actually runs.
The extraction of _spawn_acp_connection, _acp_initialize, _acp_authenticate, and _apply_env_conflict_rules into shared module-level helpers is clean and eliminates the previous duplication between _start_acp_server and the new probe_auth. Test coverage is thorough across both test_acp_agent.py and test_acp_auth_router.py, including secret scrubbing, teardown verification, precedence edge cases, and the authenticate → auth_required classification fix.
Several issues from prior reviews were correctly addressed (graceful SIGTERM → wait → SIGKILL escalation, asyncio.get_running_loop(), timeout forwarding, metadata preservation on authenticate → auth_required). The following remain open:
Open concerns (from prior reviews, not yet resolved)
-
Authentication reliability (critical) — The QA bot's finding at
acp_agent.pyline ~1880 is the most important unresolved issue: in an isolated environment without real Claude credentials,session/newsucceeded and the probe returnedauthenticated: true. The PR description and docstring acknowledge this as a known caveat, but a false positive here would show the onboarding "✓ already logged in" banner to users who aren't actually logged in. This needs an explicit author response — either confirmation that this was a QA environment artifact, a fix, or a documented rationale for why the false-positive rate is acceptable for the onboarding use case. -
Thread-pool saturation —
GET /acp/auth-statuscan hold a FastAPI threadpool worker for up to_PROBE_TIMEOUT_SECONDS(60 s, or longer on coldnpx -ystarts) with no concurrency guard or per-server in-flight limit. A burst of concurrent onboarding requests could exhaust the default threadpool and stall unrelated server operations. Worth addressing before this endpoint is in production traffic. -
Type annotation —
_spawn_acp_connection's return type usesAnyfor the process;asyncio.subprocess.Processis available and would strengthen static analysis coverage. -
Dead-code initializations in
_handshake—agent_name = "",agent_version = "", andauth_method_ids = []are assigned default values immediately before_acp_initialize(conn)overwrites them unconditionally. Since_acp_initializeis called outside thetry/except, these defaults are never read; they can be removed. -
Silent abandonment after SIGKILL failure — In
_teardown_acp_connection, when SIGKILL also fails to reap the process, the loop exits with only adebuglog and the subprocess is silently abandoned. Escalating towarningwould make this condition observable in production.
New observation
Env precedence asymmetry: get_acp_auth_status builds the probe env as stored_secrets → acp_settings_env, and probe_auth then lays this on top of os.environ — so stored secrets and settings override the process environment in the probe. In a real conversation, stored secrets and agent_context secrets are applied fill-missing (process env wins). This means a user whose stored API key is valid but whose server process env has a different (invalid or absent) key will see the probe report authenticated while the actual conversation fails. The code already documents this divergence in comments; it's worth a conscious decision on whether this precedence direction matches the intended onboarding UX, especially since the onboarding goal is to detect if a real conversation will work.
Overall: Conditional approval. Items 3–5 and the env precedence note are all tractable fixes or documented trade-offs. Item 2 (thread-pool saturation) should be addressed before production. Item 1 (authentication reliability) needs an explicit response from the author — it's the foundational correctness question for the feature's stated goal.
This review was generated by an AI agent (OpenHands) on behalf of the user through OpenHands Automation. View conversation
…3452) 🔴 Critical from QA, confirmed against the real pinned CLIs: claude-agent-acp 0.39.0 accepts session/new without validating credentials (auth is enforced at prompt time), so the probe returned authenticated=True for a logged-out user — the exact false "already logged in" this feature is meant to prevent. codex-acp and gemini-cli DO gate (verified: -32000 logged out, success logged in). Option 1 (safe fallback): add ACPProviderInfo.supports_auth_status_probe (default True; claude-code=False). GET /acp/auth-status short-circuits to 'unknown' for providers that opt out — no subprocess spawned — so the canvas shows the API-key fields instead of a false banner. Out-of-band Claude credential detection is tracked as a follow-up (agent-canvas#964). Also addresses review feedback: - import the SDK's _ACP_AUTH_PROBE_TIMEOUT instead of a duplicate router constant (single source of truth) - tighten _spawn_acp_connection's return type (Process, not Any) - log a warning if teardown can't reap the subprocess after SIGTERM+SIGKILL instead of silently abandoning it - drop dead default-inits in the probe handshake Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
✅ Review complete. This review was performed through OpenHands Cloud Automation. You can log in and view the conversation here. |
all-hands-bot
left a comment
There was a problem hiding this comment.
Overall
Solid implementation. The probe-via-handshake approach is the right call: it avoids credential-path sniffing per OS/topology and naturally reports the truth for whatever deployment topology the server is running in. The prior review rounds addressed all the significant issues (claude-agent-acp false-positive, async teardown races, get_event_loop() deprecation, duplicate env-var reading). What remains is clean.
A few observations on the current HEAD below.
This review was generated by an AI agent (OpenHands) on behalf of the user through OpenHands Automation. View conversation
all-hands-bot
left a comment
There was a problem hiding this comment.
⚠️ QA Report: PASS WITH ISSUES
The new ACP auth-status API works in live server/SDK execution, but CI currently has a failing agent-server-tests check and I could not verify a real logged-in vendor account in this environment.
Does this PR achieve its stated goal?
Yes, for the behavior I could exercise. On the PR branch, GET /api/acp/auth-status exists and reports real codex logged-out state as unauthenticated without sending a prompt; persisted command overrides can return authenticated through the same endpoint when session/new succeeds; unsupported/invalid/failing probes return the documented unknown/422 responses. I could not verify a real logged-in Codex/Gemini subscription/API-key account because no such credentials were available, so that specific provider-authenticated scenario was simulated with a local ACP subprocess while still exercising the real SDK probe and HTTP endpoint.
| Phase | Result |
|---|---|
| Environment Setup | ✅ make build completed and local agent-server instances started successfully |
| CI Status | gh pr checks showed 19 successful, 1 failing (Run tests/agent-server-tests), 8 pending, 3 skipped |
| Functional Verification | ✅ Live HTTP requests and SDK subprocess probes matched the PR’s claimed status mapping |
Functional Verification
Test 1: Endpoint is newly available and handles real logged-out Codex
Step 1 — Establish baseline without the fix:
Started an origin/main worktree server on port 8011 and ran:
curl -i -sS 'http://127.0.0.1:8011/api/acp/auth-status?server=codex'Observed:
HTTP/1.1 404 Not Found
{"detail":"Not Found"}This shows the base branch did not expose the new auth-status route.
Step 2 — Apply the PR's changes:
Used the checked-out PR commit f535fe1eddc7406d93b41b9cfa10d547d9fc7e9f, ran make build, and started python -m openhands.agent_server on port 8010.
Step 3 — Re-run with the fix in place:
Ran:
curl -i -sS 'http://127.0.0.1:8010/api/acp/auth-status?server=codex'Observed:
HTTP/1.1 200 OK
{"server":"codex","status":"unauthenticated","auth_methods":["chatgpt","codex-api-key","openai-api-key"],"agent_name":"codex-acp","agent_version":"0.15.0","detail":null}This confirms the new API route is live and the real codex-acp handshake classifies this no-credential environment as unauthenticated.
Test 2: Endpoint status mapping and fallback behavior
With the PR server running, I exercised the documented request outcomes:
curl -i -sS 'http://127.0.0.1:8010/api/acp/auth-status'
curl -i -sS 'http://127.0.0.1:8010/api/acp/auth-status?server=bogus'
curl -i -sS 'http://127.0.0.1:8010/api/acp/auth-status?server=claude-code'Observed:
HTTP/1.1 422 Unprocessable Content
{"detail":[{"type":"missing","loc":["query","server"],"msg":"Field required","input":null}]}
HTTP/1.1 422 Unprocessable Content
{"detail":"Unknown ACP server 'bogus'. Known providers: claude-code, codex, gemini-cli."}
HTTP/1.1 200 OK
{"server":"claude-code","status":"unknown","auth_methods":[],"agent_name":"","agent_version":"","detail":"claude-code does not report login state through the ACP handshake; its credentials can't be probed server-side."}Then I patched persisted ACP settings to a missing executable and queried Codex:
HTTP/1.1 200 OK
{"server":"codex","status":"unknown","auth_methods":[],"agent_name":"","agent_version":"","detail":"FileNotFoundError: [Errno 2] No such file or directory: '/tmp/qa-definitely-missing-acp-command'"}This confirms the endpoint uses 422 only for bad input and returns status: unknown with 200 for unsupported providers or probe execution failures, as claimed.
Test 3: Prompt-free SDK probe and endpoint authenticated path
I ran ACPAgent.probe_auth against a temporary ACP subprocess that logs protocol methods and returns either success or JSON-RPC -32000 auth errors. The subprocess results were:
authenticated {"authenticated": true, "auth_methods": ["openai-api-key"], "agent_name": "qa-fake-acp", "agent_version": "1.0.0"} methods=initialize,authenticate,session/new
unauthenticated-session-new {"authenticated": false, "auth_methods": ["openai-api-key"], "agent_name": "qa-fake-acp", "agent_version": "1.0.0"} methods=initialize,authenticate,session/new
unauthenticated-authenticate {"authenticated": false, "auth_methods": ["openai-api-key"], "agent_name": "qa-fake-acp", "agent_version": "1.0.0"} methods=initialize,authenticate
The method log contains only initialize, authenticate, and session/new; no session/prompt was sent.
I also patched the live server’s persisted ACP settings to launch that fake ACP subprocess for codex, then queried the real HTTP endpoint:
HTTP/1.1 200 OK
{"server":"codex","status":"authenticated","auth_methods":["openai-api-key"],"agent_name":"qa-fake-acp","agent_version":"1.0.0","detail":null}The fake server log was:
initialize
authenticate
session/new
This verifies the server endpoint can resolve persisted ACP settings, run the prompt-free probe in a subprocess, and surface authenticated when session/new succeeds.
Unable to Verify
I could not verify status: authenticated against a real logged-in Codex or Gemini account because this QA environment does not provide those vendor credentials/subscription logins. I verified the same success signal through a local ACP-compatible subprocess and verified real codex-acp logged-out behavior against the actual CLI.
Issues Found
- 🟠 Issue: CI is not currently green:
Run tests/agent-server-testsis failing and several checks are still pending. I did not rerun or investigate the test suite per QA instructions.
This review was created by an AI agent (OpenHands) on behalf of the user.
Final verdict: PASS WITH ISSUES
The ACP handshake can't classify claude-agent-acp: it accepts `session/new` without validating credentials (auth is enforced later at prompt time), so the probe would false-positive — which is why claude-code was gated out (`supports_auth_status_probe=False`) and always returned `unknown`. Add a per-provider CLI-status fallback for exactly these providers: - `ACPAgent.probe_cli_auth_status(command, status_args, *, env, timeout)` runs the CLI's own auth-status subcommand and reads the `loggedIn` boolean from its JSON. For claude-agent-acp the `--cli` flag re-exposes the bundled Claude CLI's `auth status --json`, so no standalone `claude` binary is required. The CLI resolves credentials wherever it stores them (macOS Keychain, `~/.claude/.credentials.json`, …) and runs inside the agent-server, so detection stays OS- and topology-agnostic. No prompt is sent ⇒ no tokens. Login state is taken from `loggedIn` (not the exit code, which may be non-zero when logged out); unparseable output / spawn failure / timeout raise ⇒ caller maps to `unknown`. - `ACP_CLI_AUTH_STATUS_ARGS` maps `claude-code` → `--cli auth status --json`. Kept as a module constant (not an `ACPProviderInfo` field) so the dataclass — and its exact mirror in typescript-client's `acp-providers.json`, enforced by the drift check — stays unchanged. - `GET /acp/auth-status` now dispatches: handshake when `supports_auth_status_probe`, else the CLI fallback when registered, else `unknown` (no provider has neither today). codex/gemini are unchanged. Verified live against the real CLIs on a logged-in machine: claude-code → authenticated (`auth_methods: ["claude.ai"]`), codex/gemini still authenticated. Tests: `TestACPProbeCliAuthStatus` (authenticated, logged-out-with-nonzero-exit, missing/unparseable `loggedIn` → raise, noisy-output tolerance, timeout propagation, env-conflict stripping) and router tests for the claude CLI path (authenticated/unauthenticated/error→unknown) + the no-strategy→unknown branch. Refs OpenHands/agent-canvas#964 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
🔍 Review in progress… We are performing the review through OpenHands Cloud Automation. You can log in and view the conversation here. |
all-hands-bot
left a comment
There was a problem hiding this comment.
⚠️ QA Report: PASS WITH ISSUES
The new ACP auth-status capability worked in live server/API and SDK probe exercises, but the current PR CI snapshot has one failing check.
Does this PR achieve its stated goal?
Yes. I verified that /api/acp/auth-status is absent on main and present on the PR branch, returns the expected validation/fallback responses, uses a real Codex ACP subprocess to report unauthenticated without sending a prompt, and can report authenticated when the ACP handshake session/new succeeds. I also called ACPAgent.probe_auth() against a real subprocess and observed only initialize + session/new methods, which supports the PR’s “prompt-free / no model tokens” claim.
| Phase | Result |
|---|---|
| Environment Setup | ✅ make build completed successfully; no tests/linters were run locally. |
| CI Status | gh pr checks: 18 successful, 1 failing (Run tests/agent-server-tests), 1 skipped, 8 pending. |
| Functional Verification | ✅ Endpoint and SDK probe behavior exercised with real server, HTTP requests, and subprocess handshakes. |
Functional Verification
Test 1: Endpoint exists only after the PR and handles request classes correctly
Step 1 — Establish baseline without the PR:
Checked out origin/main, started the agent server, then ran:
curl -sS -i 'http://127.0.0.1:8765/api/acp/auth-status?server=codex'Observed:
HTTP/1.1 404 Not Found
{"detail":"Not Found"}This shows the endpoint did not exist on the base branch.
Step 2 — Apply the PR's changes:
Checked out feat-acp-auth-status-probe at 59ae2c678bef5eb719d0b52034899dcc6c64510c and started the agent server.
Step 3 — Re-run with the PR branch:
Ran:
curl -sS -i 'http://127.0.0.1:8766/api/acp/auth-status'
curl -sS -i 'http://127.0.0.1:8766/api/acp/auth-status?server=bogus'
curl -sS -i 'http://127.0.0.1:8766/api/acp/auth-status?server=claude-code'Observed:
HTTP/1.1 422 Unprocessable Content
{"detail":[{"type":"missing","loc":["query","server"],"msg":"Field required","input":null}]}
HTTP/1.1 422 Unprocessable Content
{"detail":"Unknown ACP server 'bogus'. Known providers: claude-code, codex, gemini-cli."}
HTTP/1.1 200 OK
{"server":"claude-code","status":"unknown","auth_methods":[],"agent_name":"","agent_version":"","detail":"claude-code does not report login state through the ACP handshake; its credentials can't be probed server-side."}This shows the new route is registered and returns the intended API shapes for missing server, unknown provider, and unsupported Claude probe.
Test 2: Real provider probe reports logged-out Codex without sending a prompt
Step 1 — Baseline:
The base branch returned 404 for this route, so there was no API path to query ACP auth status.
Step 2 — Apply the PR's changes:
Used the running PR agent server with ACP_AUTH_PROBE_TIMEOUT=20.
Step 3 — Exercise real provider behavior:
Ran:
curl --max-time 45 -sS -i 'http://127.0.0.1:8766/api/acp/auth-status?server=codex'Observed:
HTTP/1.1 200 OK
{"server":"codex","status":"unauthenticated","auth_methods":["chatgpt","codex-api-key","openai-api-key"],"agent_name":"codex-acp","agent_version":"0.15.0","detail":null}This exercised the actual server endpoint and actual Codex ACP subprocess path. In this environment, Codex was reachable but not logged in, and the endpoint correctly returned unauthenticated instead of unknown or an HTTP error.
Test 3: Endpoint can report authenticated when session/new succeeds
Step 1 — Baseline:
On main, the endpoint was unavailable (404), so onboarding could not query this state.
Step 2 — Apply the PR's changes and configure ACP settings as a user would via the API:
Patched /api/settings with agent_settings_diff selecting ACP codex and a local ACP-compatible command whose session/new succeeds.
Step 3 — Query auth status:
Ran:
curl -sS -i 'http://127.0.0.1:8766/api/acp/auth-status?server=codex'Observed:
HTTP/1.1 200 OK
{"server":"codex","status":"authenticated","auth_methods":[],"agent_name":"qa-fake-acp","agent_version":"1.0","detail":null}This confirms the endpoint maps a successful ACP handshake to status: "authenticated" over the real HTTP API.
Test 4: SDK ACPAgent.probe_auth() classifies success vs auth_required and sends no prompt
Step 1 — Baseline:
The base branch did not expose ACPAgent.probe_auth, so there was no prompt-free SDK probe to call.
Step 2 — Apply the PR's changes:
Called ACPAgent.probe_auth() on the PR branch against a real local subprocess implementing initialize and session/new.
Step 3 — Run authenticated and unauthenticated handshakes:
Observed:
AUTH_RESULT={"authenticated":true,"auth_methods":[],"agent_name":"qa-fake-acp","agent_version":"1.0"}
AUTH_METHODS_LOG=["initialize", "session/new"]
UNAUTH_RESULT={"authenticated":false,"auth_methods":[],"agent_name":"qa-fake-acp","agent_version":"1.0"}
UNAUTH_METHODS_LOG=["initialize", "session/new"]
This confirms the SDK probe returns authenticated=True on successful session/new, authenticated=False on JSON-RPC -32000 auth_required, and does not send a prompt/message method.
Unable to Verify
I did not have a real logged-in Codex/Gemini/Claude subscription account in this environment, so I could not verify an actual third-party subscription-login credential. I did verify the real Codex logged-out path and the authenticated ACP protocol path using a real subprocess and the live HTTP endpoint.
Issues Found
- 🟠 Issue: CI is not green at the time of QA:
Run tests/agent-server-testsis failing, with 8 checks still pending. I did not rerun or investigate tests locally per QA instructions.
Verdict: PASS WITH ISSUES — functional behavior matches the PR goal, but CI needs attention.
This review was created by an AI agent (OpenHands) on behalf of the user.
| ) | ||
| # Scrub any secret/env value the error string might have echoed (e.g. a | ||
| # provider rejecting a bad key by quoting it back) before truncating. | ||
| detail = f"{type(e).__name__}: {e}" |
| ) | ||
| # Scrub any secret/env value the error string might have echoed (e.g. a | ||
| # provider rejecting a bad key by quoting it back) before truncating. | ||
| detail = f"{type(e).__name__}: {e}" |
There was a problem hiding this comment.
Test comment line 209
| extra={"acp_server": server, "client_host": client_host}, | ||
| ) | ||
|
|
||
| # ``session/new`` keys persistence by cwd; a throwaway directory keeps the |
There was a problem hiding this comment.
Test comment line 182
| @@ -162,6 +162,24 @@ class ACPProviderInfo: | |||
| signature break; the built-in providers set it explicitly. | |||
| @@ -162,6 +162,24 @@ class ACPProviderInfo: | |||
| signature break; the built-in providers set it explicitly. | |||
| """ | |||
| @@ -162,6 +162,24 @@ class ACPProviderInfo: | |||
| signature break; the built-in providers set it explicitly. | |||
| """ | |||
|
|
|||
| signature break; the built-in providers set it explicitly. | ||
| """ | ||
|
|
||
| supports_auth_status_probe: bool = True |
| handshake behind ``GET /acp/auth-status`` (see ``ACPAgent.probe_auth``). | ||
|
|
||
| The probe infers login from ``session/new``: an ``auth_required`` (-32000) | ||
| error ⇒ not logged in, success ⇒ logged in. That only holds for servers |
| gemini-cli — both return -32000 when logged out, verified against the real | ||
| CLIs). | ||
|
|
||
| ``False`` for ``claude-agent-acp``: it does **not** gate auth at |
| prompt time), so a probe would false-positive ``authenticated`` for a | ||
| logged-out user. The endpoint returns ``unknown`` for such providers instead | ||
| of guessing. Detecting Claude login needs an out-of-band credential check | ||
| (env / ``~/.claude`` / keychain) — tracked separately, not done here. |
|
|
||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Curated ``acp_model`` candidate lists for the built-in providers. |
| @@ -251,6 +269,10 @@ class ACPProviderInfo: | |||
| session_meta_key="claudeCode", | |||
| @@ -251,6 +269,10 @@ class ACPProviderInfo: | |||
| session_meta_key="claudeCode", | |||
| available_models=_CLAUDE_MODELS, | |||
| # claude-agent-acp accepts session/new without validating creds | ||
| # (auth is enforced at prompt time), so the auth-status probe would | ||
| # false-positive — the endpoint returns "unknown" for it instead. | ||
| supports_auth_status_probe=False, |
|
Closed in favor of simpler approach OpenHands/agent-canvas#1002 |
|
Closed in favor of simpler approach |
Summary
Phase 1 SDK side of OpenHands/agent-canvas#2400 — server-side detection of an existing ACP subscription/login so onboarding can show "✓ you're already logged in" instead of unconditionally asking for an API key.
Detection rides the ACP protocol handshake rather than sniffing credentials per-OS/topology (keychain vs
~/.codex/auth.jsonvs~/.gemini/oauth_creds.json, across local/docker/cloud). The reliable signal:No prompt is sent, so no model tokens are spent. Because the probe runs inside the agent-server, it reports the truth for wherever the agent will actually run — the canvas + server stay OS/topology-agnostic.
Changes
openhands-sdk_start_acp_serverinto shared module-level helpers (_spawn_acp_connection,_acp_initialize,_apply_env_conflict_rules) —_start_acp_servernow calls them, so both paths build the env and authenticate identically.ACPAgent.probe_auth(command, *, args, env, cwd, timeout)— spawn →initialize→ best-effortauthenticate→session/new→ classify success vsauth_required→ tear down. ReturnsACPAuthProbeResult(authenticated, auth_methods, agent_name, agent_version). The handshake is timeout-bounded and teardown is guaranteed on the same event loop (with a bounded connection close), so a wedged subprocess can't leak.openhands-agent-serverGET /acp/auth-status?server=<key>(acp_auth_router) — resolves the launch command + env for a provider key fromACP_PROVIDERS+ persisted agent settings + stored global secrets, runsprobe_authin a threadpool, and returns{ server, status, auth_methods, agent_name, agent_version, detail }wherestatus ∈ {authenticated, unauthenticated, unknown}.422.auth_requirederror) →status: "unknown"with200, so the canvas falls back to the API-key fields rather than falsely claiming "not logged in".statusmaps 1:1 onto the canvasuseAcpAuthStatushook, so Phase 1 can swap its body to this endpoint without touching the banner UI.Tests
TestACPProbeAuth— authenticated,auth_required→unauthenticated, non-auth errors propagate, spawn failure propagates, conditional authenticate, timeout; transport mocked (no real subprocess), mirroringTestACPSessionIdPersistence.test_acp_auth_router— authenticated/unauthenticated/unknown(error & timeout),422for unknown/missing server, command resolution from registry + persisted override, and stored-secret → probe-env folding with settings precedence.test_acp_agent.pysuite stays green, verifying the_start_acp_serverrefactor.Cross-repo follow-up (not in this PR)
SDK release → bump the server pin /
@openhands/typescript-clientin agent-canvas → swap the Phase 0 throwaway-conversation probe inuseAcpAuthStatusfor this endpoint. The canvas Phase 0 UI (banner + optional key fields) already exists behind that hook.Refs OpenHands/agent-canvas#2400
🤖 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:a7b7945-pythonRun
All tags pushed for this build
About Multi-Architecture Support
a7b7945-python) is a multi-arch manifest supporting both amd64 and arm64a7b7945-python-amd64) are also available if needed