Repository navigation
fix(ai-accounts): use per-step usage_update and cap replay transcript for Antigravity ACP - #294
Merged
neolectron merged 3 commits intoNov 24, 2026
Conversation
… for Antigravity ACP
The latest usage_update now lives on the session instead of the DSH step that received it. A final step whose LLM call sends no fresh usage_update reports the last known context size instead of falling back to the cumulative prompt usage that triggered false CONTEXT_WINDOW_EXCEEDED. The replay budget also counts image blocks, and a pending prompt that leaves no budget keeps the omission marker so the model knows earlier history was dropped.
Resolves the conflict with astahmer#295: both sides appended tests to antigravity-acp.test.ts, so both blocks are kept.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes two compounding bugs in
AntigravityAcpSessions(plugins/@dshfiles/ai-accounts/src/antigravity-acp.ts) that caused long Antigravity (agy acp) sessions to hit falseCONTEXT_WINDOW_EXCEEDEDerrors at 1.5M–2.9M reported tokens and fail every automatic and manual compaction withsummarization produced no text summary content:Cumulative multi-step
result.usagetriggered falseCONTEXT_WINDOW_EXCEEDED:agy acpemits per-stepusage_updatenotifications ({ used, size }), while the finalsession/promptresult.usagesums tokens across every LLM step in that prompt (e.g. 40 steps × ~73k = 2.92M tokens).antigravity-acp.tsignoredusage_update(leaving everytoolUsestep at0tokens) and copied the cumulativeresult.usageinto the final step'soutput.usage.pi-ai'sisContextOverflowsawinput + cacheRead > 1_048_576and converted the completed turn intoCONTEXT_WINDOW_EXCEEDED.antigravity-acp.tslistens tousage_update, reports live per-stepusedtokens ontoolUsesteps, and uses the latestusage_update.usedinstead of cumulativeresult.usagewhenever the prompt spanned multiple steps.usedvalue is kept on the session, not on the DSH step that received it, so a final step whose LLM call sends no freshusage_updatereports the last known context size instead of falling back to the cumulative usage. Cumulativeresult.usageis used only whenagysent nousage_updateduring the whole prompt.Unbounded transcript replay exceeded
agy acp's ~192 KB single-prompt limit and dropped the compaction instruction:agy acphard-truncates a singlesession/promptpast ~192 KB (<truncated N bytes>), wiping out trailing prompt blocks.CliBridge.renderTranscript(earlier)easily exceeded 192 KB, soagytruncated away the trailingCOMPACTION_INSTRUCTIONblock. Seeing a truncated coding transcript with DSH's MCP tools attached, the model called a tool (toolUse) with no text, causing@deepseek-ai/dsh-compaction-basicto fail withsummarization produced no text summary content.attach()budgets the rendered replay transcript (MAX_PROMPT_BYTES = 160_000minus the trailing prompt blocks), keeping head (25%) + omission marker + tail (75%) on UTF-8 byte boundaries so trailing instructions/messages are never truncated byagy.Not covered here
Tracked in #296: the replay cap keeps only part of a long history, a compaction request appears to share and stop the conversation's own
agyprocess, and compaction requests still offer DSH's tools to the model.Verification
pnpm exec oxlint --config .oxlintrc.json plugins/@dshfiles/ai-accounts/src/antigravity-acp.ts plugins/@dshfiles/ai-accounts/src/antigravity-acp.test.ts— 0 warnings, 0 errorspnpm exec oxfmt --check --config .oxfmtrc.json plugins/@dshfiles/ai-accounts/src/antigravity-acp.ts plugins/@dshfiles/ai-accounts/src/antigravity-acp.test.ts— cleanpnpm --dir plugins/@dshfiles/ai-accounts run typecheck— 0 errorspnpm --dir plugins/@dshfiles/ai-accounts exec vitest run src/antigravity-acp.test.ts— 15/15 passed (including 3 new regression tests: per-stepusage_update, a final step with no freshusage_update, and replay transcript capping)pnpm exec turbo run typecheck test --filter=@dshfiles/ai-accounts— 38/38 tasks successful