Repository navigation
fix(agents): answer /btw side questions on gateway-hosted sessions - #118396
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 2, 2026, 11:48 PM ET / August 3, 2026, 03:48 UTC. ClawSweeper reviewWhat this changesThe branch passes the gateway-only prepared-runtime binding from the gateway Merge readinessKeep this PR open for normal merge review: current main still has the gateway Priority: P1 Review scores
Verification
How this fits togetherGateway flowchart LR
A[Gateway /btw command] --> B[Side-question helper]
C[Embedded TUI /btw] --> B
B --> D[Prepared runtime owner lookup]
E[Gateway startup publishes owner] --> D
D --> F[Prepared model runtime]
F --> G[Side-question reply]
C -. no gateway binding .-> B
Before merge
Agent review detailsSecurityNone. PR surfaceSource +10, Tests +91. Total +101 across 5 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the caller-scoped gateway binding with the owner-selection, gateway-input, and embedded-TUI regression pins intact, then let normal CI validate the clean merge result. Do we have a high-confidence way to reproduce the issue? Yes: current main’s Is this the best way to solve the issue? Yes: passing the binding only from the gateway command handler is the narrowest maintainable repair. Putting the grant in the shared helper would incorrectly broaden gateway capabilities to the embedded TUI, while changing owner keying would weaken the existing lifecycle identity contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c89e57dd4517. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
|
@clawsweeper re-review Added the after-fix live proof to the PR body: the same gateway-hosted |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
/btw resolved its prepared model runtime without allowGatewaySubagentBinding, but that flag became part of the prepared-runtime owner identity in openclaw#117587, and gateway startup publishes configured owners with it set. The request therefore matched no published owner, and standalone activation is refused while the gateway lifecycle owns configured identities - so every gateway-hosted /btw failed with 'prepared model runtime owner was not published' before any side-question work was dispatched. The embedded TUI path has no gateway lifecycle and kept working. Thread the flag from the gateway-originated caller instead of granting it in the shared helper: runBtwSideQuestion takes an explicit optional allowGatewaySubagentBinding param, the /btw command handler (auto-reply/reply/commands-btw.ts) opts in the way its sibling handlers commands-compact.ts and commands-system-prompt.ts already do at the same layer, and the embedded TUI call site stays unset so local side questions keep the local-runtime boundary and cannot borrow the active registry's subagent and node capabilities. Pins: the gateway request input and the helper's no-grant default in btw.test.ts, the TUI call-site absence in embedded-backend.test.ts, and the owner-keying constraint in prepared-model-runtime.owner-selection.test.ts.
61d7e57 to
eb510cb
Compare
|
@clawsweeper re-review The P1 is addressed: the binding grant moved out of the shared helper. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review No code change since |
|
Security owner approval for |
|
Merged via squash.
|
…penclaw#118396) /btw resolved its prepared model runtime without allowGatewaySubagentBinding, but that flag became part of the prepared-runtime owner identity in openclaw#117587, and gateway startup publishes configured owners with it set. The request therefore matched no published owner, and standalone activation is refused while the gateway lifecycle owns configured identities - so every gateway-hosted /btw failed with 'prepared model runtime owner was not published' before any side-question work was dispatched. The embedded TUI path has no gateway lifecycle and kept working. Thread the flag from the gateway-originated caller instead of granting it in the shared helper: runBtwSideQuestion takes an explicit optional allowGatewaySubagentBinding param, the /btw command handler (auto-reply/reply/commands-btw.ts) opts in the way its sibling handlers commands-compact.ts and commands-system-prompt.ts already do at the same layer, and the embedded TUI call site stays unset so local side questions keep the local-runtime boundary and cannot borrow the active registry's subagent and node capabilities. Pins: the gateway request input and the helper's no-grant default in btw.test.ts, the TUI call-site absence in embedded-backend.test.ts, and the owner-keying constraint in prepared-model-runtime.owner-selection.test.ts.
Closes #118395
What Problem This Solves
Fixes an issue where users running a gateway would see every
/btwside question failinstantly with
⚠️ /btw failed: prepared model runtime owner was not published for <agentDir>,while the main agent turn on the same session kept working. This affected every gateway-hosted
session on current main, regardless of provider or model; only the embedded TUI was unaffected.
Why This Change Was Made
/btwresolved its prepared model runtime withoutallowGatewaySubagentBinding, but that flagbecame part of the prepared-runtime owner identity in #117587, and gateway startup publishes
configured owners with it set. The request therefore matched no published owner, and standalone
activation is deliberately refused while the gateway lifecycle owns configured identities — so
resolution failed before any side-question work was dispatched. The fix passes the flag,
matching what the gateway publishes and what the agent RPC path already sends; the two paths
now resolve the same owner. No owner-keying or lifecycle behavior is changed.
User Impact
/btwanswers side questions again on gateway-hosted sessions, using the same prepared runtimeas the main conversation. Embedded TUI behavior is unchanged.
Evidence
Two focused tests, both of which fail without the one-line change:
src/agents/btw.test.ts— "resolves the prepared runtime the way gateway-published ownersare keyed" pins the input
/btwsends, which is the regression itself. This is the test thatgoes red when the fix is reverted.
src/agents/prepared-model-runtime.owner-selection.test.ts— "resolves a gateway-publishedowner only for requests carrying the binding flag" exercises real owner resolution: it
publishes configured owners the way gateway startup does (
gatewayLifecycle: true,allowGatewaySubagentBinding: true, static catalog), then asserts the request resolves withthe flag and still throws
prepared model runtime owner was not publishedwithout it. Thisdocuments the constraint that was silently broken.
Neither test needs a model or network.
The blind spot that let this ship is that gateway tests mock
runBtwSideQuestion(
src/gateway/test-helpers.mocks.ts:256-261) andbtw.test.tsmocks the wholeprepared-model-runtimemodule, so nothing exercised real owner resolution on this path. Thesecond test closes that gap at the owner-selection layer.
Review follow-up: the binding grant is scoped to the gateway caller
The prepared-runtime binding grant is scoped to the caller that actually needs it.
runBtwSideQuestionis shared: the gateway/btwcommand handler reaches it throughchannel ingress, while the embedded TUI calls it directly and in-process. Granting
allowGatewaySubagentBindinginside the shared helper would have let embedded-TUI sidequestions borrow the active registry's subagent and node capabilities, which the local
path must not gain by default. The flag is therefore an explicit optional parameter on
runBtwSideQuestion, passed astrueonly fromsrc/auto-reply/reply/commands-btw.tsand left unset by
src/tui/embedded-backend.ts. The auto-reply command handler is theright place for that grant because it is already the repo's gateway-scoped authority
layer — sibling handlers
commands-compact.ts:270andcommands-system-prompt.ts:207set the same flag at the same layer — so the grant stays visible in the caller's own
source rather than being inferred from global lifecycle state, and any future
non-gateway caller inherits the safe default.
Three regression pins, each red in a different direction: the gateway case must pass the
flag (
btw.test.ts), the helper must not add it on its own (btw.test.ts, the P1), andthe embedded TUI call site must not pass it (
embedded-backend.test.ts):After-fix live proof (real gateway, real Codex app-server)
Same lane as the issue repro: an in-process gateway (token auth, codex plugin, real
codex-cli 0.146.0app-server behind a transparent stdio tee that captures the JSON-RPCstream), one real attempt turn, then
/btwin the same session. Recorded before on theunmodified base and after with only this PR's one-line change applied. Paths/ids
redacted.
Before —
/btwfails instantly; the side question never reaches the app-server(
thread/fork: 0 occurrences in the capture):{"type":"event","event":"chat.side_result","payload":{"kind":"btw", "runId":"idem-[UUID]-relay-proof-side","sessionKey":"agent:dev:relay-proof-baseline", "question":"Reply with exactly RELAY-SIDE-BASELINE-[NONCE] and nothing else.", "text":"⚠️ /btw failed: prepared model runtime owner was not published for [STATE_DIR]/agents/dev/agent", "isError":true,"ts":"[TS]","seq":1},"seq":83}After — the same
/btwanswers; the reply surfaces as a successchat.side_resultframe and the fork reaches the app-server:
thread/forkpresent in the app-server JSON-RPC capture (was 0 before the fix):Repeated across four independent gateway sessions (four modes of a live capture lane);
all four completed their
/btwround trip and echoed their nonce:The only delta between the failing and passing recordings is this PR's one-line change in
src/agents/btw.ts.For the reviewer's environment
eb510cbd3d(single commit over currentmain).(This PR touches no Codex protocol surface — the fix and its tests live entirely in
OpenClaw's prepared-runtime owner selection and
/btwplumbing; the app-server capture inthe proof merely demonstrates the side question reaching the harness.)