Repository navigation
refactor(prompt): remove unreachable runtime-only system prompt path - #143314
Conversation
…ting system prompt Route runtime-only event context through the message tail carrier rather than appending into the submitted system prompt and mutating active session state. This prevents prompt-cache churn on byte-prefix sensitive providers while keeping event context visible to the model. Closes openclaw#143242
|
🦞👀 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. |
|
@clawsweeper review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Codex review: needs maintainer review before merge. Reviewed September 11, 2026, 6:15 AM ET / 10:15 UTC (Revision 7). ClawSweeper reviewWhat this changesThe PR removes an unused system-prompt mutation path and its callback, carries runtime-only event details in the existing hidden context message, and updates regression coverage. Merge readiness✅ Ready for maintainer review Keep open as a focused cleanup with no actionable correctness findings. The revised scope accurately reflects the real-API results, and the earlier review blockers have been addressed. Priority: P3 Review scores
Verification
How this fits togetherOpenClaw’s embedded runner combines user messages, internal events, and current runtime facts before submitting a model request. Stable instructions form the system prompt, while changing event details travel through a hidden context message. flowchart TD
A[User messages and internal events] --> B[Prepare transcript and event facts]
B --> C[Assemble current prompt]
C --> D[Stable system instructions]
C --> E[Hidden context message]
E --> F[Escape and position context]
D --> G[Model request]
F --> G
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -48, Tests +13, Other 0. Total -35 across 13 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep one hidden runtime-context carrier and a stable system prompt, preserving event delivery, escaping, and legacy display sanitization. Do we have a high-confidence way to reproduce the issue? Not applicable to the revised cleanup scope. The supplied real-API comparison did not reproduce the former cache-collapse claim; direct empty-transcript fixtures exercise the removed branch. Is this the best way to solve the issue? Yes. Removing the unused mutation interface while reusing the established carrier is a narrow simplification, and the remaining hook-owned setter is preserved. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 48f04b97e007. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Review exact head Real provider transport proof is now in the body: production |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review The PR body is now updated for exact head Real provider transport proof is in Evidence & Real Behavior Proof:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
obviyus
left a comment
There was a problem hiding this comment.
The change looks right, and the proof direction is fine. Three failures caused by this patch block the merge at 62c344df:
- Formatting:
oxfmt --checkexited 1 in CI forsrc/agents/embedded-agent-runner/run/attempt-prompt-context.test.ts. Independent checks with Oxfmt 0.65.0 confirmedoxfmt --check head/attempt-prompt-context.test.tsexited 1, whileoxfmt --check base/attempt-prompt-context.test.tsandoxfmt --check main/attempt-prompt-context.test.tsboth exited 0. These files contained the exact PR head, parent, and pinned main versions. Please format the changed test. - Obsolete runner assertions:
time -p node --import tsx scripts/ci-run-node-test-shard.mtsexited 1 in thechecks-node-compact-large-3CI job. Insrc/agents/embedded-agent-runner/run/attempt.spawn-workspace.context-engine.test.ts, bothsubmits runtime-only context through system prompt without visible prompt(line 1966) andkeeps current inbound context visible on runtime-only turns(line 2064) still expect event text in the system prompt. Please update these assertions for the carrier while preserving checks for event delivery, hook context, and transcript visibility. - Unused production export:
pnpm deadcode:fullexited 1 in CI and reportedprojectRuntimeContextFragmentsinsrc/agents/embedded-agent-runner/run/attempt-llm-boundary.ts. The patch removes its last external production use. Please remove the unused export or use it; retain the internal projection behavior.
Please push these fixes. A maintainer will re-run review and land it once the checks pass.
Keep runtime-only events on the tail carrier in context-engine assertions, format the prompt-context test, and unexport the internal fragment projector so deadcode:full stays clean.
|
Pushed
Focused verification:
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
The three earlier blockers are fixed. The real-API measurements did not reproduce the reported cache collapse.
All 12 requests completed successfully. The event text reached the conversation input on both revisions. Every supported Gateway event entry route checked produces a nonempty transcript: completion events use the internal-events transcript renderer, and room events use the attributed prelude line. These real flows do not reach the runtime-only system-prompt branch. The PR's regression reaches it by injecting an empty transcript directly into the runner. The maintainers will decide whether to keep this as an unreachable-branch cleanup, retitled as a refactor with the now-unused system-setter callback removed too, or close the PR. We are not landing it on the cache-regression claim. Thank you for fixing the three blockers and following through on the review. |
|
Acknowledged — thank you for the real-API measurements. Your 12-request table is the better evidence. Main Agreed on reachability: the supported Gateway completion/room-event routes you checked always produce a nonempty transcript, so they never enter the empty-transcript Happy to follow whichever maintainer call you want:
No further cache-regression argument from this side. |
The three requested fixes are verified at f771ad2901da825def8932ce3f91b775a4a83f93. This review is superseded by the scoped refactor and fresh exact-head review.
f771ad2 to
90cb503
Compare
|
Thanks @zackmsa777-a11y for the cleanup and review fixes! Landed as a refactor of the unreachable runtime-only system-prompt path. The context-stage setter and unused formatter variant are removed; hook assembly, event tail routing, legacy stripping, and the byte-stability guard remain. Proof: 260 focused tests passed, including runner/context, formatter, truncation, and legacy-stripping coverage. Exact-head ClawSweeper review found no code or security issue, and the guarded merge verified the required checks. CI initially hit a timeout in an unchanged secrets-provider test. The focused case passed on the exact CI base and merge tree, and one rerun of the failed job passed. No test changes or gate exceptions were used. Final CI gate. The earlier real-API measurements remain preservation evidence, not a cache-fix claim:
The event reached the conversation input on both revisions. The refactor preserves the author's commits and credit. |
…penclaw#143314) ## What Problem This Solves Remove the audit-found runtime-only system-prompt branch and its unused mutation interface. This is a maintainer-approved refactor, not a Gateway cache fix or a performance improvement. The branch is unreachable through the supported Gateway event ingress paths: completion events receive a nonempty transcript from [`resolveInternalEventTranscriptBody`](https://github.com/openclaw/openclaw/blob/c3b4b9aa66192f377bb1e072127999492e588cf9/src/agents/internal-events.ts#L372), selected by [agent preparation](https://github.com/openclaw/openclaw/blob/c3b4b9aa66192f377bb1e072127999492e588cf9/src/agents/command/prepare.ts#L415), and room events receive an [attributed transcript line](https://github.com/openclaw/openclaw/blob/c3b4b9aa66192f377bb1e072127999492e588cf9/src/auto-reply/reply/prompt-prelude.ts#L212). The removed append required an empty transcript. Persistence suppression also disables runtime-only admission. ## Why This Change Was Made - Remove event-specific system-prompt composition and session mutation from prompt-context assembly. - Remove that stage's unused system-setter callback and update every caller and fixture; preserve the assembly-stage setter used by hooks and model identity. - Remove the unused runtime-event formatter variant and retain one delimiter-only carrier format. - Keep event tail routing, escaping, carrier lifetime, and the byte-stability regression. ## User Impact No user-visible behavior change is expected. The cleanup removes unused mutation paths while preserving supported Gateway event handling. ## Evidence The [real-API comparison](openclaw#143314 (comment)) showed no cache regression on main: both main and the original PR head kept instruction bytes equal across normal → completion event → normal, with cached-token counts of 0 → 5,888 → 5,888 in both runs. The regression fixture reaches the removed branch by supplying an empty transcript directly; it is retained as an internal byte-stability guard. All 260 focused runner, context, formatter, truncation, and legacy-stripping tests pass. With the callback-free fixture, the original append implementation fails three event cases by attempting the removed setter; 18 controls pass. All cases pass after the path is removed. Formatting, focused lint, and normal commit hooks pass. This is internal refactor coverage; the live results do not establish a user-visible cache defect. Thanks @zackmsa777-a11y for the original change and review fixes. The follow-up cleanup preserves the contributor's commits and authorship. Related: openclaw#143242. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Remove the audit-found runtime-only system-prompt branch and its unused mutation interface. This is a maintainer-approved refactor, not a Gateway cache fix or a performance improvement.
The branch is unreachable through the supported Gateway event ingress paths: completion events receive a nonempty transcript from
resolveInternalEventTranscriptBody, selected by agent preparation, and room events receive an attributed transcript line. The removed append required an empty transcript. Persistence suppression also disables runtime-only admission.Why This Change Was Made
User Impact
No user-visible behavior change is expected. The cleanup removes unused mutation paths while preserving supported Gateway event handling.
Evidence
The real-API comparison showed no cache regression on main: both main and the original PR head kept instruction bytes equal across normal → completion event → normal, with cached-token counts of 0 → 5,888 → 5,888 in both runs. The regression fixture reaches the removed branch by supplying an empty transcript directly; it is retained as an internal byte-stability guard.
All 260 focused runner, context, formatter, truncation, and legacy-stripping tests pass. With the callback-free fixture, the original append implementation fails three event cases by attempting the removed setter; 18 controls pass. All cases pass after the path is removed. Formatting, focused lint, and normal commit hooks pass. This is internal refactor coverage; the live results do not establish a user-visible cache defect.
Thanks @zackmsa777-a11y for the original change and review fixes. The follow-up cleanup preserves the contributor's commits and authorship.
Related: #143242.