Skip to content

refactor(auto-reply): normalize inbound text once - #113179

Merged
steipete merged 7 commits into
mainfrom
steipete/simplify-w5-inbound-text
Jul 24, 2026
Merged

steipete merged 7 commits into
mainfrom
steipete/simplify-w5-inbound-text

Conversation

@steipete

@steipete steipete commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The inbound reply flow repeatedly selected text from overlapping legacy fields such as BodyForCommands, CommandBody, RawBody, Transcript, BodyStripped, and Body. Different consumers could therefore make different choices for command parsing, prompt construction, session state, or ACP dispatch from the same message context.

Why This Change Was Made

finalizeInboundContext now normalizes inbound text once into canonical commandText, agentText, and rawText facts. Internal reply, directive, session, prompt, and ACP paths consume those facts directly, while the shipped uppercase fields remain compatibility projections at the public SDK boundary, following the finalized-context convention established by #113042.

MsgContext gains additive canonical fields, but no persisted session row, Gateway protocol schema, or other wire schema is changed. Public legacy fields are not removed. A private non-enumerable finalization marker prevents boundary adapters from reinterpreting authoritative canonical values, including empty strings.

Collision note: #111301 and #112833 are both still open and touch get-reply-run.ts / its media-only suite. This branch preserves their neighboring behavior and was semantically rebased onto current main before proof.

CI merge-tree repair: two iOS release-planner commits landed on main after the first exact-head proof but omitted the new CLI scripts from Knip's root model and its tooling-shard test from two routing expectations. This PR includes that small registration/test repair because the unrelated red main state blocked the merge gate.

User Impact

No intentional user-visible feature change. Commands, directives, prompts, queued turns, and plugin-created contexts now use one consistent normalized text interpretation, reducing drift and making deprecated alias precedence an ingress concern rather than a per-consumer concern.

Evidence

  • Exact branch head: 963c04ec8e6
  • Full src/auto-reply suite on Blacksmith Testbox run 30053560284: 4,467 tests green across three routed shards (738 + 41 + 3,688), including get-reply-run.media-only.test.ts 101/101 and directive/session/templating coverage.
  • Full changed gate on the same head and Testbox: formatting, Plugin SDK API/export/surface checks, core and extension production/test typechecks, lint, import-cycle, and boundary/storage guards.
  • Fresh Codex autoreview after rebase: clean, no accepted/actionable findings.
  • git diff --check and regenerated Plugin SDK API baseline check: clean.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: L maintainer Maintainer-authored PR labels Jul 24, 2026
@steipete steipete self-assigned this Jul 24, 2026
@steipete
steipete marked this pull request as ready for review July 24, 2026 00:00
@steipete
steipete force-pushed the steipete/simplify-w5-inbound-text branch from 4b5f576 to 963c04e Compare July 24, 2026 00:11
@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Jul 24, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Maintainer decision: accept the additive canonical Plugin SDK context contract in this PR.

The supported boundary is:

  • raw/public MsgContext may carry optional commandText, agentText, and rawText;
  • finalizeInboundContext makes those three fields required for internal runtime/template consumers;
  • explicitly supplied canonical values, including empty strings, are authoritative;
  • shipped uppercase fields remain public compatibility projections;
  • no persisted session-row or Gateway protocol schema changes in this PR.

Redacted runtime proof on exact head 963c04ec8e6acd57b8d178a26fae629ec27af6cc, using the production finalizeInboundContextForSdk implementation:

{"case":"legacy-only","canonical":{"commandText":"/status","agentText":"/status","rawText":"legacy raw"},"legacyProjection":{"BodyForCommands":"/status","BodyForAgent":"/status","RawBody":"legacy raw"}}
{"case":"canonical-wins","canonical":{"commandText":"/canonical","agentText":"canonical agent","rawText":"canonical raw"},"legacyProjection":{"BodyForCommands":"/canonical","BodyForAgent":"canonical agent","RawBody":"legacy raw"}}
{"case":"empty-canonical-wins","canonical":{"commandText":"","agentText":"","rawText":""},"legacyProjection":{"BodyForCommands":"","BodyForAgent":"","RawBody":"legacy raw"}}

This covers ClawSweeper's two rank-up moves: inspectable post-fix runtime evidence for legacy-only/canonical/empty-canonical plugin contexts, and explicit maintainer acceptance of the compatibility contract. Exact-head CI run 30055493042 and Testbox changed-gate run 30055521842 are green.

@steipete
steipete merged commit 0dd9dcd into main Jul 24, 2026
129 of 132 checks passed
@steipete
steipete deleted the steipete/simplify-w5-inbound-text branch July 24, 2026 00:39
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 24, 2026
* refactor(auto-reply): canonicalize inbound text once

* chore(plugin-sdk): refresh API baseline

* refactor(auto-reply): narrow finalized template context

* test(auto-reply): keep runner fixtures structurally compatible

* fix(auto-reply): guard optional post-command agent text

* fix(auto-reply): finalize intercepted gateway context

* fix(ci): register iOS release planner entries
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 3, 2026
Block: userText fallback chain in agent-runner-result-complete.ts
(drift residue). Home: restored to upstream (drift residue).

2273ef6 widened buildReplyDiagnosticsPayload's userText to
commandText || agentText || CommandBody || RawBody || BodyForAgent ||
Body. Upstream canonicalized inbound text once in 0dd9dcd (openclaw#113179),
removing those raw-body fallbacks, and 56da574 (openclaw#138695) set this
site to commandText || agentText. Restore upstream's expression; the
surrounding continuation change (skip diagnostics for silent
continuations) stays.

Refs #1418

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant