Skip to content

feat(antigravity): adopt 512k context window and 350k baton/breaker thresholds - #128

Merged
futuregerald merged 1 commit into
mainfrom
feat/512k-context-350k-baton
Nov 17, 2026
Merged

futuregerald merged 1 commit into
mainfrom
feat/512k-context-350k-baton

Conversation

@futuregerald

Copy link
Copy Markdown
Owner

Summary

  • Doubles the documented Gemini 4 (Carbon, Argon, Hydrogen) and gemini-3.8-flash compaction window from 256k to 512k across the Antigravity catalog, global/project GEMINI.md templates, subagent prompts, and tracks.yaml.
  • Raises the autonomous_breaker.py context thresholds so sessions do not hard-block until 350k tokens (BATON_WARN_TOKENS = 310000, BATON_BLOCK_TOKENS = 350000 for Coordinator and Swarm Worker caps, and SUBAGENT_TOKEN_CAP = 350000 with <320k peak-context guidance), and updates session_metrics.py's zero-compaction fallback to match (310000 / 350000).
  • Adds embedded catalog regression checks in internal/catalog/catalog_test.go and updates all Python unit/replay suites and Go -tags=e2e live hook sandbox scenarios to verify the 310k / 350k boundaries.

Background

Context

Antigravity's PreToolUse circuit-breaker hook (internal/catalog/antigravity/hooks/autonomous_breaker.py) partitions token estimates into three budgets before model auto-compaction degrades reasoning:

  1. Coordinator (BATON_WARN_TOKENS / BATON_BLOCK_TOKENS): Issues a one-time warning ahead of compaction (with a +10k buffer on authorized autonomous runs before normal commands warn) and blocks non-exempt calls at BATON_BLOCK_TOKENS until ACTIVE_CONTEXT.md is written (+50k unlock window).
  2. Swarm Workers (BATON_BLOCK_TOKENS): Exempt from the early Coordinator warning, blocking at BATON_BLOCK_TOKENS with a +25k /tmp/*.md unlock so share-workspace workers can commit WIP and post SHARE_ROOT + SHA.
  3. Subagent Helpers (SUBAGENT_TOKEN_CAP): Caps invoke_subagent planner and implementer helpers, allowing only wrap-up .md writes and send_message once reached.

The problem

Gemini's maximum context window doubled from 256k to 512k, leaving the previous 205k warn, 235k Coordinator/worker block, and 200k subagent cap prematurely interrupting multi-file planner traces, implementer TDD runs, and Coordinator orchestration well below 350k tokens.

The fix

  • Hook & metrics defaults (autonomous_breaker.py, session_metrics.py): Updated default thresholds to BATON_WARN_TOKENS = 310000 (40k runway before block; 320k authorized +10k command threshold), BATON_BLOCK_TOKENS = 350000 (leaving >110k headroom even after the +50k ACTIVE_CONTEXT.md handoff unlock inside the 512k window), and SUBAGENT_TOKEN_CAP = 350000 (with <320k peak-context prompt guidance). Retained the Stage-3 ~120k Warm Root wrap-up proxy and the 1-phase-per-implementer reuse rule, since re-billing warm subagent histories across phases remains a token-cost concern independent of the 512k ceiling.
  • Skills, subagents, templates & tracks.yaml: Updated baton-pass, antigravity-orchestration, peer-pipeline-swarm, future-model-router (SKILL.md + references/model-map.md), subagent-driven-development, lifecycle, planner.md, implementer.md, GEMINI.md, templates/GEMINI-BASE.md, antigravity/README.md, and tracks.yaml to reflect 512k / 310k / 350k.
  • Catalog invariant gate (catalog_test.go): Added an embedded FS walk across all antigravity/**/*.{md,py} files and tracks.yaml asserting zero stale 256k, 205k, 235k, 200k cap, or <185k strings and verifying the new 310000 / 350000 defaults in autonomous_breaker.py.

Test plan

  • PYTHONDONTWRITEBYTECODE=1 pytest -p no:cacheprovider -q internal/catalog/antigravity/hooks — 131 passed (covering <310k allow, [310k, 320k) authorized delegation/SYSTEM_MESSAGE warn vs normal run_command allow, [320k, 350k) +10k warn, >=350k Coordinator/Swarm/Subagent blocks, 360k Windows backslash ACTIVE_CONTEXT.md unlock, 310k refresh_floor anti-ratchet, replay_breaker helper block accounting, and session_metrics zero-compaction 310k/350k fallback)
  • HOME=$(mktemp -d) go test -race ./... — all 9 Go packages passing (including new catalog_test.go stale-threshold walk and zero-comment hook invariants)
  • HOME=$(mktemp -d) go test -tags=e2e ./e2e -run '^TestHostDesktopAppsCompatibilitySandbox$' -v — live skill-installer + autonomous-breaker.sh sandbox verification passing (315k >= 310k warn, 355k >= 350k block + +50k unlock, and 355k >= 350k subagent cap)
  • ./scripts/sync-antigravity-from-local.sh, test -z "$(gofmt -l .)", and go vet ./... — clean (exit 0)

Rollback plan

Revert this PR and re-run skill-installer --target=antigravity --global --force --yes (or set BATON_WARN_TOKENS=205000 BATON_BLOCK_TOKENS=235000 SUBAGENT_TOKEN_CAP=200000 in the environment for immediate rollback without reinstalling).

@futuregerald
futuregerald merged commit 8863af0 into main Nov 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant