Repository navigation
fix: preserve tasks following text directives - #138545
Conversation
Keep native argument ownership strict while preserving complete text directive arguments and mixed tasks. Retain positional exec rejection and cover the full reply pipeline. Closes #138530
|
🦞👀 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 maintainer review before merge. Reviewed September 4, 2026, 8:04 PM ET / September 5, 2026, 00:04 UTC. ClawSweeper reviewWhat this changesPreserves tasks and their whitespace after text slash directives, while retaining strict native-command validation and rejecting malformed positional /exec arguments. Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review No blocking findings. This remains a necessary repair for the source-proven regression on pinned main; the linked issue should remain open until the repair lands. Priority: P1 Review scores
Verification
How this fits togetherThe shared reply pipeline interprets authorized chat directives before deciding whether to acknowledge settings or run an agent. Its output includes the remaining task text, per-message execution policy, and any session-setting changes. flowchart TD
A[Incoming chat text] --> B[Existing sender authorization]
B --> C[Text or native command]
C --> D[Command normalization and directive parsing]
D --> E{Settings only or task remains}
E --> F[Settings acknowledgment or argument error]
E --> G[Agent task with per-message policy]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +20, Tests +176, Other 0. Total +196 across 15 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. Technical reviewBest possible solution: Keep one inline parser with opt-in lossless text normalization and early malformed-exec classification; the small production increase protects distinct text/native contracts without replacing existing plugin defaults. Do we have a high-confidence way to reproduce the issue? Yes, source establishes a high-confidence path on pinned main: submit an authorized text /exec policy followed by a task on the same line or next line. The supplied failing full-reply and Gateway results corroborate that mechanism; this read-only review did not execute it. Is this the best way to solve the issue? Yes, this repairs the shared owner using existing extractors rather than adding a competing parser. Globally changing normalization would affect standalone commands, while removing strict ownership entirely would reopen malformed positional-exec handling. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 62ff6248557c. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Merged via squash.
|
* fix: preserve tasks following text directives Keep native argument ownership strict while preserving complete text directive arguments and mixed tasks. Retain positional exec rejection and cover the full reply pipeline. Closes openclaw#138530 * fix(qa): follow canonical directive argument helper * fix: validate raw text exec argument boundaries
…tch turns An inline reply directive that rejects before any model run starts — a restricted explicit /model request, a locked model selection, conflicting scope flags, an unsupported runtime, a native command with leftover arguments, or a session transaction that loses its compare-and-swap — returned the error reply to the sender while the dispatch terminal outcome still reported `completed` with no reason. The `message.processed` diagnostic event therefore showed a normal successful turn and investigators had no trace to correlate the rejection against (openclaw#137198). The rejection facts already existed at the directive owners; they were dropped once the reply left the directive layer. Rather than emitting a parallel event, this records the rejection on the existing `ReplyOperationRunState` reply-option channel — the same pattern `messageInjectionAborted` already uses — and lets the dispatch finalize step, which already owns the terminal outcome, read it: - `applyInlineDirectiveOverrides` returns a `preRunRejection` (closed `ReplyPreRunRejectionCode` + reply text) from each of its 7 rejection sites through one shared `directiveRejection` helper. - The `ModelSelectionLockedError` catch sites in `get-reply.ts` record the same closed `model-selection-locked` code through one canonical `recordReplyPreRunRejection` helper on the run state. - The dispatch finalizer reports `skipped` with the closed code as the `reason` and the reply text as `error` on `message.processed`. Rebuilt onto current `main` after openclaw#138545's directive-handling refactor: the unexpected-argument rejection rides the renamed `maybeHandleUnexpectedDirectiveArguments` (return type narrowed so the closed code carries the reply text), directive inspection uses the refactored `directives.command` shape, the real-stream test passes the now-required prepared conversation, and the queue-disposition binder the refactor left caller-less is not carried over. On current `main` the unexpected-argument branch still returns a bare reply without recording a rejection, so the reported gap remains real. Co-Authored-By: Claude <[email protected]>
Closes #138530
Additional instructions
This branch is in
openclaw/openclaw, available for maintainers to edit directly.Problem and fix
A text directive followed by a task could finish with an argument error or a settings acknowledgment instead of an agent reply. For example,
/exec security=deny ask=always Explain the output.rejectedExplain, while putting the task on the next line produced only an acknowledgment. The release Gateway regression also reproduced/think highfollowed by a multiline task completing without any provider request.Text directives had acquired native commands' exclusive argument ownership and were parsed from canonical command text that discards later lines. This repair preserves complete text arguments during alias and bot-address normalization, then uses the existing inline directive parser. Native commands retain strict argument validation. The argument validator and metadata now describe command ownership rather than treating text as native.
Malformed text
/execarguments are classified from the original input before sibling directives can consume them. This prevents/exec /think highand/exec /think high host=gatewayfrom applying sibling settings instead of rejecting/think. Leading spaces or newline indentation no longer produce an empty unexpected-argument diagnostic. Only the displayed diagnostic token is trimmed; task bytes remain intact.Behavior and scope
Valid text directives can precede same-line or multiline tasks, with code indentation, tabs, repeated spaces, and trailing whitespace preserved. Coverage includes colon syntax, aliases, addressed commands, multiple directives, disabled-text routing, per-turn overrides, and directives addressed to another bot. Invalid positional
/exec gatewaystill receives a command error. No configuration, protocol, or persistence format changes.Production grows by 20 lines and tests by 176 lines across the complete PR. The final follow-up contributes production +7 and tests +60: the parser adds six net lines to establish raw-argument ownership before destructive extraction, and the diagnostic expression wraps by one line. The preliminary parse reuses the canonical exec extractor and removes late classification; no separate argument policy is introduced. The QA scenario reference follows the validator rename to
directive-handling.arguments.ts.Verification
Final source:
d0b816bc081317b60fe43d2a7fb9b608042fe6ba. This is the exact tree tested before commit as base5c6fbc77406dcb797bbc5c3af9ab65e73a7ef435plus patch SHA-2564d394b0ef1b3097ec48430d86ca854d9b0f5f948d4c5462fcc82035bd52237bb.2329399cf6a9a2ca0c19d6c620b713a2768f9125: the run returnsok, a thinking-level acknowledgment is recorded, and the first provider request is absent. It passes after the repair.no-map-spreadviolation; explicit fields fixed it, and the complete gate passed on retry.The Gateway test uses a real ephemeral Gateway and a mock OpenAI-compatible HTTP provider. Two turns verify the first provider request's raw task whitespace, immediate directive removal, canonical chat history, and original directive replay on the second turn. Sibling Gateway cases cover explicit agent ownership, attachments, native dispatch, final-effect settings, and stale-send rejection.
The following is a maintainer summary of observed harness results, not a verdict file emitted by the harness:
{ "sourceCommit": "d0b816bc081317b60fe43d2a7fb9b608042fe6ba", "testedBase": "5c6fbc77406dcb797bbc5c3af9ab65e73a7ef435", "patchSha256": "4d394b0ef1b3097ec48430d86ca854d9b0f5f948d4c5462fcc82035bd52237bb", "build": "canonical private-QA and AI runtime passed", "unitTestsPassed": 300, "gatewayTestsPassed": 8, "gateway": "real ephemeral process", "provider": "mock HTTP provider", "firstRequestWhitespaceAndHistoryReplay": "passed across two turns", "telegramLive": "not run" }Reproduction and final proof commands:
The parent-relative patch in #137562 (
2f6a3d8fb126707b3661299894388a8c4f4e1d81, parentf959cc71e28ee298fdcf41119f5dac5092347f5c) establishes the regression's source provenance. Existing directive documentation already describes the restored behavior.Remaining channel proof
ClawSweeper's latest review requested a Telegram Test Server event timeline and a rationale for production growth. The ownership rationale is above. Authenticated Telegram Test Server broker access was unavailable, so Telegram live proof was not run; no Telegram event proof or proof exception is claimed. Real Gateway/mock-provider evidence is identified separately above.
Named follow-up: preserve multiline Telegram command projection at ingress. Telegram separately normalizes its command body before this core boundary (
extensions/telegram/src/bot-message-context.session.ts). That preexisting producer behavior can discard later setting lines. This PR's multiline directive proof uses intact core command text and does not claim to repair Telegram multiline settings.