Repository navigation
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 real behavior proof before merge. What this changesThis PR routes sanitized prompt-hook context through retained runtime carriers on append-only model routes. Example: A hook returns prependContext="Customer prefers email" for the prompt "Hello" on an append-only route.
Review scores
ProductKind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Partial Merge readiness⛔ Blocked before merge - 2 items remain Keep open: this PR contains distinct runtime-only replay work, but broader hook-context routing needs an owner decision following the merged prompt-persistence change. Priority: P2 Decision needed
Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe embedded runner combines user input, plugin hooks, and runtime facts into provider requests and records the context needed for subsequent session replay. flowchart LR
A[User input] --> C[Prompt assembly]
B[Plugin hooks] --> C
C --> D[Runtime carrier]
C --> E[Prompt submission]
D --> E
E --> F[Provider request]
E --> G[Session transcript]
G --> C
Technical reviewBest possible solution: Preserve canonical projection for ordinary recorded turns unless the owner approves broader carrier semantics, and repair the distinct runtime-only replay boundary through the existing owners. Do we have a high-confidence way to reproduce the issue? Source establishes the runtime-only recorder exclusion; the original ordinary-turn persistence failure is partly addressed by #167938, and no current-main reproduction was executed. Is this the best way to solve the issue? The single routing decision and reuse of the existing carrier are focused, but the broad route changes more semantics than the remaining runtime-only persistence gap requires. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f34184a1d58d. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +55, Tests +183. Total +238 across 8 files. Added test files: 0. View PR surface stats
LabelsLabel changes: No label 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 (12 earlier review cycles; latest 8 shown)
Reviewed October 24, 2026, 8:23 AM ET / 12:23 UTC (Revision 13). |
|
Two observations from a deployment that needs this together with #164804. They are not the after-fix production trace the review asks for (limits at the end of point 1), but they cover part of it. 1. Active Memory rewrites the previous user message on every eligible turn, not only on recall turns. In Append-only retention alone does not fix it. We ran three turns on 2026.9.6 with
With retention only, the first difference is the previous user message. The 12/12 and 16/16 hold with encrypted-only reasoning. With reasoning summaries requested, they also need #167769; without it, turn 1 → 2 is 3/12. The same run checks that the hook text reached the model once per turn and was stored in the hidden carrier on all three turns. Limits: this is a backport onto 2026.9.6, not this head on main. The model stream is synthetic. The run does not exercise in-history system updates or the empty-transcript route. We have not measured provider cache reads with the change applied. 2. Instructions that plugins put in |
|
Related implementation comparison: #167938 now records and replays the enriched model-facing user prompt on the canonical transcript. This PR routes hook prepend/append context into the hidden carrier on append-only routes and keeps those additions out of ordinary submission. Could the author and @steipete confirm the intended capture location for hook context on that shared route, and whether these changes should compose or one replaces that part of the other? The comparison should preserve single inclusion and stable replay, while accounting for the context-only/empty-transcript path and previously stored turns. The checkpoint alternatives #166667 and #147248 already compare their approaches; this question concerns the upstream persistence boundary. |
|
Thanks for flagging the interaction — I checked both persistence boundaries against the merged #167938 ( They compose; neither replaces the other. The split is by route, decided at a single point:
Single inclusion and stable replay hold on both routes: hook text reaches the model exactly once per turn — via the frozen canonical projection on the shared route, via the carrier on append-only routes — with the assembly's routing flag as the single source of truth. I'm updating the branch onto current main next (#167938 only offsets |
|
Following up as promised, now that the branch is updated onto main with #167938 included: Composition verified at the merge head. All four affected suites pass against the updated branch:
So after the merge, single inclusion and stable replay hold on both routes: the canonical projection freezes the enriched prompt on the shared route, and the carrier fragment carries hook context on append-only routes, with no path where both include it. Note on the current red CI: the only failing step is |
|
@ruel225, thanks for the composition check and updated-branch test results. The Workboard manifest regeneration landed on main after your follow-up: c40ca82. It replaces the Your current head remains |
|
The new |
|
@ekinnee The two changes compose: they own disjoint bytes on every route, so single inclusion and stable replay hold with no overlap. Capture locations, per route:
Why compose rather than replace: #167938 stabilizes replay of whatever first went to the model, but the #166271 break comes from rewriting the prompt prefix within a run — the folded user text shifts the cache prefix and drops replayed thinking blocks even when later replays are stable. Only moving hook bytes out of the assembled prompt (into the carrier) fixes that; storing the folded text cannot. Conversely, this PR does not give hook context durable, reopen-stable replay on legacy routes — #167938's stored projection does. Previously stored turns: rows recorded before either change have no projection field, and capture only happens on a turn's first model send ( Net: #167938 owns the canonical user-prompt text on every route that has a recorder, this PR owns hook prompt context on append-only routes, and the runtime-only path is carrier-only by construction. Current head |
…rier On append-only runtime-context models, a before_prompt_build hook's prependContext/appendContext was folded into the active user prompt for one run only and never stored. The next run replayed the earlier user message without the injected block, so the request was no longer an append-only extension of the previous one: every cache entry written during the run sat after that rewritten message and could never be read again, and replayed thinking blocks after that message were dropped. Route the joined hook context through the stored conversation-data runtime-context fragment instead. Assembly publishes one routePromptBuildContextThroughRuntimeCarrier decision (append-only contract and non-empty prompt); carrier construction, submission, and the compaction budget consume that single decision, and the carrier bytes are redacted with the tool-payload policy from the attempt logging config before storage, since the carrier bypasses the canonical prompt-projection redaction on both consumption paths. Legacy routes are untouched: non-append-only models keep the one-run fold; blank-prompt context-only turns keep the fold so hook context alone still reaches the model. Closes openclaw#166271
f43600c to
0949de0
Compare
The carrier hook-context tests were replayed onto a base where this suite imports prepareEmbeddedAttemptPromptContext as prepareContext, so calling the original name left six TS2304 diagnostics and one implicit-any on the fragment lookup, and the vitest shard failed with ReferenceError before running a single assertion. Use the alias every other case in the file already uses.
Keep the redaction-policy test import; drop replayed imports the base removed with the Windows approval-hints test.
|
@steipete, could you settle the intended hook-context routing scope here so @ruel225 has a clear target for the remaining proof? Since your #167938 added canonical persistence for enriched user prompts, should this PR preserve that behavior for ordinary recorded turns and limit carrier routing to runtime-only submissions without projection capture, or is the broader append-only routing intended—including framing prependContext / appendContext as conversation data rather than instructions? @ruel225 has already documented the route-by-route composition and continued integrating upstream changes. The published bot review still targets f43600c5, not the current e3dc40b head, so its old conflict warning is not evidence of a current conflict. It identifies no code findings at its reviewed head, but leaves this semantics decision and shipped-entry/replay compatibility proof outstanding. Choosing the scope first would let the author focus the CLI/Gateway replay and existing-session compatibility evidence on the behavior we actually intend to ship. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Thanks for the work here. We're closing this: it doesn't show a real user-facing problem (no report from an affected user and no natural reproduction), and it follows a pattern of small, speculative or duplicate changes split across many PRs. Please open an issue with a reproduction of real harm first; a fix can follow once the problem is confirmed. |
What Problem This Solves
Closes #166271. On models that use append-only runtime context (
bindsClaudeThinkingPrefix: Opus 5.5, Fable 5.1),prependContext/appendContextreturned by abefore_prompt_buildhook was folded into the active user prompt for one run only and never stored. The next run replayed the earlier user message without the injected block, so the request was no longer an append-only extension of the previous one:replayed thinking dropped ... prefix_binding_mismatch,prefix_mismatch_behavior: "drop_block").OpenClaw's own per-turn context does not have this problem: it rides the runtime-context carrier, is stored hidden with the turn, and replays byte-identically. Hook context went down the older one-run rewrite path instead.
The Fix
prepareEmbeddedAttemptPromptAssemblygainsappendOnlyRuntimeContext. When it is true and the prompt is non-empty, the joined hookprependContext/appendContextis no longer folded intoeffectivePrompt;prepareEmbeddedAttemptPromptContextinstead adds it as aconversation-dataruntime-context fragment, so it is stored hidden with the turn and replayed unchanged — the same treatment OpenClaw's own facts get, so plugin text is not raised to instruction level.One routing decision, published once: review round 2 caught that the routing predicate was re-derived independently at each consumer and keyed on different fields — carrier construction keyed on the transcript prompt, submission on the assembled prompt. A runtime-only turn (non-empty prompt, empty
transcriptPrompt) therefore failed both: assembly skipped the fold, carrier construction excluded the hook text, and submission suppressedprependContext/appendContext, so the model never received it. Assembly now publishesroutePromptBuildContextThroughRuntimeCarrierin its result, and carrier construction, submission, and the compaction budget all consume that single decision; the runtime-only submission path delivers the stored carrier to the model.Redaction (review round 7, P1): the carrier bypasses the canonical prompt-projection redaction on both consumption paths — the provider dispatch and the durable custom-message append — so hook text that
logging.redactPatternswould have removed from the recorded prompt previously reached both the model and the retained transcript unsanitized. Carrier construction now appliesredactTranscriptText(same policy, same config object the canonical capture uses) to the joined hook context before it becomes a fragment, so dispatch and replay see identical sanitized bytes. The legacy fold path is untouched: it still passes throughcapturePersistedModelPromptProjection, which already sanitizes.Kept on the legacy path:
submitEmbeddedAttemptPrompt(prependContext/appendContext) and frompendingAdditivePromptin the compaction request budget, since the carrier now carries those bytes and is counted throughpendingContextMessages— no double injection, no double counting.Trade-off inherited from the issue discussion: stored hook blocks accumulate in history until compaction or reset; the reporter's local patch of this shape estimated 500-850 tokens per injected block, and an explicit one-run opt-out on the hook result remains possible upstream work.
Evidence
Reproduction and regression tests (all offline, no network):
attempt-prompt-build.decision.test.ts"prompt assembly hook prompt context": onappendOnlyRuntimeContext: truewith abefore_prompt_buildhook returningprependContext, the assembly keepseffectivePrompttranscript-identical ("Hello", no hook text) while still reportingpromptBuildPrependContextfor the carrier route; the legacy fold is pinned for append-only-off and for blank-prompt turns.attempt-prompt-context.test.ts: the carrier carries{ kind: "conversation-data", text: <hook context> }(prepend and append joined in order), whilepromptForSession,promptForModel, andllmBoundaryPromptForPrecheckstay bare user bytes; with the append-only contract off, the carrier contains no hook text and the folded model prompt is preserved.attempt-prompt-context.test.ts"routes hook prompt context through the carrier when the transcript prompt is empty" pins the runtime-only turn (effectivePrompt: "Runtime ask",effectiveTranscriptPrompt: "") delivering the hook text through the carrier —promptSubmission.runtimeOnlyis true,promptForModelstays bare, andruntimeContextMessageForCurrentTurncarries the hook fragment;attempt-prompt-build.decision.test.ts"publishes one carrier-routing decision for empty-transcript runtime turns" pins the published decision itself.attempt-prompt-context.test.ts"applies the transcript redaction policy to hook context stored in the carrier" — withlogging.redactPatterns: ["sk-TEST-HOOK-SECRET-[a-z0-9]+"]and a hook returning aprependContextcontainingsk-TEST-HOOK-SECRET-9f2, the carrier fragment must not contain the raw secret and must equalredactTranscriptText(hookPrepend, config)byte-for-byte;promptForModelstays clean too.Pre-fix red runs (tests only, fix reverted):
promptSubmission.runtimeOnlyisundefined(no runtime context at all reaches the turn) and the hook fragment is absent from the carrier.expect(fragment?.text).not.toContain("sk-TEST-HOOK-SECRET-9f2")fails — the raw secret is present in the carrier fragment, exactly the round-7 P1 path.Post-fix:
attempt-prompt-context.test.ts: 29/29 (28 pre-existing + 1 new redaction test)attempt-prompt-build.decision.test.ts,attempt-prompt-submit.projections.test.ts,attempt-context-advancement.test.ts,interrupted-input-context.integration.test.ts,tool-result-truncation.test.ts: all green on the same tree.Branch state: rebased onto current
main(571040c310), latest heade3dc40b08b:0949de0b07(carrier fix carrying the routing-decision and redaction rounds) →0e62acd2f9(aliased-import test helper) → merge refreshes onto successivemaintips (the net diff vsmainwas verified byte-identical to the reviewed patch: 8 files, 248+/10-, every changed line matching).