Skip to content

fix(gateway): stop fabricating assistant agent id "main" before roster resolution - #114257

Merged
steipete merged 1 commit into
mainfrom
fix/gateway-assistant-identity-default
Jul 27, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/gateway-assistant-identity-default

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

On team.openclaw.ai (agent main deliberately retired; roster = roboclaw only), every Control UI page reload briefly flashes an error chip in the CODING sidebar section — unknown agent id "main" with a Retry button — and a fresh "New thread" view can show main in the agent picker. The gateway journal shows the client firing on each reload, then retrying every ~3s:

[ws] ⇄ res ✗ sessions.catalog.list 35ms errorCode=INVALID_REQUEST errorMessage=unknown agent id "main"

Root cause is a fabricated identity, hardcoded in three places:

  • ui/src/app/gateway-store.ts:65 — the client gateway store initializes assistantAgentId: "main" before any server data arrives
  • ui/src/app/gateway-store.ts:336 — the hello handler falls back to "main" when session defaults are absent
  • src/gateway/assistant-identity.ts — DEFAULT_ASSISTANT_IDENTITY.agentId: "main", served through the Control UI HTTP bootstrap whenever no config snapshot is threaded

Agent selection (ui/src/app/agent-selection.ts) trusts that id during the pre-roster window (reconciliation passes unknown ids through until agents.list arrives), so agent-scoped catalog RPCs target a nonexistent agent.

Why This Change Was Made

Core must not carry bundled agent ids when a roster contract exists (root AGENTS.md architecture rule). The honest state before config/roster/hello resolution is "no agent known":

  • DEFAULT_ASSISTANT_IDENTITY no longer carries an agent id; resolveAssistantIdentity returns a ResolvedAssistantIdentity (agentId required) so all config-backed paths keep their guarantee at the type level.
  • ControlUiBootstrapConfig.assistantAgentId becomes optional and is omitted when no config is present (HTTP bootstrap contract only; no gateway-protocol change).
  • The UI store starts with assistantAgentId: null and the hello fallback is null, not "main".
  • reconcileSelectedId now also adopts the roster default when nothing is selected once the roster loads, so the picker settles on the real default agent instead of a fabricated one.

Production paths always thread loadGatewayConfig(), so configured installs see identical behavior; the change only removes the fabricated id in the config-absent/pre-hello windows.

User Impact

No more unknown agent id "main" flash on reload on installs whose implicit main agent was retired; the agent picker cannot show a nonexistent agent while booting. Fewer wasted failing RPCs during startup.

Evidence

  • Journal evidence above (team.openclaw.ai, 2026-07-27 01:18–01:19 UTC).
  • src/gateway/control-ui.http.test.ts — new coverage that the bootstrap omits assistantAgentId without config and resolves the roster id with config.
  • ui/src/app/gateway-store.test.ts — snapshot starts null / hello fallback stays null.
  • ui/src/app/agent-selection.test.ts — null-selection adopts roster default on roster arrival.
  • Focused runs: gateway 124 tests, UI 30 tests, plus the three files above re-run post-changelog-revert (2 shards green). Changed-file oxlint rc=0; git diff --check clean.
  • Autoreview (Codex gpt-5.6-sol, xhigh): clean, "patch is correct (0.93)".

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime labels Jul 27, 2026
@steipete
steipete marked this pull request as ready for review July 27, 2026 03:22
@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Jul 27, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 27, 2026
@clawsweeper

clawsweeper Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 26, 2026, 11:40 PM ET / July 27, 2026, 03:40 UTC.

ClawSweeper review

What this changes

The PR removes fabricated main assistant-agent defaults from gateway bootstrap and Control UI startup state, then selects the real roster default after agent data arrives.

Merge readiness

⛔ Blocked until real behavior proof is added - 4 items remain

Keep this PR open. The patch has a coherent, narrow fix for the pre-roster Control UI startup regression and its focused coverage matches the reported path, but it still lacks inspectable after-fix real behavior proof from an affected deployment or equivalent live setup.

Priority: P2
Reviewed head: f089cf4f23ac4c4f369c970b26e1fff78925f58a

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The implementation and focused coverage are solid, but missing after-fix real behavior proof remains a merge gate.
Proof confidence 🧂 unranked krab (1/6) Needs real behavior proof before merge: The PR provides a before-fix production journal excerpt and automated validation, but the author says the after-fix reload journal will follow deployment; attach a redacted live reload transcript, terminal output, recording, or diagnostic screenshot that shows the invalid request is gone. Redact private endpoints, IP addresses, tokens, and other sensitive details; updating the PR body should trigger re-review, or a maintainer can comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR provides a before-fix production journal excerpt and automated validation, but the author says the after-fix reload journal will follow deployment; attach a redacted live reload transcript, terminal output, recording, or diagnostic screenshot that shows the invalid request is gone. Redact private endpoints, IP addresses, tokens, and other sensitive details; updating the PR body should trigger re-review, or a maintainer can comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 4 items Reported failure and bounded source path: The PR describes a production journal error for sessions.catalog.list targeting retired main; its branch changes the initial store value and hello fallback to null, which directly addresses the pre-roster source of that request.
Bootstrap contract and configuration-backed identity: The branch makes the internal Control UI bootstrap agent field optional and omits it when no gateway configuration is supplied, while retaining a required agent id for configuration-backed identity resolution.
Roster reconciliation coverage: The added agent-selection test covers the intended transition from no selected id to the normalized roster default after roster publication.
Findings None None.
Security None None.

How this fits together

The gateway exposes a small Control UI bootstrap payload and later sends WebSocket hello/session-default data; the UI combines those with the agent roster to choose an agent for catalog and session requests. This PR changes the unresolved startup state from a hard-coded agent id to no selection until the real roster or gateway data is available.

flowchart LR
  A[Control UI bootstrap] --> C[Gateway store]
  B[WebSocket hello] --> C
  C --> D[Agent selection]
  E[Agent roster] --> D
  D --> F[Agent-scoped catalog requests]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR provides a before-fix production journal excerpt and automated validation, but the author says the after-fix reload journal will follow deployment; attach a redacted live reload transcript, terminal output, recording, or diagnostic screenshot that shows the invalid request is gone. Redact private endpoints, IP addresses, tokens, and other sensitive details; updating the PR body should trigger re-review, or a maintainer can comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - assistantAgentId becomes absent in a bootstrap response without a config snapshot, so merge safety still depends on confirming an actual Control UI reload does not retain another pre-roster consumer that assumes a selected agent.
  • Resolve merge risk (P1) - The supplied evidence is pre-fix production output plus automated tests; it does not yet directly demonstrate that the invalid catalog RPC and error chip disappear after the branch is deployed or run against an affected roster.
  • Complete next step (P2) - The remaining blocker is contributor-supplied real behavior proof, not a concrete code repair that an automated fix lane can safely perform.
Agent review details

Security

None.

PR surface

Source +3, Tests +51. Total +54 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 5 30 27 +3
Tests 3 57 6 +51
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 87 33 +54

Review metrics

Metric Value Why it matters
Bootstrap identity contract 1 field changed from required to optional Control UI startup consumers may now receive no assistant agent id until gateway configuration or the roster resolves it.

Merge-risk options

Maintainer options:

  1. Prove the affected startup path (recommended)
    Run or deploy the branch with a roster that omits main, then attach redacted reload diagnostics showing the picker settles on the roster default and the invalid catalog RPC no longer occurs.
  2. Accept the unproven bootstrap-contract change
    Merge based on the focused tests and consumer audit while accepting that real affected-roster startup behavior has not been independently shown.

Technical review

Best possible solution:

Keep the no-agent-until-resolved model, retain the focused bootstrap/store/roster regression coverage, and add redacted after-fix reload evidence showing no unknown agent id "main" catalog request before merging.

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

No high-confidence reproduction was independently run in this review. The provided production trace plus the branch’s focused tests make the path source-reproducible: load the Control UI with a roster containing only roboclaw, reload before roster resolution, and observe whether a catalog request targets main.

Is this the best way to solve the issue?

Yes, conditionally. Representing the unresolved state as no agent and adopting the roster default is narrower and more maintainable than retaining a bundled id, but it needs after-fix proof on the affected startup path before merge.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 04bb2b7ee9a9.

Labels

Label changes:

  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🧂 unranked krab, so this older rating label is no longer current.

Label justifications:

  • P2: The PR addresses a real but limited Control UI startup regression that produces incorrect agent-scoped requests on affected installations.
  • merge-risk: 🚨 compatibility: Making the gateway bootstrap agent field optional changes the startup contract for Control UI consumers and requires live upgrade-path confirmation.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR provides a before-fix production journal excerpt and automated validation, but the author says the after-fix reload journal will follow deployment; attach a redacted live reload transcript, terminal output, recording, or diagnostic screenshot that shows the invalid request is gone. Redact private endpoints, IP addresses, tokens, and other sensitive details; updating the PR body should trigger re-review, or a maintainer can comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Reported failure and bounded source path: The PR describes a production journal error for sessions.catalog.list targeting retired main; its branch changes the initial store value and hello fallback to null, which directly addresses the pre-roster source of that request. (ui/src/app/gateway-store.ts:65, f089cf4f23ac)
  • Bootstrap contract and configuration-backed identity: The branch makes the internal Control UI bootstrap agent field optional and omits it when no gateway configuration is supplied, while retaining a required agent id for configuration-backed identity resolution. (src/gateway/control-ui.ts:966, f089cf4f23ac)
  • Roster reconciliation coverage: The added agent-selection test covers the intended transition from no selected id to the normalized roster default after roster publication. (ui/src/app/agent-selection.test.ts:115, f089cf4f23ac)
  • PR validation and remaining proof gap: The supplied CI state shows the completed UI, type, lint, build, contract, and security checks succeeding so far; the prior ClawSweeper review and the author’s follow-up both confirm that after-fix live reload evidence has not yet been posted. (f089cf4f23ac)

Likely related people:

  • steipete: The available PR evidence shows direct investigation of the affected deployment, a consumer audit across the UI path, and the focused gateway/UI change and tests. (role: recent area contributor; confidence: medium; commits: f089cf4f23ac; files: src/gateway/control-ui.ts, ui/src/app/gateway-store.ts, ui/src/app/agent-selection.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Attach redacted evidence from an affected roster showing fresh reloads no longer issue sessions.catalog.list for main.
  • Show that the agent picker settles on the real roster default after startup.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-07-27T03:26:53.790Z sha 3247f1a1bcfc1dcd813b4595985701611582a305 :: needs real behavior proof before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

Addressing the rank-up moves.

Consumer audit (move 2), performed: every consumer of assistantAgentId in ui/src already types it string | null / optional and consumes it behind ??-fallback chains, because the ws-disconnected snapshot always permitted null — e.g. ui/src/lib/sessions/session-key.ts:126 (host.assistantAgentId ?? agentsList/hello fallback), ui/src/app/config.ts:127 (parsed.assistantAgentId ?? null where the bootstrap field is now omitted), chat-state-page.ts:84, chat-session-workspace.ts:122, new-session-page.ts:1447. No consumer assumed presence; no additional coverage gaps found beyond the tests this PR adds (bootstrap omission, store null-start, hello null fallback, roster-default adoption).

After-fix reload evidence (move 1): follows deployment to team.openclaw.ai immediately after merge — acceptance is the production journal showing zero sessions.catalog.list … unknown agent id on fresh page loads, which is exactly the before-evidence trace in the PR body. Will post the post-deploy journal excerpt here. Note the client-side literals this PR removes (gateway-store.ts:65/336) are the dominant source of the flash; the sibling PR for the catalog-side retry loop (in flight) covers the remainder.

@steipete
steipete force-pushed the fix/gateway-assistant-identity-default branch from 3247f1a to 41eea47 Compare July 27, 2026 03:35
…r resolution

Three fabrication points told clients the assistant agent was "main" before
any roster/config resolution: DEFAULT_ASSISTANT_IDENTITY in
src/gateway/assistant-identity.ts, the Control UI store's initial snapshot
(ui/src/app/gateway-store.ts:65), and its hello fallback (:336). On installs
whose implicit main agent is retired, every page reload fired
sessions.catalog.list for the nonexistent agent and flashed
'unknown agent id "main"' in the sidebar.

The no-roster state now carries no agent id: DEFAULT_ASSISTANT_IDENTITY drops
agentId, resolveAssistantIdentity returns ResolvedAssistantIdentity (agentId
required) for config-backed paths, the bootstrap omits the optional
assistantAgentId field without config, the UI store starts null, and agent
selection adopts the roster default once agents.list arrives.
@steipete
steipete force-pushed the fix/gateway-assistant-identity-default branch from 41eea47 to f089cf4 Compare July 27, 2026 03:35
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 27, 2026
@steipete
steipete merged commit bb55d44 into main Jul 27, 2026
127 of 129 checks passed
@steipete
steipete deleted the fix/gateway-assistant-identity-default branch July 27, 2026 03:48
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@steipete

Copy link
Copy Markdown
Contributor Author

Post-deploy verification from team.openclaw.ai, as promised. Deploy be50034bb (this PR plus the rest of the fleet: #114237, #114303, #114311, #114324, #114338, #114358, #114362, #114363) ran 2026-07-26 06:14 → 2026-07-27 06:50 UTC; deploy 9a0fa8f3756 (adds #114266) went live 06:52 UTC.

Clean-idle snapshot (first minutes after deploy, per-method journal latency):

  • unknown agent id "main" errors: 0 (previously continuous on every UI boot; the 49 stragglers over the full soak window all trace to pre-deploy browser tabs still running the old bundle)
  • sessions.catalog.list and config.get dropped off the top-latency list entirely (pre-fix avgs 620ms / ~450ms)
  • chat.startup 436ms → 351ms avg
  • channels.status 2441ms → 659ms

Full 24.6h soak aggregate (with an honest caveat):

  25368  avg   270ms  max 30317ms  controlUi.sessionPullRequests (UNAVAILABLE spam, see below)
   3143  avg  1112ms  max 27203ms  sessions.catalog.list
   2707  avg  1294ms  max  9073ms  sessions.list
   2735  avg   192ms  max  1101ms  board.get
    278  avg   474ms  max  1222ms  chat.startup
    253  avg   481ms  max  2883ms  config.get

The aggregate sessions.list/sessions.catalog.list averages are inflated by a newly identified bottleneck, not by regressions in these fixes: sessions.files.list runs a synchronous full-transcript scan per request (avg 4.7s, max 78s on large sessions) and blocks the event loop; slow-neighbor spikes correlate exactly with Files-panel usage windows in the journal. An incremental touched-files fold using the append-stable transcript delta cursor is in review and will get its own PR.

The controlUi.sessionPullRequests UNAVAILABLE storm (25k responses over the window) is the client retry loop fixed by #114266, deployed 06:52 UTC — it drains as browser tabs reload onto the new bundle.

Error rate excluding that spam: 319 over 24.6h (~13/h), zero crashes, RSS steady ~820MB.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 27, 2026
…r resolution (openclaw#114257)

Three fabrication points told clients the assistant agent was "main" before
any roster/config resolution: DEFAULT_ASSISTANT_IDENTITY in
src/gateway/assistant-identity.ts, the Control UI store's initial snapshot
(ui/src/app/gateway-store.ts:65), and its hello fallback (:336). On installs
whose implicit main agent is retired, every page reload fired
sessions.catalog.list for the nonexistent agent and flashed
'unknown agent id "main"' in the sidebar.

The no-roster state now carries no agent id: DEFAULT_ASSISTANT_IDENTITY drops
agentId, resolveAssistantIdentity returns ResolvedAssistantIdentity (agentId
required) for config-backed paths, the bootstrap omits the optional
assistantAgentId field without config, the UI store starts null, and agent
selection adopts the roster default once agents.list arrives.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant