Skip to content

refactor(auto-reply): consolidate reply preparation and command flows - #166685

Merged
steipete merged 4 commits into
mainfrom
deslop/d02-auto-reply-reply-20261007
Oct 7, 2026
Merged

steipete merged 4 commits into
mainfrom
deslop/d02-auto-reply-reply-20261007

Conversation

@steipete

@steipete steipete commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Reduces duplicated production code throughout reply preparation, command handling, delivery, and lifecycle management. Also fixes ACP reset-target lookup throwing when the optional channel configuration is absent.

User Impact

The refactor preserves existing commands, reply text, config keys, public contracts, persisted shapes, authorization, cancellation, and replay behavior. The adjacent ACP fix uses the existing default-account fallback instead of throwing. No migration or operator action is required.

Why This Change Was Made

Shared cores now own repeated prepared runtime/skill inputs, command variants, delivery settlement, and formatting. Callers keep explicit differences and the original checks around asynchronous work. Redundant state derives from its existing owner, and retired private forwarding modules have complete caller/mock cutovers that retain lazy loading.

The lane implemented and measured a largest-first pass over 418 production files during a two-hour implementation window. Net production reduction after both conflict-only integrations and the boundary repair: 1,589 lines (2,525 added / 4,114 removed), excluding tests, fixtures, test support, generated files, and declarations. This excludes overlapping cleanup independently landed on main. Concrete shared-core trials that added 9, 14, or 15 lines were rejected; a four-line type reduction was reverted to retain an explicit public SDK declaration. Measurements and the per-file coverage log are retained in the lane artifacts.

Evidence

  • ACP regression: the missing-channel-config case failed on the original implementation while the configured-account case passed; the corrected full command suite passed all 74 tests. Single-worker command-file run: 227.80s wall including compiled-worker preparation, 64.81s Vitest time.
  • Behavior coverage is retained; mock/import changes follow retired internal seams. The shared media-context spy now sees initial preparation, so the full-flow test requires exactly one creation; direct execution still requires zero with a supplied context and one without. All media-content, ownership, and delivery assertions remain. The mock-export baseline shrank by 26 entries and the assertion baseline by four allowances, with no new suppression or allowance.
  • Passed: full production build; core production and all core test type shards; Knip (zero unused exports); SDK export/surface checks; runtime and Madge cycle checks (zero cycles each).
  • Full reply directory: 425 files, 7,051 passing tests, two unchanged Windows-only skips, and three retired-seam spy failures repaired and verified in focused reruns. Remaining media, agent, and E2E coverage passed 320 tests across nine files, including 245 E2E tests. Direct Gateway-media/outbound consumers passed 121 tests; inbound-context coverage passed 67; TTS/CLI/skill consumers passed 149. The final repaired-owner batch and lint-suppression guard passed 195 tests across nine files.
  • All discovered changed-file lint findings and four test line-cap growth findings were repaired without changing limits, suppressions, or assertions. The complete local changed-check invocation passed its preceding checks but hit the unchanged 15-minute limit in monolithic core lint. All five full core lint stripes, scripts, and central guards then passed through the repository's native CI layout. The remaining owner checks subsequently passed remotely after a CPU-contended local scan was stopped.
  • After conflict integration, a fresh full build, production types, affected test-type graphs, all conflict-related lint, all eight remaining owner checks, SDK export/surface checks, and both cycle checks passed (zero cycles). Focused proof passed 546 tests across 23 files, including the required lint-suppression guard. The final four-line adjustment restores main's public formatter input annotation without changing runtime code.
  • The formal SDK API comparison before the boundary repair reported no public entrypoint, export, or signature changes. Its 147 reachability-only hash changes traced to seven internal declarations: equivalent abort typeof aliases, the shared token helper, and the generic count mapper. Those source differences were inspected; public input/output contracts remain unchanged. The boundary repair moves the private helper out of the protected token module. No API acknowledgement or baseline override was used.
  • Fresh independent P2 review of the full candidate after conflict integration completed cleanly in both passes. Main's directive field projections, asynchronous placement checks, incognito authority checks, and Gateway metrics notification ordering are preserved.
  • Initial hosted CI found an owned boundary defect in checks-node-changed-compact-small-10 and checks-node-compact-small-2: deleting delivery-hints.ts broke the protected PR-wrapper inventory, failing 16 provisioning cases and six extraction cases. The correction restores all three touched protected dependencies byte-for-byte to main and moves the shared token helper to a private leaf. The inventory and tests are unchanged, and the protected-inventory diff is empty.
  • Boundary repair proof passed: full build; the actual changed-check command with all core test-type graphs, lint, Knip and owner guards; zero runtime/Madge cycles; and 222 focused tests across eight files. Both previously failing suites passed in full, apart from their unchanged APFS-only case on Linux. Independent P2 review of the correction was clean.
  • The second conflict-only rebase preserves main's shared skill mapping, ACP binding batch reads and authority recheck, system-event identity filter, and outbound handling. Fresh proof passed production types, all affected test-type graphs, 373 tests across 14 files, the suppression guard, and both cycle checks (zero each). The full changed-check command subsequently passed all 27 core test-type graphs, lint, both Knip scans, ratchets, and runtime-owner guards in Testbox; the lease was stopped after success. Independent review completed; its sole reset-default finding was rejected because both reset branches already pass undefined, with the existing 30-test command suite confirming override removal.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: XL labels Oct 7, 2026
@steipete
steipete marked this pull request as ready for review October 7, 2026 17:55
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 7, 2026
@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 7, 2026, 4:20 PM ET / 20:20 UTC (Revision 6).

ClawSweeper review

What this changes

The PR consolidates private reply preparation, command handling, delivery, and lifecycle helpers and prevents ACP session lookup from throwing when optional channel configuration is absent.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open. The earlier wrapper-inventory defect is repaired, and source inspection does not support the previous generic config/default blocker. No blocking introduced defect was found.

Priority: P2
Reviewed head: 32271a353cfc6632008e3c1aaa517795681c936d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful consolidation with substantial recorded validation, repaired prior findings, and no remaining concrete blocker identified.
Proof confidence 🌊 off-meta tidepool Not applicable: GitHub-verified repository-admin authorship exempts this PR from ordinary external-contributor runtime proof. Recorded tests are supplemental, and the inspected refactors do not materially change authority or stored-data contracts.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: GitHub-verified repository-admin authorship exempts this PR from ordinary external-contributor runtime proof. Recorded tests are supplemental, and the inspected refactors do not materially change authority or stored-data contracts.
Evidence reviewed 9 items Pinned introduction and merge boundary: Reviewed the merge-base-to-head introduction separately from base drift. The raw test-merge commit records the pinned main parent followed by the exact PR head.
ACP fix remains necessary on fetched main: Fetched main still indexes params.cfg.channels without optional chaining. The branch preserves explicit and configured account selection while allowing the existing DEFAULT_ACCOUNT_ID fallback when channels is absent.
Prior automation defect resolved: The verified test merge has no changes to tokens.ts, delivery-hints.ts, or message-tool-delivery-hints.ts relative to its main parent. The protected dependencies implicated in the earlier finding are retained.
Findings None None.
Security None None.

How this fits together

OpenClaw’s automatic reply pipeline receives channel messages and commands, prepares session and agent inputs, and delivers responses. These helpers coordinate execution, cancellation, session updates, and delivery settlement.

flowchart TD
  A[Incoming messages and commands] --> B[Reply preparation]
  B --> C[Session and authority checks]
  C --> D[Command handling]
  C --> E[Agent execution]
  D --> F[Reply delivery]
  E --> F
  F --> G[Delivery settlement]
Loading

Before merge

  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

PR surface statistics unavailable: the file list is incomplete.

Review metrics

None.

Stored data model

Persistent data-model change detected: unknown-truncated-pull-files. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep shared private owners for reply preparation and settlement while preserving command values, lazy imports, live authority checks, and session persistence contracts.

Do we have a high-confidence way to reproduce the issue?

Yes, by source inspection: fetched main dereferences absent channels when ACP reset lookup receives an omitted account and channel configuration. This review did not execute that path.

Is this the best way to solve the issue?

Yes. The inspected shared helpers retain existing inputs, reset semantics, authorization predicates, and persistence operations; optional chaining repairs the ACP defect without adding configuration.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against e73028f81cda.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded internal improvement with an adjacent ACP lookup repair, without evidence of an urgent user-facing regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: GitHub-verified repository-admin authorship exempts this PR from ordinary external-contributor runtime proof. Recorded tests are supplemental, and the inspected refactors do not materially change authority or stored-data contracts.

Evidence

What I checked:

  • Pinned introduction and merge boundary: Reviewed the merge-base-to-head introduction separately from base drift. The raw test-merge commit records the pinned main parent followed by the exact PR head. (85c33a83fc3b)
  • ACP fix remains necessary on fetched main: Fetched main still indexes params.cfg.channels without optional chaining. The branch preserves explicit and configured account selection while allowing the existing DEFAULT_ACCOUNT_ID fallback when channels is absent. (src/auto-reply/reply/acp-reset-target.ts:26, e73028f81cda)
  • Prior automation defect resolved: The verified test merge has no changes to tokens.ts, delivery-hints.ts, or message-tool-delivery-hints.ts relative to its main parent. The protected dependencies implicated in the earlier finding are retained. (src/auto-reply/reply/delivery-hints.ts, 85c33a83fc3b)
  • Existing reset and persistence contracts preserved: The shared setting writer deletes undefined values and retains persistCommandSession with the exact touched field. Both usage reset and fast-mode default pass undefined, preserving the documented removal of session overrides rather than introducing a new default or persisted shape. (src/auto-reply/reply/commands-session.ts:115, 32271a353cfc)
  • Documented command compatibility: Current slash-command documentation defines fast default and usage reset as clearing session overrides; the inspected branch retains those contracts. Public docs: docs/tools/slash-commands.md. (docs/tools/slash-commands.md:265, 32271a353cfc)
  • Authority checks retained: The authority refactor extracts projection and session-generation comparisons without changing their predicates. Both operator authorities, captured read-plan liveness, caller policy equality, and checks after awaited preparation remain present; no material expansion of authority was identified. (src/auto-reply/reply/reply-tool-authority.ts:519, 32271a353cfc)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (5 earlier review cycles)
  • reviewed 2026-10-07T18:07:05.549Z sha a1526f5 :: blocked before merge. :: [P2] [P2] Remove the deleted facade from the wrapper inventory
  • reviewed 2026-10-07T18:30:58.164Z sha a1526f5 :: blocked before merge. :: [P2] [P2] Remove the deleted facade from the wrapper inventory
  • reviewed 2026-10-07T18:38:41.274Z sha a1526f5 :: blocked before merge. :: [P2] [P2] Remove the deleted facade from the wrapper inventory
  • reviewed 2026-10-07T19:43:54.574Z sha 1a4ecf1d31eb776826662c3bf9cda9a3dda09fa7 :: blocked before merge. :: none
  • reviewed 2026-10-07T20:01:53.963Z sha 32271a3 :: blocked before merge. :: none

Share ACP setter parsing, target resolution, dispatch, and replies while
preserving alias-specific validation, ordering, and exact user-facing text.
Keep prompt reconstruction with the context that owns its inputs and carry
the complete envelope through admission. Share directive acknowledgement
payload construction without changing metadata-bearing replies.

Remove 144 net production lines. Adapt one internal test fixture (+6 lines)
with all assertions unchanged.

Validation: 361 focused tests across 13 files; lint-suppression tests;
zero runtime and Madge cycles; check-changed including core/test typechecks,
lint, guards, and dead-export scans on Blacksmith Testbox; independent P2 review.
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 7, 2026
@steipete
steipete force-pushed the deslop/d02-auto-reply-reply-20261007 branch from 1a4ecf1 to 32271a3 Compare October 7, 2026 19:53
@steipete
steipete merged commit 0abba2b into main Oct 7, 2026
153 of 154 checks passed
@steipete
steipete deleted the deslop/d02-auto-reply-reply-20261007 branch October 7, 2026 20:23
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 7, 2026
…b [step 4/5]

Upstream "consolidate reply preparation and command flows" (openclaw#166685). Eight
conflicting files; the semantic ports:

- agent-runner-run-params.ts (auto-merged upstream builder): the shared
  buildFallbackCandidateTurnParams now carries the feature's hookTrigger
  override (`turn.hookTrigger ?? heartbeat/user`), so both the embedded and
  CLI candidates keep it. The candidate hunks take upstream; the embedded
  candidate keeps the feature's continuation options
  (drainsContinuationDelegateQueue, continueWorkOpts, requestCompactionOpts)
  and drops the prepareAssistantTranscriptMessage line upstream moved into
  the builder.
- agent-runner-execution.ts: upstream collapsed the fallback loop into one
  `cycle`. The feature's continueWorkRequests / compactionTraceparent /
  rawContinuationText join the post-loop destructure, and the hook trigger
  keeps the override.
- agent-runner-execute.ts: `cfg` is restored to the input destructure for the
  feature's context-pressure evaluation (upstream switched to `...context`).
- get-reply-run-admission/-execute.ts: upstream's promptBodies. The admission
  result keeps the feature's managedSystemEventDeliveries. Execution takes
  only media/inboundMediaIndexes up front, because the text bodies are re-read
  after the feature's system-event refresh.
- agent-runner-result-payloads.ts: both sides added an identical
  isPayloadLaneEnabled; one copy is kept.
- normalize-reply.ts: both imports kept.
- Deleted upstream modules: agent-runner.ts (a re-export) and
  reply-media-paths.runtime.ts. The feature's imports and tests move to
  agent-runner-run.js and reply-media-paths.js. The media-only test drops
  upstream's removed runtime mock (its cancelContinuationTimer stub has no
  live target).

Checks: typecheck clean for core and every core test shard plus
extensions-test. Canonical runner: 93 of 94 agent-runner* / get-reply-run* /
normalize-reply* / crosssession-gate files green. The remaining file,
agent-runner.runreplyagent.e2e.test.ts, needs CI's prepared-runtime route
and is covered by the Gate 2.5 delta's e2e lane.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Jhynq2GVpzuVQQieebEubg
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 8, 2026
…upstream's rename

Upstream openclaw#166685 (0abba2b) deleted src/auto-reply/reply/agent-runner.runtime.ts.
get-reply-run-helpers.ts now lazy-loads ./agent-runner-run.js. The feature's
tsdown entry, which keeps that runner in the unified graph so continuation's
singleton state is shared (a split chunk can silently drop continue_work tool
calls), still named the deleted file, so the build failed with
UNRESOLVED_ENTRY. Typecheck and vitest never build dist, so the absorb sweep
missed it; 🍃's Gate 2.5 e2e lane (prepare-vitest-runtime) caught it.

The entry now names src/auto-reply/reply/agent-runner-run.ts. Checks:
`pnpm build:strict-smoke` passes. dist has one auto-reply/reply/agent-runner-run.js
entry, and the only dynamic import of it is import("./auto-reply/reply/agent-runner-run.js"),
so there is no duplicated runner chunk.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Jhynq2GVpzuVQQieebEubg
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 8, 2026
…openclaw#166685)

* refactor(auto-reply): consolidate command and prompt preparation

Share ACP setter parsing, target resolution, dispatch, and replies while
preserving alias-specific validation, ordering, and exact user-facing text.
Keep prompt reconstruction with the context that owns its inputs and carry
the complete envelope through admission. Share directive acknowledgement
payload construction without changing metadata-bearing replies.

Remove 144 net production lines. Adapt one internal test fixture (+6 lines)
with all assertions unchanged.

Validation: 361 focused tests across 13 files; lint-suppression tests;
zero runtime and Madge cycles; check-changed including core/test typechecks,
lint, guards, and dead-export scans on Blacksmith Testbox; independent P2 review.

* refactor(auto-reply): consolidate reply and command flows

* refactor(auto-reply): retain explicit SDK formatter input

* fix(auto-reply): preserve protected wrapper dependencies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant