You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Long cached Anthropic tool loops could report aggregate cache billing buckets as
if they were one live context-window snapshot. That inflated token counts and
could trigger compaction well below the configured reserve threshold.
Why This Change Was Made
Both Anthropic stream adapters now preserve the prompt snapshot from message_start for context-window accounting while retaining the final
aggregate cache buckets for billing and cost reporting.
The shared context-token helper prefers an explicit prompt snapshot, then
derives the latest call's prompt size from total - output, and finally falls
back to component sums. Accumulated session usage remains component-based.
Metadata persistence and timeout-driven compaction use the same helper so the
decision is consistent across runner paths.
User Impact
Cached Anthropic sessions no longer compact early because repeated cache-read
and cache-write billing totals are mistaken for the current prompt size.
Billing totals remain intact, and sessions above the real context threshold
still compact normally.
pnpm check:changed passed, including production/test typechecks, all core
oxlint shards, import-cycle checks, and changed-surface guards.
Fresh autoreview: .agents/skills/autoreview/scripts/autoreview --mode local --prompt-file .local/review-ci-followup.md --stream-engine-output
no accepted/actionable findings;
patch correct, confidence 0.98.
Hosted compact jobs still expose four unrelated docs-sync failures. Each was
reproduced unchanged on current origin/main at 1d9fb2773f04ee8828d98077130b06496344ac2a: src/docs/environment-docs.test.ts, src/config/talk-defaults.test.ts, src/agents/minimax-docs.test.ts, and src/cron/isolated-agent/run-fallback-policy.test.ts.
This PR changes none of those files or docs.
Summary
The latest durable ClawSweeper review was for head f8f7878534960589affe2b6b736b00d9bcd2ae95, but the PR head is now 5fc8f0ab37c208b7864262269ac55e307d473316. Its old verdict and PR readiness labels are no longer current.
Next step
Run or wait for a fresh ClawSweeper review on the current PR head.
Review history (8 earlier review cycles)
reviewed 2026-07-04T07:15:55.535Z sha 6cc347b :: needs real behavior proof before merge. :: [P1] Preserve cached prompt tokens in the fallback
reviewed 2026-07-04T09:18:23.136Z sha 4bc55b6 :: found issues before merge. :: [P1] Carry a real context snapshot before dropping cache buckets
reviewed 2026-07-04T12:06:46.712Z sha f38d668 :: needs real behavior proof before merge. :: none
reviewed 2026-07-04T12:19:52.464Z sha f38d668 :: needs real behavior proof before merge. :: none
clawsweeperBot
added
rating: 🧂 unranked krab
Not merge-ready due to missing proof or serious correctness/safety concerns.
status: 📣 needs proof
The PR needs real behavior proof before ClawSweeper can clear the contributor ask.
P1
High-priority user-facing bug, regression, or broken workflow.
merge-risk: 🚨 session-state
🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state.
labels
Jul 4, 2026
I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.
I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
agentsAgent runtime and toolingdocsImprovements or additions to documentationgatewayGateway runtimeP1High-priority user-facing bug, regression, or broken workflow.size: XL
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #99843
What Problem This Solves
Long cached Anthropic tool loops could report aggregate cache billing buckets as
if they were one live context-window snapshot. That inflated token counts and
could trigger compaction well below the configured reserve threshold.
Why This Change Was Made
Both Anthropic stream adapters now preserve the prompt snapshot from
message_startfor context-window accounting while retaining the finalaggregate cache buckets for billing and cost reporting.
The shared context-token helper prefers an explicit prompt snapshot, then
derives the latest call's prompt size from
total - output, and finally fallsback to component sums. Accumulated session usage remains component-based.
Metadata persistence and timeout-driven compaction use the same helper so the
decision is consistent across runner paths.
User Impact
Cached Anthropic sessions no longer compact early because repeated cache-read
and cache-write billing totals are mistaken for the current prompt size.
Billing totals remain intact, and sessions above the real context threshold
still compact normally.
Evidence
b054cb5c5921218b0c5b2b8783efb84cf3728df8.node scripts/run-vitest.mjs src/agents/usage.test.ts src/agents/embedded-agent-runner/run/helpers.test.ts src/llm/providers/anthropic.test.ts src/agents/anthropic-transport-stream.test.ts src/auto-reply/status.test.ts src/agents/embedded-agent-runner/run.empty-error-retry.test.ts src/agents/embedded-agent-runner/run.compaction-loop-guard.test.ts src/agents/embedded-agent-runner/run.overflow-compaction.loop.test.ts src/agents/embedded-agent-runner/run.overflow-compaction.test.tstbx_01kwr9ecvcty3pvvtthtkw60kc:pnpm check:changedpassed, including production/test typechecks, all coreoxlint shards, import-cycle checks, and changed-surface guards.
.agents/skills/autoreview/scripts/autoreview --mode local --prompt-file .local/review-ci-followup.md --stream-engine-outputreproduced unchanged on current
origin/mainat1d9fb2773f04ee8828d98077130b06496344ac2a:src/docs/environment-docs.test.ts,src/config/talk-defaults.test.ts,src/agents/minimax-docs.test.ts, andsrc/cron/isolated-agent/run-fallback-policy.test.ts.This PR changes none of those files or docs.