Repository navigation
fix(gateway): give refusals an honest cause and a next step - #202402
Conversation
- Preserve structured message-policy refusals and explain how to retry ended turns and approvals. - Settle approvals cancelled during preparation before delivering a pending prompt. - Explain replaced OpenClaw chats in the existing proposal and audit owners.
|
🦞👀 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: needs changes before merge. What this changesThis PR makes Gateway refusals actionable, preserves structured policy errors, and cancels approvals stopped during preparation before prompting. Example: Stop ends run run-stopped-during-preparation while its exec approval is being prepared.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 2 items remain Keep this maintainer-authored PR open: it addresses concrete refusal and cancellation problems, but two diff-caused CI failures require repair. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherGateway handlers accept agent message and approval requests, apply existing authority and persistence rules, and return delivery results, approval prompts, or refusal messages. flowchart TD
A[Agent or client request] --> B[Gateway admission]
B --> C[Message routing and delivery]
B --> D[Approval registration]
D --> E[Existing cancellation manager]
D --> F[Approval prompt]
C --> G[Structured result or refusal]
E --> G
Technical reviewBest possible solution: Keep the existing refusal and cancellation owners, complete the consumer-test updates, and resolve diagnostic-text ratchet matches without expanding identity allowances. Do we have a high-confidence way to reproduce the issue? Source shows preparation yielding before approval registration, allowing Stop's cancellation sweep to miss the record; the added handler regression exercises that ordering, but no target code was run during this review. Is this the best way to solve the issue? The production repair is focused and reuses existing state and cancellation operations; the remaining concrete defects are incomplete consumer validation and diagnostic wording that fails the existing ratchet. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d6817c218df7. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +58, Tests +132. Total +190 across 19 files. Added test files: 1. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 20, 2026, 5:03 AM ET / 10:03 UTC. |
- Remove cause-selection branches from approval refusals while preserving the existing guards. - Use one corrective-stop notice with a clear recovery step. - Update Teams and Slack ended-turn expectations without changing effect assertions.
- Restore the existing plugin-review and corrective-attempt notices unchanged. - Keep actionable chat persistence guidance at the user-visible audit fence. - Limit the new Teams ended-turn expectation to Gateway reads.
## Problem `channel-run-admission.discord-recovery.test.ts` (#202330) pinned the exact refused-followup notice. #202402 then added a next step to that notice in its owner (`agent-runner-error-handler.ts`), so the test fails on `main` whenever it is selected. ## Fix Stop pinning wording. The test still proves the behavior: one terminal error event with a notice, the same notice shown once in the transcript, the same text delivered for the unavailable case, and no model or channel effects for a revoked sender. ## Evidence `ocx test src/auto-reply/reply/channel-run-admission.discord-recovery.test.ts`: passed. oxfmt and test types clean. Co-authored-by: Ayaan Zaidi <[email protected]>
…#202402) Problem: several user-facing refusals were honest but had no next step or used internal words: "message action authority is no longer active" for an ended message turn, "approval consumption is no longer available", "approval record is no longer current", "approval run already aborted", the owner notice for a refused queued request (openclaw#202252), and "OpenClaw session changed during audit persistence". A Stop during approval preparation could also miss the cancellation sweep, so the user still got an approval prompt for stopped work. Fix (text in existing owners, no new error types and no identity comparisons): "The message turn has ended. Start a new turn to retry."; "This approval is no longer available. Start a new turn to request approval again."; "The approval run was stopped. Start a new turn to request approval again."; the owner notice adds "Review the channel access settings; once access is restored, ask the requester to send the request again."; the system-agent audit fence reads "This OpenClaw chat changed while the change was being saved. Check the current settings before making a new request." Main's two specific corrective notices are unchanged. Approval registration that finds the run already stopped settles the record as cancelled before any prompt is delivered. Proof: Stop-during-preparation regression red on base, green with the fix; affected Slack, Teams, approval and system-agent suites; session-identity ratchet, oxlint, format; clean exact-head local ClawSweeper review; real Gateway run (Stop on a real-model exec: no approval prompt, the run cancelled, the new stopped-run wording returned). Co-authored-by: Ayaan Zaidi <[email protected]>
…#202471) ## Problem `channel-run-admission.discord-recovery.test.ts` (openclaw#202330) pinned the exact refused-followup notice. openclaw#202402 then added a next step to that notice in its owner (`agent-runner-error-handler.ts`), so the test fails on `main` whenever it is selected. ## Fix Stop pinning wording. The test still proves the behavior: one terminal error event with a notice, the same notice shown once in the transcript, the same text delivered for the unavailable case, and no model or channel effects for a revoked sender. ## Evidence `ocx test src/auto-reply/reply/channel-run-admission.discord-recovery.test.ts`: passed. oxfmt and test types clean. Co-authored-by: Ayaan Zaidi <[email protected]>
## Problem `channel-run-admission.discord-recovery.test.ts` (#202330) pinned the exact refused-followup notice. #202402 then added a next step to that notice in its owner (`agent-runner-error-handler.ts`), so the test fails on `main` whenever it is selected. ## Fix Stop pinning wording. The test still proves the behavior: one terminal error event with a notice, the same notice shown once in the transcript, the same text delivered for the unavailable case, and no model or channel effects for a revoked sender. ## Evidence `ocx test src/auto-reply/reply/channel-run-admission.discord-recovery.test.ts`: passed. oxfmt and test types clean. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 656de08) Companion of #202330 (gap-sweep): its regression pinned notice wording that this branch already extended (4eb5484); main fixed the test the same way. Co-authored-by: RomneyDa <[email protected]>
What problem this solves
Several refusals that users see were honest but gave no next step, or named the wrong cause, or used internal words:
Also, a Stop during approval preparation could miss the cancellation sweep, so the user still got an approval prompt for work they had already stopped (from #201812).
Change
Text, inside the existing owners (no new error types or notice writers):
Behavior: when approval registration finds the run already stopped (the existing abort marker), it settles the record as cancelled through the existing cancellation owner before any prompt is delivered.
Evidence
Proof tier: source (
ocx test) plus a real Gateway run (see the PR comment).openclaw.chatsession-replaced regression shows the new outer and inner texts.pnpm tsgo, type-aware oxlint on all 19 touched files, format, and the lifetime-check and line-cap ratchets: pass.