Repository navigation
fix(gateway): return one chat history entry per user turn - #169434
Conversation
|
🦞👀 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. What this changesThe PR marks inline command acknowledgements so transcript mirroring does not record their accompanying user prompt twice. Example: Send
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR fixes a source-confirmed duplicate-history regression, with no actionable code findings. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe shared reply dispatcher delivers command and model replies and records eligible exchanges in the session transcript used by chat.history and later model turns. flowchart TD
A[Inbound prompt] --> B[Inline action owner]
B --> C[Normal model turn]
B --> D[Marked acknowledgement]
C --> E[Session transcript]
D --> F[Reply dispatcher]
F --> G[Command mirror admission]
G --> E
Technical reviewBest possible solution: Keep normal turn persistence authoritative for inline prompts while preserving delivered-command recording for standalone exchanges. Do we have a high-confidence way to reproduce the issue? Current-main source exposes the second command-input writer, and the author reports a matching failing Gateway scenario; this review executed no target code. Is this the best way to solve the issue? Producer-owned metadata repairs the shown ownership error without text deduplication, changing stored formats, or broadening the patch into a dispatcher refactor. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b3c7dc2af7dd. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +3, Tests +54. Total +57 across 5 files. Added test files: 1. View PR surface stats
Review metrics
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 HistoryReview history (1 earlier review cycle)
Reviewed October 11, 2026, 8:01 PM ET / October 12, 2026, 00:01 UTC (Revision 2). |
|
Runtime evidence for the Gateway scenario ( Before (main-based head After (this head
CI note: the |
|
Maintainer override (Ayaan approved landing): the only red job on this head (14784a2) is
|
…rns (#169475) ## What Problem This Solves Fixes the WebChat media-artifact proof treating a revision of one user message as a duplicate user turn. This is an explicitly requested main CI repair. ## User Impact No product behavior changes. The proof still rejects duplicate canonical user turns and still checks every supported/rejected media outcome. ## Why This Change Was Made The user-turn owner publishes the initial transcript append and then a revision of that same message when its first-sent model prompt projection is captured. `session.message` therefore is not a one-event-per-message protocol. Check nonempty canonical message IDs and require one unique ID, and independently require one persisted user turn in `chat.history`. This is not #169434: this scenario sends an ordinary `Reply exactly ...` request, not an inline slash-command acknowledgement. ## Evidence Baseline: `5889e62f4902b8f3fa4b6eb2cecbbd26f5b8ceb0`. - Before: `webchat-media-artifacts.e2e.test.ts` failed at `userEvents` length, expected 1 and received 2. - Source: `capturePersistedModelPromptProjection` republishes the same transcript `entryId`; the UI already reconciles same-ID event revisions. - Existing attachment-success, attachment-error, missing-file, mixed-batch and rendered-content checks remain intact. - After: the complete WebChat media matrix passed (1/1), including the new canonical-ID and persisted-user-turn assertions. - A loaded-host attempt timed out; an isolated run finished in 41.5 seconds without changing timeouts. - Independent autoreview: scoped-clean at P2. - Root test typechecks (all four shards), changed-file Oxlint/Oxfmt, and the line-cap ratchet passed. Co-authored-by: Ayaan Zaidi <[email protected]>
…69434) Related: openclaw#168843 ## What Problem This Solves Fixes duplicate user turns in `chat.history` when a message starts with an inline directive such as `/think high` and continues with an ordinary prompt. ## User Impact One `chat.send` produces one user-history entry, preserving the original prompt and its whitespace. Standalone slash commands, native command errors, and their delivered replies keep their existing history behavior. Existing transcripts are not rewritten. ## Why This Change Was Made Regression introduced by openclaw#169026 (`afb47c66b96d2408160ca91de63e3cd930403832`): command mirroring classified a delivered inline acknowledgement by the inbound message's `/` prefix. The normal user-turn owner had already persisted `<run>:user`; command mirroring then persisted the same input again under `command-input:[channel,account,conversation,run]`, with array content instead of string content. The inline-reply producer now records private `inlineCommandReply` metadata. Both block and final transcript-mirror admission honor that ownership fact instead of creating another command exchange. There is no content-based dedupe or text-parser heuristic. A focused suite protects producer metadata and both delivery paths; its existing producer case moved out of an oversized suite without removing assertions. No overlap with Pash/Sarah changes. ## Evidence - Before: the whitespace Gateway RPC test failed on main-based `ed1bc51edb0`, expecting one user message and receiving two identical prompts (string and text-block-array shapes). The two persisted identities were traced to normal turn admission and the command mirror introduced by openclaw#169026. - After: `preserves model-input whitespace independently from canonical chat history` passed through the real Gateway and mock provider (two turns, exact whitespace assertions, one history entry per turn). The temporary fixture from openclaw#168961 was used, with its replay assertion adjusted to the stable model-prompt projection introduced by openclaw#167938; none of those fixture changes are in this PR. - The other eight `gateway-rpc-chat.e2e.test.ts` cases passed in the full-file run. - Four focused unit suites passed: 202 tests, including producer metadata, block/final mirror exclusion, and existing standalone command coverage. - Runtime build, `tsgo:core`, formatting, line-cap growth ratchet, and oxlint on the other four changed files passed. The initial raw oxlint invocation reported the pre-existing over-cap `dispatch-from-config.choose-route.ts`; this file has no counted-line growth. - Independent source review: no remaining findings. Merge danger: **two-way door**. Reverting restores the old inline-acknowledgement mirroring behavior. No schema, stored-data migration, or configuration changes; the blast radius is transcript mirroring of inline command acknowledgements. Co-authored-by: Ayaan Zaidi <[email protected]>
…rns (openclaw#169475) ## What Problem This Solves Fixes the WebChat media-artifact proof treating a revision of one user message as a duplicate user turn. This is an explicitly requested main CI repair. ## User Impact No product behavior changes. The proof still rejects duplicate canonical user turns and still checks every supported/rejected media outcome. ## Why This Change Was Made The user-turn owner publishes the initial transcript append and then a revision of that same message when its first-sent model prompt projection is captured. `session.message` therefore is not a one-event-per-message protocol. Check nonempty canonical message IDs and require one unique ID, and independently require one persisted user turn in `chat.history`. This is not openclaw#169434: this scenario sends an ordinary `Reply exactly ...` request, not an inline slash-command acknowledgement. ## Evidence Baseline: `11f576b23cf70615ca4504eb12fdba93591b9c8f`. - Before: `webchat-media-artifacts.e2e.test.ts` failed at `userEvents` length, expected 1 and received 2. - Source: `capturePersistedModelPromptProjection` republishes the same transcript `entryId`; the UI already reconciles same-ID event revisions. - Existing attachment-success, attachment-error, missing-file, mixed-batch and rendered-content checks remain intact. - After: the complete WebChat media matrix passed (1/1), including the new canonical-ID and persisted-user-turn assertions. - A loaded-host attempt timed out; an isolated run finished in 41.5 seconds without changing timeouts. - Independent autoreview: scoped-clean at P2. - Root test typechecks (all four shards), changed-file Oxlint/Oxfmt, and the line-cap ratchet passed. Co-authored-by: Ayaan Zaidi <[email protected]>
Related: #168843
What Problem This Solves
Fixes duplicate user turns in
chat.historywhen a message starts with an inline directive such as/think highand continues with an ordinary prompt.User Impact
One
chat.sendproduces one user-history entry, preserving the original prompt and its whitespace. Standalone slash commands, native command errors, and their delivered replies keep their existing history behavior. Existing transcripts are not rewritten.Why This Change Was Made
Regression introduced by #169026 (
289d859c2babddd9f5aee9dda96fbb94c5107f70): command mirroring classified a delivered inline acknowledgement by the inbound message's/prefix. The normal user-turn owner had already persisted<run>:user; command mirroring then persisted the same input again undercommand-input:[channel,account,conversation,run], with array content instead of string content.The inline-reply producer now records private
inlineCommandReplymetadata. Both block and final transcript-mirror admission honor that ownership fact instead of creating another command exchange. There is no content-based dedupe or text-parser heuristic. A focused suite protects producer metadata and both delivery paths; its existing producer case moved out of an oversized suite without removing assertions.Evidence
ed1bc51edb0, expecting one user message and receiving two identical prompts (string and text-block-array shapes). The two persisted identities were traced to normal turn admission and the command mirror introduced by fix: retain delivered slash commands in conversation history #169026.preserves model-input whitespace independently from canonical chat historypassed through the real Gateway and mock provider (two turns, exact whitespace assertions, one history entry per turn). The temporary fixture from fix: Gateway regression tests fail after runtime context labeling changes #168961 was used, with its replay assertion adjusted to the stable model-prompt projection introduced by perf(agents): keep enriched user prompt history stable #167938; none of those fixture changes are in this PR.gateway-rpc-chat.e2e.test.tscases passed in the full-file run.tsgo:core, formatting, line-cap growth ratchet, and oxlint on the other four changed files passed. The initial raw oxlint invocation reported the pre-existing over-capdispatch-from-config.choose-route.ts; this file has no counted-line growth.Merge danger: two-way door. Reverting restores the old inline-acknowledgement mirroring behavior. No schema, stored-data migration, or configuration changes; the blast radius is transcript mirroring of inline command acknowledgements.