Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1520,7 +1520,6 @@ snapshot with bounded, spillable excerpts.
| Gemini | `gemini` | Legacy, best-effort path for accounts that still have CLI access. |

The default Antigravity model chain is `Gemini 3.8 Flash (High)`, then
`Gemini 3.7 Flash (High)`, then `Gemini 3.6 Flash (High)`, then `Gemini 3.1 Pro (High)`, then
`Claude Opus 5.5 (Medium)` (served on a separate quota) for eligible capacity
failures. A quota-exhausted provider is skipped as a whole quota group, so a
Gemini exhaustion goes straight to Opus; see
Expand All @@ -1535,7 +1534,7 @@ structured turns use agy's schema-constrained output. Disable it with

Malformed structured responses get a format-repair pass. By default it uses
Antigravity with the repair chain `Gemini 3.8 Flash (Medium)`, then
`Gemini 3.7 Flash (Medium)`, followed by the Antigravity chain above. Use
`Claude Opus 5.5 (Medium)`, followed by the Antigravity chain above. Use
`--repair-backend` and repeatable `--repair-model` to change it. The default
requires the `agy` CLI even when no role uses Antigravity; on a host without it,
pass `--repair-backend codex --repair-model MODEL` (or `claude`). Models that
Expand Down
6 changes: 3 additions & 3 deletions docs/local_agent_loop.md
Original file line number Diff line number Diff line change
Expand Up @@ -1125,12 +1125,12 @@ unavailable reread can never remove an established evidence barrier. A reviewer-
change never reassigns a converted obligation's stored owners; the clearance
rule above already falls back to the whole current board.

Gemini CLI consumer access (free / Google AI Pro / Ultra) is retiring on June 18, 2026; personal-account `gemini` users should migrate to the Antigravity CLI (`agy`) with `--coder antigravity` / `--reviewer antigravity` (pick a single model via `--antigravity-model`, or an ordered fallback chain via `--antigravity-models`; default chain `Gemini 3.8 Flash (High)` → `Gemini 3.7 Flash (High)` → `Gemini 3.6 Flash (High)` → `Gemini 3.1 Pro (High)` → `Claude Opus 5.5 (Medium)`; see [Quota groups and fallback](#quota-groups-and-fallback)). Enterprise / API-key Gemini CLI paths may remain available for organizations that still have access, so the `gemini` backend is retained for those users. Direct Gemini CLI support is best-effort: maintainers without enterprise Gemini CLI access need reporter-provided `.agent-loop-logs/*gemini.log` output, response-file contents, CLI version, and any sharable account/access context to debug live `gemini` failures. Antigravity turns are single-shot (no cross-round session resume) and report estimated usage.
Gemini CLI consumer access (free / Google AI Pro / Ultra) is retiring on June 18, 2026; personal-account `gemini` users should migrate to the Antigravity CLI (`agy`) with `--coder antigravity` / `--reviewer antigravity` (pick a single model via `--antigravity-model`, or an ordered fallback chain via `--antigravity-models`; default chain `Gemini 3.8 Flash (High)` → `Claude Opus 5.5 (Medium)`; see [Quota groups and fallback](#quota-groups-and-fallback)). Enterprise / API-key Gemini CLI paths may remain available for organizations that still have access, so the `gemini` backend is retained for those users. Direct Gemini CLI support is best-effort: maintainers without enterprise Gemini CLI access need reporter-provided `.agent-loop-logs/*gemini.log` output, response-file contents, CLI version, and any sharable account/access context to debug live `gemini` failures. Antigravity turns are single-shot (no cross-round session resume) and report estimated usage.


### Quota groups and fallback

The default Antigravity chain is `Gemini 3.8 Flash (High)` → `Gemini 3.7 Flash (High)` → `Gemini 3.6 Flash (High)` → `Gemini 3.1 Pro (High)` → `Claude Opus 5.5 (Medium)`. The four Gemini entries share one quota; the Claude entry is served on a separate one, so it is reached only when Gemini cannot serve.
The default Antigravity chain is `Gemini 3.8 Flash (High)` → `Claude Opus 5.5 (Medium)`. The Gemini entry uses the Gemini quota; the Claude entry is served on a separate one, so it is reached only when Gemini cannot serve.

- **Groups.** Each chain entry belongs to a quota group derived from its name: names starting with `Gemini` form the `gemini` group, names starting with `Claude` the `claude` group, and any other name is its own group. `--antigravity-quota-group MODEL=GROUP` (repeatable) overrides the derivation; `MODEL` must be in the configured chain. Groups are a **skipping heuristic, not a guarantee of independent quota**: agy can fail every model for an account-wide limit.
- **Exhaustion is read from the provider's own error frame only** (the `Error:` line plus its indented continuation lines, a JSON error object, or agy's `AGY_ERROR:` line), taken from the raw output, never from transcript text. Capacity-only wording (`high traffic`, `capacity exhausted`), short resets (300 s or less), bare `429` and auth/billing failures are never exhaustion.
Expand Down Expand Up @@ -9510,7 +9510,7 @@ For structured plan reviews, plan revisions, PR reviews, and coder follow-ups,
a present but malformed structured response may get a repair pass before the
local failure is raised. By default the repair pass calls Antigravity through
the existing PTY backend with the default repair chain `Gemini 3.8 Flash (Medium)` →
`Gemini 3.7 Flash (Medium)`; explicit repair models replace that chain and are
`Claude Opus 5.5 (Medium)`; explicit repair models replace that chain and are
followed by the configured coder/reviewer chain. Models missing from `agy models`
are skipped. When `agy` reports a transient `model-access validation errors`
failure on its own output channel (stdout with no response artifact and no
Expand Down
6 changes: 2 additions & 4 deletions src/coding_review_agent_loop/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@
# for discoverability/symmetry with DEFAULT_ANTIGRAVITY_QUOTA_SIGNATURES.
DEFAULT_ANTIGRAVITY_MODELS: tuple[str, ...] = (
"Gemini 3.8 Flash (High)",
"Gemini 3.7 Flash (High)",
"Gemini 3.6 Flash (High)",
"Gemini 3.1 Pro (High)",
# Served on a quota separate from Gemini's, so it only runs when the Gemini
# group cannot serve (#1236). Two reviewers may then share one model.
"Claude Opus 5.5 (Medium)",
Expand Down Expand Up @@ -105,7 +102,8 @@
DEFAULT_ANTIGRAVITY_PRINT_TIMEOUT_SECONDS = 10 * 60
DEFAULT_REPAIR_MODELS: tuple[str, ...] = (
"Gemini 3.8 Flash (Medium)",
"Gemini 3.7 Flash (Medium)",
# Served on Antigravity's separate quota, so it is a real fallback (#2023).
"Claude Opus 5.5 (Medium)",
)
# agy reports a transient model-access failure on its provider channel (stdout,
# with no response artifact) with this text. Matched case-insensitively; the
Expand Down
3 changes: 0 additions & 3 deletions tests/test_antigravity.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,9 +583,6 @@ def test_config_from_args_antigravity_defaults(tmp_path):
assert config.antigravity_model is None
assert config.antigravity_models == (
"Gemini 3.8 Flash (High)",
"Gemini 3.7 Flash (High)",
"Gemini 3.6 Flash (High)",
"Gemini 3.1 Pro (High)",
"Claude Opus 5.5 (Medium)",
)
assert config.antigravity_print_timeout_seconds == 600
Expand Down
79 changes: 66 additions & 13 deletions tests/test_antigravity_quota_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ def test_named_seats_share_backend_quota_memory_without_model_substitution(tmp_p
HIGH_TRAFFIC = "Error: high traffic, try again in a minute"
OPUS = "Claude Opus 5.5 (Medium)"
GEM1 = "Gemini 3.8 Flash (High)"
# Test-local multi-Gemini chain for walk-mechanics tests that need several
# entries in the gemini quota group. It is a fixture, not a production default.
GEM2 = "Gemini Sibling B (High)"
MULTI_GEMINI_CHAIN = (GEM1, GEM2, "Gemini Sibling C (High)", "Gemini Sibling D (High)", OPUS)
REMOVED_DEFAULT_MODELS = (
"Gemini 3.7 Flash (High)",
"Gemini 3.6 Flash (High)",
"Gemini 3.1 Pro (High)",
)


class FakeClock:
Expand Down Expand Up @@ -129,10 +138,14 @@ def _turn(tmp_path, outputs, *, agent_max_retries=1, runner=None, **overrides):
# --- config / groups -------------------------------------------------------

def test_default_chain_has_opus_last():
assert len(DEFAULT_ANTIGRAVITY_MODELS) == 5
assert DEFAULT_ANTIGRAVITY_MODELS == (GEM1, OPUS)
assert DEFAULT_ANTIGRAVITY_MODELS[-1] == OPUS


def test_default_chain_quota_groups_are_gemini_then_claude():
assert [agy.antigravity_quota_group(m) for m in DEFAULT_ANTIGRAVITY_MODELS] == ["gemini", "claude"]


def test_group_derivation_and_override():
assert agy.antigravity_quota_group("Gemini 3.1 Pro (High)") == "gemini"
assert agy.antigravity_quota_group(" claude Sonnet 5.5 (Medium)") == "claude"
Expand Down Expand Up @@ -171,7 +184,9 @@ def test_cli_override_must_name_a_chain_model(tmp_path):


def test_override_only_on_fallback_entry_survives_singleton(tmp_path):
config = make_config(tmp_path, antigravity_quota_groups=((OPUS, "x"),))
config = make_config(
tmp_path, antigravity_models=MULTI_GEMINI_CHAIN, antigravity_quota_groups=((OPUS, "x"),)
)
state = agy.AntigravityAttemptState.from_config(config, 1)
assert state.groups == ("gemini",) * 4 + ("x",)
narrowed = state.singleton_config(config)
Expand All @@ -191,6 +206,30 @@ def test_quota_on_first_link_skips_gemini_group_without_sleep(tmp_path):
assert response.model_used == OPUS


def test_default_chain_quota_exhaustion_jumps_straight_to_opus(tmp_path):
with workdir_claims.workdir_claim_scope():
response, error, models, sleeps, _l = _turn(tmp_path, [_fail(QUOTA_4H), ("ok review", 0)])
assert error is None and response.text == "ok review"
assert response.model_used == OPUS
assert models == [GEM1, OPUS] # no retry of the exhausted model
assert sleeps == []
assert not set(models) & set(REMOVED_DEFAULT_MODELS)


def test_default_chain_transient_failures_end_at_opus_with_ordinary_error(tmp_path):
with workdir_claims.workdir_claim_scope():
runner = FakeRunner(antigravity_outputs=[_fail(HIGH_TRAFFIC)] * 3)
_r, error, models, _s, _l = _turn(tmp_path, [], agent_max_retries=1, runner=runner)
assert runner.antigravity_outputs == [] # every queued failure was consumed
memory = agy.quota_memory_for_current_run()
assert all(memory.entry(g) is None for g in ("gemini", "claude"))
assert models == [GEM1, GEM1, OPUS]
assert type(error) is AgentInvocationError
assert not isinstance(error, QuotaResetExceededError)
assert not str(error).startswith("Antigravity unavailable")
assert not set(models) & set(REMOVED_DEFAULT_MODELS)


def test_quota_exhaustion_does_not_consume_retry_budget(tmp_path):
_r, error, models, sleeps, _l = _turn(
tmp_path, [_fail(LIVE_SAMPLE), _fail(HIGH_TRAFFIC), ("done", 0)], agent_max_retries=1
Expand Down Expand Up @@ -283,21 +322,29 @@ def test_transient_walk_to_opus_then_exhaustion_jumps_back_to_gemini(tmp_path):
tmp_path,
[_fail(HIGH_TRAFFIC)] * 4 + [_fail(QUOTA_4H), _fail(HIGH_TRAFFIC), _fail(HIGH_TRAFFIC)],
agent_max_retries=0,
antigravity_models=MULTI_GEMINI_CHAIN,
)
assert models[:5] == list(DEFAULT_ANTIGRAVITY_MODELS)
assert models[:5] == list(MULTI_GEMINI_CHAIN)
assert models[5] == GEM1 # Claude group exhausted; jump back, no raise
assert not isinstance(error, QuotaResetExceededError)


def test_unverified_transcript_reset_at_end_of_chain_does_not_raise_quota_reset(tmp_path):
@pytest.mark.parametrize("chain", [MULTI_GEMINI_CHAIN, DEFAULT_ANTIGRAVITY_MODELS], ids=["multi-gemini", "default"])
def test_unverified_transcript_reset_at_end_of_chain_does_not_raise_quota_reset(tmp_path, chain):
noise = "reviewing: the quota note says try again in 4h\nmore transcript\n"
outputs = [_fail(HIGH_TRAFFIC)] * 5 + [_fail(noise + HIGH_TRAFFIC)]
# One retry is spent on the first entry, then the walk reaches Opus, which
# fails last with the transcript noise. Queue exactly one output per call.
expected_models = [GEM1, GEM1, *chain[1:]]
outputs = [_fail(HIGH_TRAFFIC)] * (len(expected_models) - 1) + [_fail(noise + HIGH_TRAFFIC)]
runner = FakeRunner(antigravity_outputs=list(outputs))
with workdir_claims.workdir_claim_scope():
_r, error, models, _s, _l = _turn(tmp_path, outputs, agent_max_retries=1)
_r, error, models, _s, _l = _turn(
tmp_path, outputs, agent_max_retries=1, runner=runner, antigravity_models=chain
)
memory = agy.quota_memory_for_current_run()
assert all(memory.entry(g) is None for g in ("gemini", "claude"))
# one retry is spent on Gemini 3.8, then the walk reaches Opus, which fails last
assert models == [GEM1, GEM1, *DEFAULT_ANTIGRAVITY_MODELS[1:]]
assert models == expected_models
assert runner.antigravity_outputs == [] # the end-of-chain noise output was consumed
assert type(error) is AgentInvocationError
assert not str(error).startswith("Antigravity unavailable")

Expand All @@ -310,18 +357,21 @@ def test_sparse_newline_head_header_never_becomes_exhaustion(tmp_path):
assert capacity.is_capacity and capacity.frame == ""
with workdir_claims.workdir_claim_scope():
_r, error, models, sleeps, _l = _turn(
tmp_path, [_fail(text), ("ok", 0)], agent_max_retries=0
tmp_path, [_fail(text), ("ok", 0)], agent_max_retries=0,
antigravity_models=MULTI_GEMINI_CHAIN,
)
assert error is None
assert models == [GEM1, "Gemini 3.7 Flash (High)"] # transient sibling fallback, no skip
assert models == [GEM1, GEM2] # transient sibling fallback, no skip
assert agy.quota_memory_for_current_run().entry("gemini") is None


def test_shared_limit_message_names_the_actual_last_failure(tmp_path):
claude_frame = "Error: quota exceeded (claude frame)"
gemini_frame = "Error: quota exceeded (gemini frame)"
outputs = [_fail(HIGH_TRAFFIC)] * 4 + [_fail(claude_frame), _fail(gemini_frame)]
_r, error, models, _s, _l = _turn(tmp_path, outputs, agent_max_retries=0)
_r, error, models, _s, _l = _turn(
tmp_path, outputs, agent_max_retries=0, antigravity_models=MULTI_GEMINI_CHAIN
)
assert models[-2:] == [OPUS, GEM1]
assert type(error) is AgentInvocationError
assert "gemini frame" in str(error) and "claude frame" not in str(error)
Expand Down Expand Up @@ -430,8 +480,11 @@ def test_multiple_overrides_and_out_of_chain_repair_model(tmp_path, monkeypatch)
agy = sys.modules[repair_module.AntigravityBackend.__module__]

monkeypatch.setattr(agy, "_antigravity_settings_path", lambda: tmp_path / "settings.json")
overrides = ((GEM1, "g1"), ("Gemini 3.7 Flash (High)", "g1"), (OPUS, "g2"))
config = make_config(tmp_path, antigravity_quota_groups=overrides, repair_models=("Out Of Chain Model",))
overrides = ((GEM1, "g1"), (GEM2, "g1"), (OPUS, "g2"))
config = make_config(
tmp_path, antigravity_models=MULTI_GEMINI_CHAIN, antigravity_quota_groups=overrides,
repair_models=("Out Of Chain Model",),
)
state = agy.AntigravityAttemptState.from_config(config, 1)
assert state.groups == ("g1", "g1", "gemini", "gemini", "g2")
captured = []
Expand Down
27 changes: 23 additions & 4 deletions tests/test_cli_repair.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,19 @@ def test_cli_repair_requires_explicit_model(tmp_path, backend):
make_config(tmp_path, repair_backend=backend)


def test_codex_repair_flag_without_model_rejected_and_single_model_verbatim(tmp_path):
base = [
"issue", "1", "--repo", "OWNER/REPO",
"--codex-dir", str(tmp_path / "codex"),
"--subprocess-log-dir", str(tmp_path / "logs"),
"--repair-backend", "codex",
]
with pytest.raises(AgentLoopError, match="explicit --repair-model"):
config_from_args(build_parser().parse_args(base), FakeRunner())
config = config_from_args(build_parser().parse_args([*base, "--repair-model", "M"]), FakeRunner())
assert config.repair_models == ("M",)


@pytest.mark.parametrize("backend,effort", [("codex", "max"), ("claude", "minimal"), ("antigravity", "high")])
def test_cli_repair_invalid_effort(tmp_path, backend, effort):
with pytest.raises(AgentLoopError, match="--repair-reasoning-effort"):
Expand Down Expand Up @@ -179,14 +192,20 @@ def test_default_repair_and_antigravity_chains_use_current_flash_generation(tmp_
DEFAULT_REPAIR_MODELS,
)

assert DEFAULT_REPAIR_MODELS == ("Gemini 3.8 Flash (Medium)", "Gemini 3.7 Flash (Medium)")
assert DEFAULT_REPAIR_MODELS == ("Gemini 3.8 Flash (Medium)", "Claude Opus 5.5 (Medium)")
assert DEFAULT_ANTIGRAVITY_MODELS == (
"Gemini 3.8 Flash (High)",
"Claude Opus 5.5 (Medium)",
)
removed = {
"Gemini 3.7 Flash (High)",
"Gemini 3.7 Flash (Medium)",
"Gemini 3.6 Flash (High)",
"Gemini 3.1 Pro (High)",
"Claude Opus 5.5 (Medium)",
)
}
for model in (*DEFAULT_ANTIGRAVITY_MODELS, *DEFAULT_REPAIR_MODELS):
assert model not in removed
assert "Gemini 4 Hydrogen" not in model
args = build_parser().parse_args([
"issue", "1", "--repo", "OWNER/REPO",
"--subprocess-log-dir", str(tmp_path / "logs"),
Expand All @@ -198,5 +217,5 @@ def test_default_repair_and_antigravity_chains_use_current_flash_generation(tmp_
with pytest.raises(SystemExit):
build_parser().parse_args(["issue", "--help"])
help_text = " ".join(capsys.readouterr().out.split())
assert "Gemini 3.8 Flash (Medium) -> Gemini 3.7 Flash (Medium)" in help_text
assert "Gemini 3.8 Flash (Medium) -> Claude Opus 5.5 (Medium)" in help_text
assert "only; required" not in help_text
25 changes: 23 additions & 2 deletions tests/test_docs_guidance.py
Original file line number Diff line number Diff line change
Expand Up @@ -973,13 +973,34 @@ def test_failed_managed_activation_state_report_is_documented():
assert "reports only the measured current state" in doc


def test_antigravity_quota_group_docs_describe_five_model_chain():
from coding_review_agent_loop.config import DEFAULT_ANTIGRAVITY_MODELS
def test_antigravity_quota_group_docs_describe_default_chain():
import re

from coding_review_agent_loop.config import DEFAULT_ANTIGRAVITY_MODELS, DEFAULT_REPAIR_MODELS

guide = LOCAL_AGENT_LOOP_DOC.read_text(encoding="utf-8")
readme = README.read_text(encoding="utf-8")
assert "### Quota groups and fallback" in guide
for model in DEFAULT_ANTIGRAVITY_MODELS:
assert f"`{model}`" in guide
assert f"`{model}`" in readme
for model in DEFAULT_REPAIR_MODELS:
assert f"`{model}`" in guide
assert f"`{model}`" in readme
removed = ("Gemini 3.7 Flash", "Gemini 3.6 Flash", "Gemini 3.1 Pro")
chain_sentences = [
sentence
for text in (guide, readme)
for sentence in re.split(r"(?<=[.;])\s", " ".join(text.split()))
if "default Antigravity chain" in sentence
or "default Antigravity model chain" in sentence
or "default chain `" in sentence
or "repair chain `" in sentence
]
assert len(chain_sentences) >= 4
for sentence in chain_sentences:
for name in removed:
assert name not in sentence, sentence
for expected in (
"skipping heuristic, not a guarantee of independent quota",
"Claude Sonnet 5.5 (Medium)",
Expand Down
16 changes: 9 additions & 7 deletions tests/test_repair.py
Original file line number Diff line number Diff line change
Expand Up @@ -5007,8 +5007,12 @@ def test_fresh_matrix_guard_stays_strict_for_unnormalized_bare_string():
)


def test_execute_repair_default_antigravity_chain_ends_with_opus(tmp_path, monkeypatch):
"""The repair chain is the union of repair and chain models; Opus is now last (#1236)."""
def test_execute_repair_default_chain_is_repair_then_deduplicated_antigravity_chain(tmp_path, monkeypatch):
"""The repair chain is the union of repair and chain models (#1236).

With the #2023 defaults, Opus appears in both chains, so it is tried second
and the de-duplicated Antigravity chain adds only Gemini 3.8 Flash (High).
"""
from coding_review_agent_loop.agents import antigravity as agy_mod
from coding_review_agent_loop.config import DEFAULT_REPAIR_MODELS

Expand All @@ -5025,13 +5029,11 @@ def test_execute_repair_default_antigravity_chain_ends_with_opus(tmp_path, monke
expected_kind="pr_review",
)
tried = list(dict.fromkeys(attempt.model for attempt in attempts))
assert DEFAULT_REPAIR_MODELS == ("Gemini 3.8 Flash (Medium)", "Claude Opus 5.5 (Medium)")
assert tried == [
*DEFAULT_REPAIR_MODELS,
"Gemini 3.8 Flash (High)",
"Gemini 3.7 Flash (High)",
"Gemini 3.6 Flash (High)",
"Gemini 3.1 Pro (High)",
"Gemini 3.8 Flash (Medium)",
"Claude Opus 5.5 (Medium)",
"Gemini 3.8 Flash (High)",
]
assert agy_mod._run_memories == memory_before # repair never touches quota memory

Expand Down