Skip to content

refactor(prompt): remove unreachable runtime-only system prompt path - #143314

Merged
obviyus merged 3 commits into
openclaw:mainfrom
zackmsa777-a11y:fix/runtime-event-prompt-cache-churn
Sep 11, 2026
Merged

obviyus merged 3 commits into
openclaw:mainfrom
zackmsa777-a11y:fix/runtime-event-prompt-cache-churn

Conversation

@zackmsa777-a11y

@zackmsa777-a11y zackmsa777-a11y commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

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

  • 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 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.

…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
@clawsweeper

clawsweeper Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@zackmsa777-a11y

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. agents Agent runtime and tooling size: S labels Sep 9, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 9, 2026
@clawsweeper

clawsweeper Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 11, 2026, 6:15 AM ET / 10:15 UTC (Revision 7).

ClawSweeper review

What this changes

The 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
Reviewed head: 90cb503e5dde2b9bfc66b94e150ff9aee08b5485

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, maintainable cleanup supported by relevant runtime observations and corrected regression coverage.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): Production prompt assembly and Responses transport evidence exercises normal → injected runtime-only → normal turns with stable instructions and event delivery in request input; the separate 12-request real-API comparison confirms supported-flow preservation. The final interface cleanup preserves those paths and does not establish a new performance claim.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): Production prompt assembly and Responses transport evidence exercises normal → injected runtime-only → normal turns with stable instructions and event delivery in request input; the separate 12-request real-API comparison confirms supported-flow preservation. The final interface cleanup preserves those paths and does not establish a new performance claim.
Evidence reviewed 9 items Pinned change ownership: The complete host-provided merge-base-to-head patch identifies the introduced cleanup. Raw inspection confirms the test merge has the pinned main parent followed by the exact PR head; unrelated endpoint drift was excluded from review.
Canonical context path remains intact: Prompt assembly retains the original system instructions and includes event fragments in the existing runtime-context carrier. Prompt submission still forwards that carrier through the existing queued or transient context path, and the earlier assembly-stage setter remains available for hooks.
Escaping and legacy handling preserved: The internal fragment projector still escapes delimiters and distinguishes conversation data from runtime instructions. The formatter retains the same delimiters, and legacy runtime-event header stripping remains covered. This is OpenClaw-owned prompt assembly; no changed behavior requires a Codex dependency contract.
Findings None None.
Security None None.

How this fits together

OpenClaw’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
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -48, Tests +13, Other 0. Total -35 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 5 13 61 -48
Tests 7 40 27 +13
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 13 54 89 -35

Review metrics

None.

Technical review

Best 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.

Labels

Label justifications:

  • P3: This is an internal cleanup with no demonstrated user-facing cache regression or intended behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): Production prompt assembly and Responses transport evidence exercises normal → injected runtime-only → normal turns with stable instructions and event delivery in request input; the separate 12-request real-API comparison confirms supported-flow preservation. The final interface cleanup preserves those paths and does not establish a new performance claim.
  • proof: sufficient: Contributor real behavior proof is sufficient. Production prompt assembly and Responses transport evidence exercises normal → injected runtime-only → normal turns with stable instructions and event delivery in request input; the separate 12-request real-API comparison confirms supported-flow preservation. The final interface cleanup preserves those paths and does not establish a new performance claim.

Evidence

What I checked:

  • Pinned change ownership: The complete host-provided merge-base-to-head patch identifies the introduced cleanup. Raw inspection confirms the test merge has the pinned main parent followed by the exact PR head; unrelated endpoint drift was excluded from review. (90cb503e5dde)
  • Canonical context path remains intact: Prompt assembly retains the original system instructions and includes event fragments in the existing runtime-context carrier. Prompt submission still forwards that carrier through the existing queued or transient context path, and the earlier assembly-stage setter remains available for hooks. (src/agents/embedded-agent-runner/run/attempt-prompt-build.ts:508, 90cb503e5dde)
  • Escaping and legacy handling preserved: The internal fragment projector still escapes delimiters and distinguishes conversation data from runtime instructions. The formatter retains the same delimiters, and legacy runtime-event header stripping remains covered. This is OpenClaw-owned prompt assembly; no changed behavior requires a Codex dependency contract. (src/agents/embedded-agent-runner/run/attempt-llm-boundary.ts:71, 90cb503e5dde)
  • Reachability and existing contract: Runtime-only admission requires an empty transcript and producer context. Completion preparation selects the internal-event transcript renderer; room-event preparation supplies an attributed transcript line. The system-prompt documentation already describes delimiter-only carriers beneath stable instructions. (src/agents/embedded-agent-runner/run/runtime-context-prompt.ts:65, 90cb503e5dde)
  • Runtime evidence and corrected claim: The captured discussion records production Responses transport requests exercising normal → injected runtime-only → normal turns, with equal instruction hashes and event text in request input. The subsequent real-API comparison records 12 successful requests across the merge base and head 6ea75fd, with equal instructions and cached-token counts of 0 → 5,888 → 5,888 on both. These results support preserved behavior, not a reproduced Gateway cache defect: refactor(prompt): remove unreachable runtime-only system prompt path #143314 (comment). The final callback/formatter cleanup was inspected separately. (6ea75fd0523e)
  • Earlier review resolutions: The dismissed review requested formatting, updated runner assertions, and removal of an unused export. Current source preserves event delivery, hook context, and transcript-visibility assertions while checking the new carrier location; the projector is private. The discussion reports successful formatting and focused validation, and the captured body reports 260 passing tests. No tests or repository helpers were executed during this read-only review. (src/agents/embedded-agent-runner/run/attempt.spawn-workspace.context-engine.test.ts:1908, 90cb503e5dde)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peetiegonzalez: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • obviyus: 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 (6 earlier review cycles)
  • reviewed 2026-09-09T18:21:08.012Z sha 62c344d :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-09T18:28:32.438Z sha 62c344d :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-09T18:46:44.093Z sha 62c344d :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-11T07:45:41.632Z sha 62c344d :: needs maintainer review before merge. :: none
  • reviewed 2026-09-11T08:59:14.951Z sha 6ea75fd :: needs maintainer review before merge. :: none
  • reviewed 2026-09-11T10:07:37.360Z sha f771ad2901da825def8932ce3f91b775a4a83f93 :: needs maintainer review before merge. :: none

@zackmsa777-a11y

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@zackmsa777-a11y

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Review exact head 62c344dfc244d623e06219b06583de1014ae2b86 against the updated PR body.

Real provider transport proof is now in the body: production createOpenAIResponsesTransportStreamFn() issued three real POST /v1/responses HTTP/SSE requests on loopback. Wire instructions stayed 1a80902930f5fc71 across normal → runtime-only → normal; the runtime-only turn delivered the event text on the request input and did not call setActiveSessionSystemPrompt.

@clawsweeper

clawsweeper Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@zackmsa777-a11y

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The PR body is now updated for exact head 62c344dfc244d623e06219b06583de1014ae2b86.

Real provider transport proof is in Evidence & Real Behavior Proof:

  • Transport: production createOpenAIResponsesTransportStreamFn() (packages/ai/src/transports/openai-responses-client.ts)
  • Three real POST /v1/responses HTTP/SSE requests on loopback (status=200, contentType=text/event-stream)
  • Wire instructions hash stayed 1a80902930f5fc71 across normal → runtime-only → normal
  • Runtime-only turn delivered the event text on request input and did not call setActiveSessionSystemPrompt

@clawsweeper

clawsweeper Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 11, 2026

@obviyus obviyus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks right, and the proof direction is fine. Three failures caused by this patch block the merge at 62c344df:

  1. Formatting: oxfmt --check exited 1 in CI for src/agents/embedded-agent-runner/run/attempt-prompt-context.test.ts. Independent checks with Oxfmt 0.65.0 confirmed oxfmt --check head/attempt-prompt-context.test.ts exited 1, while oxfmt --check base/attempt-prompt-context.test.ts and oxfmt --check main/attempt-prompt-context.test.ts both exited 0. These files contained the exact PR head, parent, and pinned main versions. Please format the changed test.
  2. Obsolete runner assertions: time -p node --import tsx scripts/ci-run-node-test-shard.mts exited 1 in the checks-node-compact-large-3 CI job. In src/agents/embedded-agent-runner/run/attempt.spawn-workspace.context-engine.test.ts, both submits runtime-only context through system prompt without visible prompt (line 1966) and keeps 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.
  3. Unused production export: pnpm deadcode:full exited 1 in CI and reported projectRuntimeContextFragments in src/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.
@zackmsa777-a11y

Copy link
Copy Markdown
Contributor Author

Pushed 6ea75fd0 for the three merge blockers at 62c344df:

  1. Formatting — oxfmt on attempt-prompt-context.test.ts (oxfmt --check now exits 0).
  2. Obsolete runner assertions — attempt.spawn-workspace.context-engine.test.ts now expects runtime-only event text on the compiled prompt / tail carrier, not in systemPrompt. Event delivery, hook context, and transcript visibility checks remain.
  3. Unused production export — projectRuntimeContextFragments is no longer exported; internal projection is unchanged. The harness selection test now asserts the fragment payload directly.

Focused verification:

  • oxfmt --check on the four touched files — pass
  • node scripts/run-vitest.mjs attempt-prompt-context.test.ts + attempt.spawn-workspace.context-engine.test.ts + selection.test.ts — 244 passed
  • knip all-exports no longer reports projectRuntimeContextFragments

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Sep 11, 2026
@obviyus

obviyus commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

The three earlier blockers are fixed. The real-API measurements did not reproduce the reported cache collapse.

Revision Run Turn 1 cached tokens Event turn cached tokens Turn 3 cached tokens Instruction hashes equal across all three turns
Main merge-base 31d03f78 1 0 5,888 5,888 Yes
Main merge-base 31d03f78 2 0 5,888 5,888 Yes
PR head 6ea75fd0 1 0 5,888 5,888 Yes
PR head 6ea75fd0 2 0 5,888 5,888 Yes

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.

@zackmsa777-a11y

Copy link
Copy Markdown
Contributor Author

Acknowledged — thank you for the real-API measurements.

Your 12-request table is the better evidence. Main 31d03f78 and this head both keep instruction hashes equal and both read 5,888 cached tokens on the event turn and turn 3. That does not support a cache-collapse claim, and I am not asking to land this as one.

Agreed on reachability: the supported Gateway completion/room-event routes you checked always produce a nonempty transcript, so they never enter the empty-transcript runtimeOnly system-prompt branch. The regression only hits that branch by injecting an empty transcript into the runner.

Happy to follow whichever maintainer call you want:

  1. Close — fine if the unused branch is not worth a cleanup.
  2. Keep as an unreachable-branch refactor — I can retitle, drop the cache-regression framing from the body, and remove the now-unused system-setter callback if that is the preferred shape.

No further cache-regression argument from this side.

@obviyus obviyus changed the title fix(prompt): keep runtime-only event turns cache-stable without rewriting system prompt refactor(prompt): remove unreachable runtime-only system prompt path Sep 11, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Sep 11, 2026
@obviyus
obviyus dismissed their stale review September 11, 2026 10:00

The three requested fixes are verified at f771ad2901da825def8932ce3f91b775a4a83f93. This review is superseded by the scoped refactor and fresh exact-head review.

@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Sep 11, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. and removed P2 Normal backlog priority with limited blast radius. labels Sep 11, 2026
@obviyus
obviyus force-pushed the fix/runtime-event-prompt-cache-churn branch from f771ad2 to 90cb503 Compare September 11, 2026 10:09
@obviyus
obviyus merged commit b97da79 into openclaw:main Sep 11, 2026
365 of 367 checks passed
@obviyus

obviyus commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

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:

Revision, both runs Turn 1 cached tokens Event turn cached tokens Turn 3 cached tokens Instruction hashes
Main merge-base 0 5,888 5,888 Equal within each run
Original PR head 0 5,888 5,888 Equal within each run

The event reached the conversation input on both revisions. The refactor preserves the author's commits and credit.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 12, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

2 participants