Re-check compaction after every agent step - #493
Conversation
Preview:
|
|
e6a79d8 to
ebf312a
Compare
|
On the two Bonk points: P2, chars/4 undercounting CJK: that is the estimator the turn-start check has always used; the post-step check adds the same estimate to the provider-measured total for the step, so the two checks agree and each step re-anchors on real usage. Not changing the estimator here. #494 caps what one result can contribute, which bounds the exposure. P3, the active-file marker surviving a reload: real. runAgent now clears it before returning reloadForCompaction, the same thing a non-edit tool start does, so the rerun's fresh preview manager starts from the state the client sees. |
|
|
The SUGGESTED_MODELS doc: moved onto the export, with the per-field docs on the entry type where they belong. |
ebf312a to
709f06b
Compare
|
LGTM! |
5fc3f20 to
970f1ec
Compare
|
|
LGTM! |
970f1ec to
74977df
Compare
|
Bonk P2 (19:37) and Devin on the zero-usage case: both right, and I was wrong to remove it. The turn-start check at While there, the decision moved out of its own exported helper and into |
|
LGTM! |
The compaction check ran once, at the start of a turn. A turn whose tool results grew the prompt past the provider limit then failed mid-turn, the user saw an error, and compaction only ran after a manual retry. runAgent now owns the loop the Overseer used to run around it: it loads the durable history, runs one pass, publishes any checkpoint the pass produced, and goes again until a pass finishes. A pass ends early either because it compacted instead of prompting the model (as before) or, new here, because a persisted tool step left the next request over the compaction trigger: the step's measured prompt plus its tool results, or, when the provider reported no usage, a reload regardless so the turn-start estimator measures the whole prompt. Cancellation, connection requests and pending approvals still end the turn ahead of compaction. The 30-step cap on a turn is gone. It came from the ai-sdk's stepCountIs(30) and was carried over when the loop moved to pi-agent-core; nothing else needed it. GPT-5.6 Sol, Luna and Terra gain a `compactionInputBudget` of 272K, the point past which OpenAI prices their input higher. Compaction sizes against that instead of the 1.05M window; the window itself is unchanged.
74977df to
ecbd6b1
Compare
|
# By Maximo Guk (9) and others # Via GitHub * origin: (33 commits) Bump the react-and-ui group across 1 directory with 4 updates (cloudflare#515) Bump the editor-codemirror group across 1 directory with 5 updates (cloudflare#502) Bump the remaining-npm group across 1 directory with 5 updates (cloudflare#501) Bump the github-actions group with 2 updates (cloudflare#499) Fix blueprint configurator readiness (cloudflare#505) fix sizing issues with user search ui (cloudflare#511) gatekeeper-confluence: stop reporting the access-token expiry as the credential expiry (cloudflare#509) Review Workshop eval trajectory changes (cloudflare#477) Compare Workshop evals on pull requests (cloudflare#476) Re-check compaction after every agent step (cloudflare#493) Write the bundled format blueprints in TypeScript (cloudflare#466) add deployment-wide user directory for user search (cloudflare#474) Load agent catalogs each turn instead of caching them on the chat (cloudflare#267) Updated agent prompt: avoid unnecessary implementation details in response, don't always create gadgets (cloudflare#489) Fix Anthropic streams in the local eval target; default evals to GLM 5.3 Flash (cloudflare#495) Make spawned agents persistent across restarts (cloudflare#492) Bump vitest from 4.1.10 to 4.1.11 (cloudflare#470) Restricted data UI - share modal stays usable for restricted workspaces (cloudflare#308) Restricted data: govern restricted reads by observer verification (cloudflare#382) Rename prohibitAllSharing -> containsRestrictedData (cloudflare#381) ... # Conflicts: # packages/workshop-backend/src/user.ts # packages/workshop-shared/src/api.ts
The compaction check ran once, at the start of a turn. A turn whose tool results grew the prompt past the provider limit failed mid-turn with a context error; the user pressed retry, and only that second turn compacted. Robert hit this on Sol at roughly 512K tokens.
runAgentnow owns the loop the Overseer used to run around it: load the durable history, run one pass, publish any checkpoint the pass produced, go again until a pass finishes. The Overseer's side is oneawait runAgent(...)plus two hooks,loadChatHistoryandcommitChatCompaction, which are the two private helpers it already had. A pass ends early either because it compacted instead of prompting the model, as before, or, new here, because a persisted tool step left the next request over the compaction trigger. That decision sits inshouldStopAfterTurnbeside the other stop reasons: the step's measured prompt plus its tool results as the model will see them (not thedetailscopy), or, when the provider reported no usage, a reload regardless so the turn-start estimator measures the whole prompt, the same rule that check already follows. Cancellation, connection requests and pending approvals still end the turn ahead of compaction.The 30-step cap on a turn is gone. It came from the ai-sdk's
stepCountIs(30)and was carried over when the loop moved to pi-agent-core; nothing else needed it.GPT-5.6 Sol, Luna and Terra also gain a
compactionInputBudgetof 272K, the point past which OpenAI prices their input higher. Compaction sizes against that instead of the 1.05M window. The window and output limit are unchanged;getModelTokenLimitsreturns the smaller of the two asinputBudget, so nothing else moves.Tests: the GPT-5.6 limits in
agent-compaction.test.ts, plus the full backend suite and integration. The post-step decision is five lines over two functions the suite already covers (estimateProjectionTokens,shouldCompactChat); the scripted-model harness reports a fixed token count and has no summarizer, so an end-to-end test of it would mean building that, and the incident is the end-to-end check. Build and lint clean.