Repository navigation
feat(tui): answer agent questions in gateway and local modes - #143273
Conversation
Render session-owned questions with choices, Other, multi-select, a stepper, Skip, expiry, and /question. Restore pending prompts after reconnect and session changes, and keep masked input outside the composer and history. Serve local questions through QuestionManager and claim eligible replies before queue policy so answers cannot wait behind their blocked run. Keep local secret-store requests blocked with explicit setup guidance. Recover uncertain resolutions without replaying input and surface saved secret refresh failures without exposing submitted values. Validation: 1,893 focused and sibling tests; 102 PTY tests; isolated Gateway and local scripted-model round trips; full build; check:changed; docs checks; independent P0-P2 review. The broader docs anchor audit reports three existing broken links in untouched generated maturity pages.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 9, 2026, 1:48 PM ET / 17:48 UTC (Revision 3). ClawSweeper reviewWhat this changesAdds interactive agent-question prompts to Gateway-connected and local terminal sessions, including masked Gateway secret entry and plain replies that resume waiting local runs. Merge readiness⛔ Blocked before merge - 1 item remains The PR remains useful and has no supported blocking findings. The prior migration concern is resolved: runtime questions remain in memory, and the added serialized files are isolated proof artifacts. Current main still lacks the terminal question flow. Priority: P2 Review scores
Verification
How this fits togetherThe terminal UI connects either to a Gateway or an embedded local agent. Its question controller presents pending agent questions and returns operator answers to the existing question lifecycle; secret-store writes remain Gateway-owned. flowchart TD
A[Agent requests human input] --> B{Terminal mode}
B -->|Gateway| C[Existing question RPCs]
B -->|Local| D[In-process question broker]
C --> E[Session question prompt]
D --> E
E --> F[Operator answers or skips]
F --> C
F --> D
C --> G[Resume agent or store secret]
D --> H[Resume local agent]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +1231, Tests +1494, Docs +58, Config +1, Other +570. Total +3354 across 29 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Use one shared terminal question controller with existing Gateway contracts, process-owned local questions, and Gateway-owned secret storage. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main lacks terminal question presentation and sends default local question requests toward the Gateway. This review did not execute a failing runtime case. Is this the best way to solve the issue? Yes. Reusing the existing question manager and RPC contracts addresses the missing terminal path without a parallel persistent store, protocol change, or new configuration. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against fc3bb9f5e3a9. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Merged via squash.
|
…w#143273) * feat(tui): answer agent questions in gateway and local modes Render session-owned questions with choices, Other, multi-select, a stepper, Skip, expiry, and /question. Restore pending prompts after reconnect and session changes, and keep masked input outside the composer and history. Serve local questions through QuestionManager and claim eligible replies before queue policy so answers cannot wait behind their blocked run. Keep local secret-store requests blocked with explicit setup guidance. Recover uncertain resolutions without replaying input and surface saved secret refresh failures without exposing submitted values. Validation: 1,893 focused and sibling tests; 102 PTY tests; isolated Gateway and local scripted-model round trips; full build; check:changed; docs checks; independent P0-P2 review. The broader docs anchor audit reports three existing broken links in untouched generated maturity pages. * fix(ci): register the TUI question proof command
Related: #120656 #143238
What Problem This Solves
Fixes an issue where an agent calling
ask_userin the terminal UI left the user with nothing to answer: the TUI never rendered the question, only the raw tool call, and in local mode (openclaw chat,openclaw tui --local) the tool's question RPCs went to a Gateway that usually is not running, so the request failed outright. Thesecretstool had the same gap, which is part of why the local TUI could only fall back to asking for credentials in chat (#120656). Ordinary answers typed while a question was pending in collect or followup queue mode also waited behind the blocked run.Why This Change Was Made
Both TUI backends now share one session-scoped question controller. Gateway mode uses the existing
question.*RPCs and events under the scopes the TUI already holds. Local mode serves the same five methods in-process through an embedded question broker wrapping the Gateway'sQuestionManager, registered like the existing embedded plugin-approval broker, and the question dispatcher routes there only when embedded mode has a broker. A typed reply is claimed by the pending question through the active run's guarded input owner before queue policy runs, which is what removed the collect/followup deadlock. Masked answers keep their exact bytes.Store-bound
secretsrequests in local mode return a clear blocker to the model instead of collecting a value the process cannot commit, because the store write and runtime refresh are Gateway-owned. No protocol, schema, config, or Control UI changes.User Impact
ask_userprompts render in the TUI in both modes: one question at a time with a stepper, arrow or number selection, Other… free text, multi-select toggles, Skip, and the time remaining./questionreopens it; a plain reply still answers the pending question.secretsrequests use a masked input that never touches the chat log or input history, showing the entry name, reason, and proposed allowed hosts (accepted as proposed; edit hosts in the Control UI).secretsrequests explain that they need a running Gateway; plain masked questions work.Evidence
Real-model live run on an isolated state directory and free port (never the operator's Gateway), model
anthropic/claude-fable-5-1, driven through tmux; captures are text only and contain no credentials.Local mode, prompt rendered from a real
ask_usercall:After
1+ Enter:Question: answered.followed by the model'sYou chose Blue.A second question was collapsed with Esc (status lineQuestion pending · 899s · /question to open), answered by typingLargeinto the composer, and the model repliedYou chose Large.Gateway mode (
tui --url ws://127.0.0.1:<port>): same prompt, answered2+ Enter, model repliedYou chose Green.Then a realsecretsrequest rendered the masked prompt:After Enter:
Question: answered.and the model repliedThe credential is stored as LIVE_TEST_TOKEN with allowed host example.com.The typed value did not appear in any capture (checked by grep across all frames).Automated proof:
node --import ./scripts/tsx.mjs scripts/dev/tui-questions-proof.tsruns an isolated Gateway plus TUI and a local TUI with a scripted OpenAI-compatible model, verifying option resolution and the Esc/plain-reply continuation from the model's request bodies.Tests: 1,893 tests across 62 files in the TUI, infra, harness, tools, runner, and Gateway question suites, plus 102 PTY tests. The exact-secret-byte cases fail on the original
QuestionManagerand pass with the fix.node scripts/check-changed.mjspassed all selected gates;pnpm buildclean; docs mdx, link audit, glossary, and markdownlint pass. Codex autoreview (P0–P2): scoped-clean.Known limits: the overlay host composites prompts over the chat log, so long background lines show at the overlay margins, the same as the existing plugin-approval overlay; secret input is single-line (use the CLI
--value-fileroute for multiline values); local-mode questions do not survive exiting the TUI.Overlay update: question prompts now use Pi TUI's supported
width: "100%"option, resolving the background-chat margin limitation noted above.Data-model compatibility evidence
The serialized writes in
scripts/dev/tui-questions-proof.tsare isolated proof fixtures and requested evidence artifacts, not a runtime data-model change. The script creates its own temporary state and removes it after verified child cleanup, retaining only terminal frames and answer witnesses in the requested output directory. The repeatable proof passed Gateway selection, local selection, and local Esc/plain-reply continuation.Runtime questions remain in QuestionManager's in-memory map. The embedded broker reuses that manager and rejects store-bound requests. The diff from the rebased parent leaves
packages/gateway-protocol,src/config,src/secrets, andsrc/gateway/server-methods/question.tsunchanged. Existing persisted formats and the Gateway secret-store write path are preserved; this change requires no data migration or upgrade conversion.