diff --git a/README.md b/README.md index 122bca79..67f370fe 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/docs/local_agent_loop.md b/docs/local_agent_loop.md index bacef3f1..aeb0fd75 100644 --- a/docs/local_agent_loop.md +++ b/docs/local_agent_loop.md @@ -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. @@ -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 diff --git a/src/coding_review_agent_loop/config.py b/src/coding_review_agent_loop/config.py index 3d7da680..62d673d7 100644 --- a/src/coding_review_agent_loop/config.py +++ b/src/coding_review_agent_loop/config.py @@ -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)", @@ -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 diff --git a/tests/test_antigravity.py b/tests/test_antigravity.py index fd892390..90768a1d 100644 --- a/tests/test_antigravity.py +++ b/tests/test_antigravity.py @@ -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 diff --git a/tests/test_antigravity_quota_groups.py b/tests/test_antigravity_quota_groups.py index fe5b3f88..981c2748 100644 --- a/tests/test_antigravity_quota_groups.py +++ b/tests/test_antigravity_quota_groups.py @@ -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: @@ -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" @@ -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) @@ -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 @@ -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") @@ -310,10 +357,11 @@ 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 @@ -321,7 +369,9 @@ 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) @@ -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 = [] diff --git a/tests/test_cli_repair.py b/tests/test_cli_repair.py index e979603d..1fea7772 100644 --- a/tests/test_cli_repair.py +++ b/tests/test_cli_repair.py @@ -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"): @@ -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"), @@ -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 diff --git a/tests/test_docs_guidance.py b/tests/test_docs_guidance.py index 76faf7b3..a2362948 100644 --- a/tests/test_docs_guidance.py +++ b/tests/test_docs_guidance.py @@ -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)", diff --git a/tests/test_repair.py b/tests/test_repair.py index c06b8ab2..7f2d64fd 100644 --- a/tests/test_repair.py +++ b/tests/test_repair.py @@ -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 @@ -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