Skip to content

fix(controller): show an agent unavailable page on the agent host - #6548

Merged
freeqaz merged 3 commits into
mainfrom
fix-stopped-agent-page-3402
Nov 19, 2026
Merged

freeqaz merged 3 commits into
mainfrom
fix-stopped-agent-page-3402

Conversation

@freeqaz

@freeqaz freeqaz commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

After occ agent stop, an open Agent UI shows the panel "Reconnect to the Gateway. Your sign-in may have expired, or your access may have changed. Reconnect in browser". That link is a plain page load of / on the Agent host. For a signed-in user who has access to the Agent, the controller refuses it with admission reason agent_unavailable. interceptNativeAdminHttp has HTML pages only for session_invalid, revision_changed and authorization_denied, so the browser shows the raw JSON 403 FORBIDDEN ("The exact platform operation was not authorized."). Nothing tells the user that the Agent is unavailable or where to go. Seen on a production-shaped test install; #6523 named it as a follow-up.

Change

  • nativeAdminProxyContext: when requireAvailable refuses an availability that resolveNativeAdminAvailability has already returned (stopped, deleting or unsupported) with reason agent_unavailable, the denial carries an internal accessEstablished mark. Its other refusals (revision_changed, disabled, the host-mismatch authorization_denied) carry no mark, as before. The reasons are unchanged. The agent_unavailable reason alone does not prove access: some failures before or inside the authorization step map to it too, and those stay unmarked.
  • interceptNativeAdminHttp: the Agent's console URL (/console/#native-agent=<key>) is built once, for eligible page loads, and is shared by the sign-in answers and the Agent pages. One branch now renders both the Agent version changed page and the new Agent unavailable page (403, the same headers, the sentence "This Agent is not available right now. Open it from the console." and a Return to console link). The wording is true for every sub-state: stopped, being deleted, or running without a browser UI in its Configuration or Compute.
  • Unchanged: /healthz and other API or probe requests (JSON 403, so the Agent UI still shows its panel), WebSocket upgrades, the agent_transition 503, revision_changed, a Compute owner mismatch (operator fault: JSON 403), and every answer to a caller without access.
  • Docs: the native admin flow, the reference and the deploy guide's reconnect section describe the page. The guide says: if it shows Agent unavailable, open the Agent in the console for its status; deploy a stopped Agent.

No new setting, flag, header or response field. Deleted: the duplicate console URL construction and the separate revision_changed branch (folded into the shared one).

The four points of an independent review were applied in a follow-up commit: wording that is true in every state, the mark only for agent_unavailable, the JSON request-ID check restored in the test, and the flow page's "without an HTTP response" restored with a long line rewrapped.

Verification

  • tests/integration/native-admin-access.test.mjs: the case fix(controller): answer a deployment in progress with 503 on the Agent host #6523 added now also covers the page. On a stopped Agent, the authorized page load of / gets 403 text/html with the title Agent unavailable, the sentence, and <a href="<console>/console/#native-agent=<key>">Return to console</a>, without the Agent ID. /healthz (plain, and sent as a page load) and a JSON GET / keep the JSON 403. The outsider comparison covers a signed-out caller and a signed-in caller without Agent operate, each for GET /healthz and a user-activated page load of GET /. It compares whole answers (status, headers, body; request ID and date aside) in the available, replacing and stopped states, and checks the JSON body's request ID against x-request-id for non-empty JSON answers (the empty 302 carries a JSON content type). Signed out gets 403 JSON and 302 to the console; no access gets 403 JSON and the Access denied page, identical in all three states.
    • With the fix: passes.
    • With apps/controller/src/http/native-admin.ts from main (4c2da280f8): fails at the stopped page load, application/json instead of text/html. The outsider comparisons pass there too, as they should.
  • CI lanes on a remote test VM:
    • checks-baseline-2 (typecheck, native-admin-access): pass at 92ab7ab2e0 and at 400b3b539a (after the review commit).
    • postgres-auth (native-admin-session-postgres, native-browser-launch-postgres): pass at 92ab7ab2e0. The stop lease close reason agent_unavailable and the version-changed 403 (JSON and HTML) are unchanged. Not rerun after the review commit, which changes no reason, lease or JSON answer.
    • static: failed at 92ab7ab2e0 on docs length (the three pages went over 2,500 words); passes at 64f9b885da after shortening them, and at 400b3b539a.
  • Docs length after the review commit: flow 2,499, reference 2,497, deploy guide 2,500 words (limit 2,500).
  • Format check, ESLint and the flow-doc validator on the touched files: clean.
  • Real install: a production-shaped test install was upgraded in place to the previous commit of this branch (64f9b885da). The review commit after it changes the page's title and sentence and narrows the internal mark; it changes no status, header, link or condition for showing the page.
    • Stopped Agent (occ agent stop) with the Agent UI open: the panel still appears. Reconnect in browser and an address-bar reload of the host root both load the page: 403, text/html; charset=utf-8, cache-control: no-store, referrer-policy: no-referrer, 324 bytes, neither the Agent ID nor its name in the HTML. Return to console opens the Agent's console page ("Start this Agent before opening its browser UI"); Deploy new version there brought the Agent UI back 57 s later.
    • With the same cookie, GET /healthz (plain and sent as a page load) and a JSON GET / keep the JSON 403.
    • Deploy of a running Agent with the Agent UI open: only "Reconnecting" for about 36 s, every probe 503 with agent_transition; neither the panel nor the page appears.
    • Callers without access: the whole answers (status, every header except request ID and date, body with the request ID replaced) of a signed-out client and of a signed-in account without a grant, for GET /healthz and a user-activated page load of GET /, are byte-identical in four states (running, deploy of a running Agent, stopped, deploy from stopped). The authorized probe saw 200, 503, 403, 503 at the same moments. Signed out: 403 JSON and 302 to the console. No access: 403 JSON and the Access denied page.
    • Not covered by that round: the final title and sentence (Agent unavailable), which the integration test checks on the final head, and the deleting and no-browser-UI sub-states.
  • This is a controller-rendered refusal page, not a Console page or component, so there is no Storybook story. Screenshots from the round show the page with its earlier wording; the next install round captures the final wording.

Risks

  • A caller without access cannot tell a stopped Agent from any other state: a signed-out caller is refused at the session check and a signed-in caller without a grant at authorizeAgentAccess, both before any lifecycle state is read. The page needs the mark that only an availability returned after that check can set. The test compares the whole answers (status, headers, body; request ID and date aside) of both callers for GET / and GET /healthz in the available, replacing and stopped states.
  • The page does not say why the Agent is unavailable; the console shows the actual state behind the link.
  • The real-install check ran one commit before the final head (see Verification). The final wording and the deleting and no-browser-UI sub-states rest on the integration test and code reading; the next production-shaped install round repeats the page check on main.

…rs with access

A signed-in caller with access who follows the Agent UI's Reconnect in browser
link on a stopped or unsupported Agent got the generic JSON 403. A document
navigation refused for that reason, after access was established, now gets a
403 page that says the Agent is not running and links to the Agent in the
console, built by the same branch as the Agent version changed page. Probes,
API reads, WebSocket upgrades and every answer to a caller without access are
unchanged.
The added sentences put the flow, reference and deploy guide pages over the
2500-word hard limit. Shorten them and tighten two nearby sentences without
changing what they say.
@freeqaz
freeqaz requested a review from a team as a code owner November 19, 2026 06:14
@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P2 Normal priority bug or improvement with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 19, 2026
@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR gives authorized visitors to an unavailable Agent’s host an HTML refusal page with a return link to the console.

Example: After occ agent stop, a signed-in administrator selects Reconnect in browser, opening / on the Agent host.

  • Before: The browser displays a generic JSON 403 refusal.
  • After: The browser displays Agent unavailable with a Return to console link, while /healthz retains its JSON 403.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused implementation and meaningful integration coverage support correctness; shipped-behavior evidence does not yet support a pass.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A user following Reconnect in browser after stopping an Agent receives raw JSON with no useful explanation or recovery link.
Reason: The maintainer-authored direction addresses an explicitly recorded follow-up with a narrow change to existing refusal handling.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR addresses a recovery gap still present on main, and review found no introduced correctness defect.

Priority: P2
Reviewed head: 400b3b539a1108ce64fb33bebb4ddea37bca970a

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Supply before/after browser evidence showing stop, Reconnect in browser, the unavailable page, and Return to console on the reviewed implementation.
Agent review details

How this fits together

The controller intercepts Agent-host requests, checks the browser session and exact Agent permissions, resolves availability, and either proxies the request or renders a refusal.

flowchart TB
  Browser[Agent browser tab] --> Admission[Native host admission]
  Admission --> IAM[Session and exact Agent access]
  IAM --> Availability[Agent availability]
  Availability -->|Available| Gateway[Agent Gateway]
  Availability -->|Unavailable page navigation| Refusal[HTML refusal page]
  Refusal -->|Return link| Console[Agent console page]
Loading

Technical review

Best possible solution:

Use the existing authorized native-host refusal renderer and console recovery path while preserving probe responses and exact-Agent access checks.

Do we have a high-confidence way to reproduce the issue?

Current-main source shows authorized stopped-Agent navigation reaching the generic JSON 403; the supplied regression reports the corresponding base failure, but this review ran no target code.

Is this the best way to solve the issue?

The patch fixes presentation at its existing controller owner, preserves admission outcomes, and extends a relevant integration scenario without adding a parallel recovery mechanism.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 3d6808607c5a.

Provenance checked

  • Availability refusal classification keeps the original intent (67c518f: Separate deployment transitions from stopped or unsupported Agents so temporary deployment failures do not imply expired sign-in.)
  • Version-change HTML refusal keeps the original intent (49e3f60: Guide stale tabs back to the console while preserving HTTP 403, cookies, and explicit reopening.)
  • Signed-out console return keeps the original intent (88ec2dc: Return activated browser navigations to the configured console origin with only the opaque Agent destination.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Free Wortley: Raw commit 67c518f adds apps/controller/src/http/native-admin.ts:1595 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 67c518f6b0ab; files: apps/controller/src/http/native-admin.ts)
  • Eric Cai: Raw commit 1f4f166 adds apps/controller/src/http/native-admin.ts:234 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 1f4f1664c3af; files: apps/controller/src/http/native-admin.ts)
  • kevinlin-openai: Raw commit 6ba4cce adds apps/controller/src/http/native-admin.ts:755 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 6ba4cceaa1b0; files: apps/controller/src/http/native-admin.ts)
  • Patrick Erichsen: Raw commit 54f8340 adds apps/controller/src/http/native-admin.ts:239 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 54f83409c8ee; files: apps/controller/src/http/native-admin.ts)

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: An explicit-stop recovery flow ends in confusing JSON, but the console remains available and the failure has limited scope.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-19T06:27:58.868Z sha 64f9b88 :: needs maintainer review before merge. :: none

Reviewed November 19, 2026, 1:43 AM ET / 06:43 UTC (Revision 2).

The page for a caller with access is also shown for an Agent being deleted
and for a running Agent whose Configuration or Compute offers no browser UI,
so "not running" was wrong there. Title it "Agent unavailable" with "This
Agent is not available right now. Open it from the console." The deploy
guide now says to open the Agent in the console for its status and to deploy
a stopped Agent.

Set the internal access mark only for the agent_unavailable reason; the
other refusals from requireAvailable carry no mark, as before. The outsider
comparison checks the JSON request ID again for JSON answers. The flow page
again says an upgrading socket is closed without an HTTP response, and a long
line is rewrapped.
@freeqaz freeqaz changed the title fix(controller): show an agent not running page on the agent host fix(controller): show an agent unavailable page on the agent host Nov 19, 2026
@freeqaz

freeqaz commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@freeqaz
freeqaz merged commit f59c857 into main Nov 19, 2026
45 of 48 checks passed
@freeqaz
freeqaz deleted the fix-stopped-agent-page-3402 branch November 19, 2026 06:56
@freeqaz

freeqaz commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator Author

Real-install check of the landed page on main (f59c857119)

The same production-shaped test install was upgraded in place from this PR's earlier head to main f59c857119. The upgrade was clean: Helm upgrade exit 0, no migration, the same object list, and no error-level lines in API, worker, Gateway or Harness logs. The Agent under test is a dedicated Codex Agent with browser chat. The user is signed in as an administrator with access to it.

Result: PASS.

Stopped Agent (occ agent stop) with the Agent UI open

  • The Agent UI shows its panel, unchanged: "Reconnect to the Gateway. Your sign-in may have expired, or your access may have changed. Reconnect in browser".
  • Selecting Reconnect in browser loads the new page:
    • title Agent unavailable;
    • text: "This Agent is not available right now. Open it from the console." and a Return to console link to /console/#native-agent=<key>;
    • status 403;
    • content-type: text/html; charset=utf-8, cache-control: no-store, referrer-policy: no-referrer, x-content-type-options: nosniff;
    • the HTML (336 bytes) contains neither the Agent ID nor its name.
  • Loading the Agent host root from the address bar gives the same page, with the same status and headers.
  • With the same cookie, GET /healthz (plain and with navigation headers) and a JSON GET / still return the JSON 403 (FORBIDDEN, "The exact platform operation was not authorized.").
  • Return to console opens the Agent's detail page in the Console, which shows the runtime as "Stop requested" and offers Deploy new version.

Callers without access
We collected the whole answer (status, every header except request ID and date, and the body with the request ID replaced) for four requests:

  • GET /healthz and a page load of GET / (with sec-fetch-mode: navigate, sec-fetch-dest: document and sec-fetch-user: ?1);
  • each from a signed-out client and from a signed-in account with no grant on the Agent.

We collected them while the Agent was running and while it was stopped. The authorized caller's probe confirmed each state at the same moment (200, then 403). Both sets are byte-identical to each other, and to the sets collected on the earlier head in four other states:

  • signed out: 403 JSON for /healthz, and 302 to the Console for the page load;
  • no access: 403 JSON for /healthz, and the 403 Access denied page for the page load.

Agent being deleted
While the stopped Agent was being deleted, the administrator's page load still got the Agent unavailable page for about 3 seconds. Once the deletion removed the Agent's access, the same administrator got the Access denied page ("You do not have access to this gateway.") with a link to the Agent list, the same answer an account without access gets.

The page as rendered on that install:

agent-unavailable-page-main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant