diff --git a/app/src/modelMeta.ts b/app/src/modelMeta.ts index 296f485d..5c1ae2d7 100644 --- a/app/src/modelMeta.ts +++ b/app/src/modelMeta.ts @@ -154,6 +154,7 @@ export const MODEL_RELEASE_DATES: Record = { "gemini-4-argon": "2026-10-13", "gemini-4-carbon": "2026-11-10", "gemini-4-hydrogen": "2026-11-12", + "gemini-4-neon": "2026-11-18", "gemini-3.1-flash-lite-preview": "2026-03-03", "gpt-5.4-mini": "2026-03-17", "gpt-5.4-nano": "2026-03-17", diff --git a/policybench/config.py b/policybench/config.py index 06a7edeb..fb3b7a9a 100644 --- a/policybench/config.py +++ b/policybench/config.py @@ -126,6 +126,13 @@ # page's one stable version; Google lists no dated snapshot # (aistudio.google.com/docs/models/gemini-4-hydrogen, read 2026-11-13). "gemini-4-hydrogen": "gemini/gemini-4-hydrogen", + # Gemini 4 Neon. The Gemini API changelog lists gemini-4-neon as + # generally available on 2026-11-18, on the paid tier + # (aistudio.google.com/docs/changelog, read 2026-11-19). It runs on the + # first-party Gemini API like the other Gemini rows. The id is the model + # page's one stable version; Google lists no dated snapshot + # (aistudio.google.com/docs/models/gemini-4-neon, read 2026-11-19). + "gemini-4-neon": "gemini/gemini-4-neon", # Cloaked OpenRouter preview listed 2026-08-20 (free window); Z.ai later # identified it as GLM-5.3-Flash. On the board as a labeled preview row. "ox-alpha": "openrouter/stealth/ox-alpha", @@ -324,6 +331,16 @@ # $1.50 / $7.50; the override prices a request from the rates above # whether or not the map is available. "gemini-4-hydrogen": {"input": 1.5, "output": 7.5, "cache_read": 0.075}, + # gemini-4-neon: $3 / $15 per 1M input/output tokens (output includes + # thinking tokens) and $0.15 cached input, the paid tier's standard + # rates, with no introductory rate and no dated change + # (aistudio.google.com/docs/pricing, read 2026-11-19). The page lists one + # rate at every prompt length, implicit caching only, and no free tier + # for this model. litellm 1.95.0's bundled price map has no gemini-4 id; + # PolicyBench uses these rates to reconstruct a request's synchronous + # token cost from its reported usage, whether or not litellm's map has + # the id. + "gemini-4-neon": {"input": 3.0, "output": 15.0, "cache_read": 0.15}, # glm-5.3: $1.40 / $4.40 per 1M (OpenRouter list, 2026-09-03). "glm-5.3": {"input": 1.40, "output": 4.40}, # deepseek dated snapshots via OpenRouter (list prices 2026-09-03). diff --git a/policybench/eval_no_tools.py b/policybench/eval_no_tools.py index 888c5747..c9de6f1f 100644 --- a/policybench/eval_no_tools.py +++ b/policybench/eval_no_tools.py @@ -1061,8 +1061,15 @@ def _uncapped_completion_controls( include_explanations: bool = True, variables: list[str] | None = None, ) -> dict: + card = card_for(model_id) if model_id.startswith("gemini/"): - if model_id == "gemini/gemini-3.1-pro-preview": + cap = GEMINI_MAX_COMPLETION_TOKENS_CAP + if card is not None and card.completion_token_cap is not None: + # A gemini/ card that sets completion_token_cap starts there, as + # a thinking-budget card does in the branch below (base and cap + # both). Every other gemini/ id keeps the family's 16,384. + base_tokens = cap = card.completion_token_cap + elif model_id == "gemini/gemini-3.1-pro-preview": base_tokens = GEMINI_PRO_JSON_MAX_COMPLETION_TOKENS else: base_tokens = GEMINI_JSON_MAX_COMPLETION_TOKENS @@ -1071,10 +1078,9 @@ def _uncapped_completion_controls( base_tokens, variables, include_explanations, - cap=GEMINI_MAX_COMPLETION_TOKENS_CAP, + cap=cap, ) } - card = card_for(model_id) # A thinking-budget card outranks the legacy xai/ family branch: # grok-4.5 reasons by default (14k tokens on the 16-variable probe), # while grok-4.3 has no card and keeps the flat family budget. diff --git a/policybench/model_cards.py b/policybench/model_cards.py index b987562c..35f2ebca 100644 --- a/policybench/model_cards.py +++ b/policybench/model_cards.py @@ -7,7 +7,8 @@ completion budget. None of this is model *configuration* — every model still runs unconfigured at its provider-default reasoning effort. Cards only encode serving-stack facts discovered during onboarding (see -``policybench onboard``). +``policybench onboard``); a card written before its model's onboarding says +so in its notes. Cards OVERRIDE the family-prefix heuristics in ``eval_no_tools``; models without a card (or with a field left ``None``) keep the heuristic treatment. @@ -61,8 +62,11 @@ class ModelCard: # True → 16,384-token completion budget on both explanation arms # (reasoning bills against the same budget as the answer). thinking_budget: bool | None = None - # Overrides the thinking-class starting budget for models whose reasoning - # tail overflows 16,384. Headroom is free — only generated tokens bill. + # The model's starting budget, for models whose reasoning tail overflows + # 16,384: it overrides the thinking-class starting budget on a + # thinking_budget card and, on a gemini/ card, the Gemini family's + # 16,384-token starting budget. Requests are still clamped to the + # escalation ceiling. Headroom is free — only generated tokens bill. completion_token_cap: int | None = None # Hard provider output limit, when it is lower than PolicyBench's 128k # escalation ceiling. This is distinct from ``completion_token_cap``, @@ -736,10 +740,11 @@ class ModelCard: # high (aistudio.google.com/docs/generate-content/thinking, read # 2026-11-13), and all 51 raw generateContent responses in the record # carry thought tokens. The 16,384-token starting budget is not the - # card's: the harness gives every gemini/ id 16,384 - # (GEMINI_JSON_MAX_COMPLETION_TOKENS). The gauntlet used all of it on the - # forced-tool probe, 61% on the 3-variable JSON probe and 44% on the - # whole-scenario JSON probe (22% of the 32,768-token ceiling). + # card's: it sets no completion_token_cap, so the harness gives it the + # Gemini family's 16,384 (GEMINI_JSON_MAX_COMPLETION_TOKENS). The + # gauntlet used all of it on the forced-tool probe, 61% on the + # 3-variable JSON probe and 44% on the whole-scenario JSON probe (22% of + # the 32,768-token ceiling). # - request_timeout_seconds 900. Google's Gemini 4 Carbon guide says hard # prompts "can take several minutes" and recommends HTTP client # timeouts of "at least 15 minutes" @@ -871,10 +876,11 @@ class ModelCard: # 2026-11-13), and all 51 raw generateContent responses in the record # carry thought tokens. The harness sends no thinkingConfig, so this # model's default is high where Carbon's and Argon's is medium. The - # 16,384-token starting budget is not the card's: the harness gives every - # gemini/ id 16,384 (GEMINI_JSON_MAX_COMPLETION_TOKENS). The gauntlet - # used 67% of it on the 3-variable probe and 73% on the whole-scenario - # probe (18% of the 65,536-token ceiling). + # 16,384-token starting budget is not the card's: it sets no + # completion_token_cap, so the harness gives it the Gemini family's + # 16,384 (GEMINI_JSON_MAX_COMPLETION_TOKENS). The gauntlet used 67% of + # it on the 3-variable probe and 73% on the whole-scenario probe (18% of + # the 65,536-token ceiling). # - request_timeout_seconds 600. At the gauntlet's 228 to 234 completion # tokens a second, a request at the 65,536-token ceiling (the second # budget escalation) takes about 280 to 290s, and at the slowest rates @@ -968,6 +974,214 @@ class ModelCard: "minutes per request. Google lists $1.50/$7.50 per 1M." ), ), + # Gemini 4 Neon. This card was written from Google's documentation, read + # 2026-11-19, the day after Google released the model, and from the Gemini + # 4 Hydrogen card above, whose default thinking level, high, it shares. The + # same day the onboarding gauntlet ran under this card, then with the + # thinking class's 300s timeout; two raw generateContent calls with no + # tools asked the model one plain tax question; and a first two-household + # smoke ran on the board's request, then with the Gemini family's + # 16,384-token starting budget. After that smoke the card's starting budget + # moved to the 65,536-token ceiling (completion_token_cap below), and on + # 2026-11-21 a second smoke ran the same two households at that starting + # budget. Field by field: + # - answer_contract "tool": Hydrogen's contract, the board's forced answer + # tool, which litellm sends as mode ANY with allowed_function_names. + # Google's model page lists function calling as supported + # (aistudio.google.com/docs/models/gemini-4-neon), and the API + # reference's FunctionCallingConfig describes mode ANY, naming no + # exception (aistudio.google.com/api-reference/caching). The gauntlet + # settled nothing between the contracts. The API accepted the forced + # call, but on the 3-variable tool probe the model reasoned until the + # 16,384-token budget ran out, nearly all of it on reasoning, and the + # probe ended at length after about two minutes with 0 of 3 outputs + # parsed. The 3-variable JSON probe ended the same way. The gauntlet + # sends each probe once at that budget, with no budget escalation, so it + # found neither contract answering, reported the model "not scorable" at + # that budget, did not reach its whole-scenario probe and derived no + # card. Gemini 4 Carbon's card took JSON because its JSON probes passed + # after its tool probe ran out of budget; here both ran out, so the card + # kept the tool contract. The forced tool worked for both households in + # each smoke: each household answered every output through it, 16 of 16 + # and 20 of 20, values and explanations, so the contract stays. + # - explanation_chunk_size None: the canonical whole-scenario request + # (chunking is closed to new models). + # - thinking_budget True: the model reasons by default. Google's thinking + # guide lists its default as "On (high)", with levels low, medium, high + # and xhigh, and lists "minimal" as not supported on Gemini 4 models + # (aistudio.google.com/docs/thinking); no page read says thinking can be + # turned off. The harness sends no thinkingConfig. Google's pricing page + # bills thinking tokens as output ("Output price (including thinking + # tokens)", aistudio.google.com/docs/pricing). The model reasoned on + # every call in the record. The harness recorded nearly all of each + # gauntlet probe's 16,384 completion tokens as reasoning tokens, the rest + # as text, so litellm 1.95.0 counts reasoning inside completion_tokens + # and the output rate prices it. The two raw calls, one direct REST + # generateContent request each with no tools, asked for a single filer's + # federal income tax before refundable credits, and generateContent + # reported usageMetadata.thoughtsTokenCount on both: about 7,600 thought + # tokens and 350 answer tokens (candidatesTokenCount) with no + # thinkingConfig (the default, high), and about 1,400 and 350 with + # thinkingLevel low. These are facts about the model; the board sends no + # thinkingConfig, so low is not a treatment it uses. Every response in + # both smokes reported reasoning tokens too, most of its completion + # tokens. + # - completion_token_cap 65_536: the starting budget, at the escalation + # ceiling, set after the first smoke. That smoke ran at the Gemini + # family's 16,384-token starting budget + # (GEMINI_JSON_MAX_COMPLETION_TOKENS), which the board's request doubles + # on a length finish to 32,768 and then 65,536. The 20-output household + # answered on its first request, with about 15,000 completion tokens. The + # 16-output household's first two requests used their whole 16,384- and + # 32,768-token budgets, nearly all on reasoning, and ended at length with + # no usable output; its third, at 65,536, answered with about 24,000 + # completion tokens. Those two truncated requests used about 55% of the + # smoke's completion tokens, an estimated $0.75 of its $1.36 at Google's + # list rates (the households about $1.12 and $0.23). Starting at the + # ceiling removes the two lower rungs. On a length finish the harness + # keeps the usable values and explanations a response returned, with + # valid cells from earlier requests. Below the ceiling it asks again at + # the next rung for the outputs still missing. When a request at the + # ceiling ends at length, no rung is left, so it asks for them no more. + # An output still missing its value gets failure source + # budget_exhausted_at_ceiling. One that has its value but lacks a usable + # explanation keeps the value, and the harness adds + # "budget_exhausted_at_ceiling (explanation)" to the error. The second + # smoke ran the same two households at the 65,536-token start, in one + # round. Each household answered every output, values and explanations, + # on its first response through the forced tool; no response ended at + # length, the harness ran no repair, and no request erred or timed out. + # The 20-output household's response used about 19,000 completion tokens + # and the 16-output household's about 35,000, nearly all reasoning, an + # estimated $0.29 and $0.53 at Google's list rates, $0.83 together. Both + # responses used more tokens than the households' answering responses in + # the first smoke; two households cannot show whether the larger first + # budget or run-to-run variation accounts for that. + # - request_timeout_seconds 600, set from the measured output rate as on + # Hydrogen's card. The gauntlet's probes ran at about 127 and 129 + # completion tokens a second, the raw call at the default level at about + # 138, the first smoke's four requests at about 128 to 136, and the + # second smoke's two at about 127 to 129. Those responses ran from about + # 7,900 to 35,000 completion tokens. Every request now asks for the + # 65,536-token ceiling. A response that used all of it would take about + # 475 to 516s if it ran at those 127 to 138 tokens a second, past the + # thinking class's 300s. No request in the record used the whole ceiling + # (the longest used about 35,000 tokens), so those times hold only if the + # rate stays in that range. Google's generateContent long-decode guide, + # read 2026-11-14 for the Carbon and Hydrogen cards above and not re-read + # for this one, says the server closes a non-streaming connection after + # 10 minutes and recommends a 20-minute client read timeout, and its + # option table gives 20 minutes per request + # (aistudio.google.com/docs/long-decode?generate-content=true). If the + # server closes at 10 minutes, a client timeout above 600s could not help + # this request, which litellm sends as one non-streaming request, with no + # long-decode continuation. If the table's 20 minutes applies instead, + # 600s still exceeds the about 475 to 516s that those rates predict for a + # request at the ceiling. This departs from Hydrogen's test, under which + # 600s exceeds what the slowest rates in its record predict: the slowest + # rate here, the raw call at level low (about 1,700 thought and answer + # tokens at about 105 a second), predicts about 624s at the ceiling. The + # card sets that call aside: it ran at a thinking level the board does + # not send. No page read for Neon gives a model-specific client timeout, + # as Google's Gemini 4 Carbon guide does for Carbon (hence Carbon's + # 900s). The margin is smaller than Hydrogen's: a request at the ceiling + # outlasts 600s at any rate below about 109 completion tokens a second. + # - provider_max_completion_tokens 65_536: the Models API's + # outputTokenLimit for the model, whose entry lists generateContent among + # its supported methods (models.get on + # generativelanguage.googleapis.com/v1beta/models/gemini-4-neon, read + # 2026-11-19). litellm makes one non-streaming generateContent request. + # Google's model page gives the same 65,536 as the model's "default + # synchronous" maximum output, and up to 1,048,576 with long decode. The + # raw call at the default level asked for maxOutputTokens 65,536 on one + # non-streaming generateContent request and returned 200 (it stopped at + # about 7,900 thought and answer tokens), which shows only that the value + # is accepted. + # - expected_cost_per_scenario_usd is not set: the gauntlet did not reach + # its whole-scenario probe and derived no cost, and the card takes none + # from the smokes' two households. + # Both raw responses name the model as gemini-4-neon, the requested name, + # with no dated snapshot (modelVersion). The gauntlet's rows carry the same + # name, but litellm sets it from the request on this path, so they cannot + # show a re-route. + "gemini/gemini-4-neon": ModelCard( + litellm_id="gemini/gemini-4-neon", + answer_contract="tool", + request_timeout_seconds=600, + thinking_budget=True, + completion_token_cap=65_536, + provider_max_completion_tokens=65_536, + notes=( + "Written 2026-11-19 from Google's documentation, read that day, the day " + "after Google released the model. The Gemini API changelog lists " + "gemini-4-neon as generally available on 2026-11-18, on the paid tier; " + "Google's pricing page lists no free tier for it. The card takes Gemini 4 " + "Hydrogen's contract, the board's forced answer tool on the " + "whole-scenario request; Google's model page lists function calling as " + "supported. The harness sends no thinkingConfig, and Google's thinking " + "guide lists the model's default as On (high), with levels low, medium, " + "high and xhigh, as for Hydrogen. The same day the onboarding gauntlet " + "ran under this card, then with a 300s timeout and the Gemini family's " + "16,384-token starting budget. The Gemini API accepted the forced call, " + "but on the 3-variable tool probe the model reasoned until the " + "16,384-token budget ran out, with 0 of 3 outputs parsed, and the " + "3-variable JSON probe ended the same way. The gauntlet sends each probe " + "once at that budget, with no budget escalation, so it found neither " + "contract answering, reported the model not scorable at that budget and " + "derived no card. Both contracts failed the same way, so the row kept the " + "tool contract. Two raw generateContent calls with one plain tax question " + "and no tools returned thought tokens (usageMetadata.thoughtsTokenCount): " + "about 7,600 thought tokens and 350 answer tokens with no thinkingConfig, " + "and about 1,400 and 350 at thinking level low, which the board does not " + "send. Both name the model as gemini-4-neon, the requested name, with no " + "dated snapshot. A first two-household smoke then ran on the board's " + "request at the 16,384-token starting budget, which the request doubles " + "on a length finish to 32,768 and then 65,536. Both households answered " + "every output through the forced tool, 16 of 16 and 20 of 20, so the tool " + "contract stays. The 20-output household answered on its first request, " + "with about 15,000 completion tokens. The 16-output household's first two " + "requests used their whole 16,384- and 32,768-token budgets and ended at " + "length with no usable output; its third, at 65,536, answered with about " + "24,000. Those two truncated requests used about 55% of the smoke's " + "completion tokens, an estimated $0.75 of its $1.36 at Google's list " + "rates. So the card starts at the 65,536-token ceiling " + "(completion_token_cap), and no request runs at a lower budget. On a " + "length finish the harness keeps the usable values and explanations a " + "response returned, with valid cells from earlier requests. When a request " + "at the ceiling ends at length, the harness asks no more for the outputs " + "still missing. One missing its value gets failure source " + "budget_exhausted_at_ceiling; one that has its value but lacks a usable " + "explanation keeps the value, and the harness adds " + "budget_exhausted_at_ceiling (explanation) to the error. On 2026-11-21 a " + "second smoke ran the same two households at the 65,536-token start. Each " + "answered every output, values and explanations, on its first response " + "through the forced tool, with no response ending at length and no " + "repair: about 19,000 completion tokens for the 20-output household and " + "about 35,000 for the 16-output one, nearly all reasoning, an estimated " + "$0.29 and $0.53 at Google's list rates. Both used more tokens than the " + "households' answering responses in the first smoke; two households " + "cannot show whether the larger first budget or run-to-run variation " + "accounts for that. The card sets no expected cost per scenario. The " + "Models API gives the model an outputTokenLimit of 65,536 and lists " + "generateContent, the method the harness calls with one non-streaming " + "request, among its supported methods; the model page gives the same " + "65,536 as the default synchronous output. The gauntlet's probes, the raw " + "call at the default level and both smokes' responses ran at about 127 to " + "138 completion tokens a second, on responses of about 7,900 to 35,000 " + "tokens. No request in the record used the whole 65,536-token ceiling; " + "one that did would take about 475 to 516s at those rates, and would " + "outlast 600s at any rate below about 109 tokens a second. The card sets " + "a 600s timeout, as Hydrogen's does. The raw call at level low averaged " + "about 105 tokens a second, which predicts about 624s at the ceiling; " + "Hydrogen's 600s exceeds what the slowest rates in its record predict, " + "but this card sets that call aside, since the board does not send its " + "thinking level. Google's generateContent long-decode guide (read " + "2026-11-14 for the Carbon and Hydrogen cards, not re-read for Neon) says " + "the server closes a non-streaming call after 10 minutes. The same guide " + "recommends a 20-minute client read timeout, and its option table gives " + "20 minutes per request. Google lists $3/$15 per 1M." + ), + ), "openrouter/z-ai/glm-5.3": ModelCard( litellm_id="openrouter/z-ai/glm-5.3", answer_contract="tool", diff --git a/policybench/paper_results.py b/policybench/paper_results.py index 937dffb5..d8dc4add 100644 --- a/policybench/paper_results.py +++ b/policybench/paper_results.py @@ -3637,6 +3637,12 @@ def last_engine_upgrade(self) -> EngineUpgrade: # gemini-models/introducing-gemini-4-hydrogen (2026-11-12: "Starting # today" in the Gemini API and the Gemini app), both read 2026-11-13. "gemini-4-hydrogen": "2026-11-12", + # aistudio.google.com/docs/changelog ("November 18, 2026": Gemini 4 Neon, + # gemini-4-neon, generally available, on the paid tier) and blog.google/ + # innovation-and-ai/models-and-research/gemini-models/ + # introducing-gemini-4-neon (2026-11-18: "rolling out today in the Gemini + # API in Google AI Studio"), both read 2026-11-19. + "gemini-4-neon": "2026-11-18", # blog.google gemini-3-1-flash-lite; siliconangle.com 2026-03-03 "gemini-3.1-flash-lite-preview": "2026-03-03", # openai.com/index/introducing-gpt-5-4-mini-and-nano; 9to5mac 2026-03-17 diff --git a/tests/test_eval_no_tools.py b/tests/test_eval_no_tools.py index fe2b522f..681ae2eb 100644 --- a/tests/test_eval_no_tools.py +++ b/tests/test_eval_no_tools.py @@ -3373,6 +3373,45 @@ def test_gemini_4_hydrogen_override_reconstructs_token_costs( assert reconstructed.is_estimated is False +def test_gemini_4_neon_runs_first_party_at_googles_list_rate(): + """Gemini 4 Neon runs on the first-party Gemini API, like the other + Gemini rows, at the paid-tier rate on Google's pricing page: $3 / $15 per + 1M input/output tokens (output includes thinking tokens) and $0.15 + cached input, at every prompt length, with no introductory rate and no + dated change. The page lists no free tier for the model.""" + assert MODELS["gemini-4-neon"] == "gemini/gemini-4-neon" + assert PRICE_OVERRIDES_PER_1M["gemini-4-neon"] == { + "input": 3.0, + "output": 15.0, + "cache_read": 0.15, + } + + +@pytest.mark.parametrize( + ("prompt_tokens", "completion_tokens", "cached_prompt_tokens", "expected"), + [ + (1_000_000, 0, 0, 3.0), + (0, 1_000_000, 0, 15.0), + (1_000_000, 1_000_000, 0, 18.0), + (1_000_000, 0, 1_000_000, 0.15), + (1_000_000, 0, 250_000, 2.2875), + ], +) +def test_gemini_4_neon_override_reconstructs_token_costs( + prompt_tokens, completion_tokens, cached_prompt_tokens, expected +): + reconstructed = _reconstruct_token_cost( + model_name="gemini-4-neon", + model_id="gemini/gemini-4-neon", + prompt_tokens=prompt_tokens, + completion_tokens=completion_tokens, + cached_prompt_tokens=cached_prompt_tokens, + ) + + assert reconstructed.usd == pytest.approx(expected) + assert reconstructed.is_estimated is False + + # Google's listed per-1M rates (input, cached input, output; Carbon's are the # rates the page lists through 2026-11-30), written out here and not read from # PRICE_OVERRIDES_PER_1M, so the property below checks the override against @@ -3380,6 +3419,7 @@ def test_gemini_4_hydrogen_override_reconstructs_token_costs( GEMINI_4_LISTED_RATES_PER_1M = { "gemini-4-carbon": (2.0, 0.10, 10.0), "gemini-4-hydrogen": (1.5, 0.075, 7.5), + "gemini-4-neon": (3.0, 0.15, 15.0), } @@ -3389,7 +3429,7 @@ def test_gemini_4_hydrogen_override_reconstructs_token_costs( completion_tokens=st.integers(min_value=0, max_value=131_072), cached_share=st.floats(min_value=0.0, max_value=1.0), ) -def test_gemini_4_carbon_and_hydrogen_costs_are_linear_and_bounded_by_the_cache_rate( +def test_gemini_4_listed_rate_costs_are_linear_and_bounded_by_the_cache_rate( model, prompt_tokens, completion_tokens, cached_share ): """Invariants of each override's reconstruction: the cost is the sum of @@ -3818,6 +3858,300 @@ def test_gemini_4_hydrogen_request_forces_the_answer_tool_and_sets_no_reasoning( assert reasoning_key not in kwargs +def test_gemini_4_neon_request_forces_the_answer_tool_and_sets_no_reasoning( + mini_scenario, +): + """Gemini 4 Neon's card, written before the model's onboarding, takes + Gemini 4 Hydrogen's contract, the board's forced answer tool; Google's + model page lists function calling as supported, and in both + two-household smokes every household answered every output through it. + The request carries no reasoning parameter, so the model reasons at + Google's default, high per Google's thinking guide, as Hydrogen does. It + takes the card's 600s timeout, set by extrapolating measured rates to + 65,536 tokens, and the card's own starting budget, the 65,536-token + ceiling: in the first smoke, at the Gemini family's 16,384, one + household's first two requests ran out of budget with no usable output. + The first request, an answers-only repair request and + _initial_completion_budget_tokens, which the supervisor's and the resume + sidecar's fingerprints both call, all give 65,536, so a length finish + has no rung left.""" + from policybench.completion_budget import next_completion_budget + from policybench.eval_no_tools import ( + ANSWER_FUNCTION_NAME, + _answer_contract_for_model, + _chat_completion_request_kwargs, + _completion_budget_ceiling, + _initial_completion_budget_tokens, + ) + + model_id = "gemini/gemini-4-neon" + assert _answer_contract_for_model(model_id, env={}) == "tool" + assert _thinking_configuration(model_id) == {"mode": "provider_default"} + assert _request_timeout_seconds(model_id) == 600 + + _, kwargs = _chat_completion_request_kwargs(mini_scenario, ["income_tax"], model_id) + _, repair = _chat_completion_request_kwargs( + mini_scenario, + ["income_tax"], + model_id, + repair=True, + include_explanations=False, + ) + + assert kwargs["tool_choice"] == { + "type": "function", + "function": {"name": ANSWER_FUNCTION_NAME}, + } + assert [tool["function"]["name"] for tool in kwargs["tools"]] == [ + ANSWER_FUNCTION_NAME + ] + assert kwargs["max_completion_tokens"] == 65_536 + assert repair["max_completion_tokens"] == 65_536 + assert _initial_completion_budget_tokens(model_id, ["income_tax"]) == 65_536 + assert next_completion_budget(65_536, _completion_budget_ceiling(model_id)) is None + assert kwargs["timeout"] == 600 + assert "response_format" not in kwargs + for reasoning_key in ("reasoning", "reasoning_effort", "thinking"): + assert reasoning_key not in kwargs + + +# The gemini/ ids whose starting budget is the Gemini family's 16,384 tokens +# (GEMINI_JSON_MAX_COMPLETION_TOKENS): every gemini/ roster id and gemini/ +# card that sets no completion_token_cap, and one card-less gemini/ id. +GEMINI_FAMILY_STARTING_BUDGET_IDS = ( + "gemini/gemini-2.5-flash", + "gemini/gemini-3-flash-preview", + "gemini/gemini-3.1-flash-lite-preview", + "gemini/gemini-3.1-pro-preview", + "gemini/gemini-3.5-flash", + "gemini/gemini-3.5-flash-lite", + "gemini/gemini-3.6-flash", + "gemini/gemini-3.7-flash", + "gemini/gemini-3.8-flash", + "gemini/gemini-4-argon", + "gemini/gemini-4-carbon", + "gemini/gemini-4-hydrogen", +) +CARDLESS_GEMINI_ID = "gemini/gemini-2.5-flash" + + +def _gemini_card_ids() -> list[str]: + from policybench.model_cards import MODEL_CARDS + + return sorted( + model_id for model_id in MODEL_CARDS if model_id.startswith("gemini/") + ) + + +def test_every_gemini_id_has_a_pinned_starting_budget(): + """Every gemini/ roster id and gemini/ card is either pinned at the + family's 16,384-token starting budget below or sets its own budget with + completion_token_cap, so a new gemini/ row cannot skip both.""" + from policybench.model_cards import MODEL_CARDS, card_for + + gemini_ids = { + model_id for model_id in MODELS.values() if model_id.startswith("gemini/") + } | set(_gemini_card_ids()) + capped = { + model_id + for model_id in gemini_ids + if MODEL_CARDS.get(model_id) is not None + and MODEL_CARDS[model_id].completion_token_cap is not None + } + # Gemini 4 Neon starts at its 65,536-token ceiling (its own test above). + assert capped == {"gemini/gemini-4-neon"} + assert MODEL_CARDS["gemini/gemini-4-neon"].completion_token_cap == 65_536 + assert gemini_ids - capped == set(GEMINI_FAMILY_STARTING_BUDGET_IDS) - { + CARDLESS_GEMINI_ID + } + assert card_for(CARDLESS_GEMINI_ID) is None + + +@pytest.mark.parametrize("model_id", GEMINI_FAMILY_STARTING_BUDGET_IDS) +def test_gemini_ids_without_a_card_budget_keep_the_family_starting_budget( + model_id, +): + """A gemini/ card's completion_token_cap leaves every other gemini/ id + where it was: 16,384 tokens for 1, 3, 16 and 20 outputs, in the request + controls with and without explanations (the board's requests and + answers-only ones), and in the initial-budget helper with explanations. + The supervisor's and the resume sidecar's fingerprints both call that + helper, _initial_completion_budget_tokens.""" + from policybench.eval_no_tools import _initial_completion_budget_tokens + + for variable_count in (1, 3, 16, 20): + variables = [f"v{i}" for i in range(variable_count)] + for include_explanations in (True, False): + assert _completion_controls( + model_id, + include_explanations=include_explanations, + variables=variables, + ) == {"max_completion_tokens": 16_384} + assert _initial_completion_budget_tokens(model_id, variables) == 16_384 + + +@pytest.mark.parametrize( + ("cap", "ceiling", "expected"), + [ + # Above the family's 16,384 and below the ceiling: the card's value. + (24_576, 65_536, 24_576), + # At the ceiling: the first request is the last rung. + (65_536, 65_536, 65_536), + # Above the ceiling: clamped to it, as for every card. + (98_304, 65_536, 65_536), + ], +) +def test_a_gemini_card_completion_token_cap_is_its_starting_budget( + mini_scenario, monkeypatch, cap, ceiling, expected +): + """A gemini/ card's completion_token_cap sets the budget of its first + request and of its answers-only repair requests (base and cap both, as a + thinking-budget card's does on other providers), clamped to the card's + escalation ceiling.""" + from policybench.eval_no_tools import ( + _chat_completion_request_kwargs, + _initial_completion_budget_tokens, + ) + from policybench.model_cards import MODEL_CARDS, ModelCard + + model_id = "gemini/gemini-capped-test" + monkeypatch.setitem( + MODEL_CARDS, + model_id, + ModelCard( + litellm_id=model_id, + answer_contract="tool", + request_timeout_seconds=600, + thinking_budget=True, + completion_token_cap=cap, + provider_max_completion_tokens=ceiling, + ), + ) + + _, first = _chat_completion_request_kwargs(mini_scenario, ["income_tax"], model_id) + _, repair = _chat_completion_request_kwargs( + mini_scenario, + ["income_tax"], + model_id, + repair=True, + include_explanations=False, + ) + assert first["max_completion_tokens"] == expected + assert repair["max_completion_tokens"] == expected + for variable_count in (1, 3, 16, 20): + variables = [f"v{i}" for i in range(variable_count)] + for include_explanations in (True, False): + assert _completion_controls( + model_id, + include_explanations=include_explanations, + variables=variables, + ) == {"max_completion_tokens": expected} + assert _initial_completion_budget_tokens(model_id, variables) == expected + + +@pytest.mark.parametrize("model_id", _gemini_card_ids()) +def test_every_gemini_card_reads_its_completion_token_cap( + mini_scenario, monkeypatch, model_id +): + """Fails if the gemini/ branch ignores the card: each gemini/ card, given + a 24,576-token completion_token_cap (under every gemini/ ceiling), starts + its first and answers-only repair requests at 24,576, not 16,384.""" + import dataclasses + + from policybench.eval_no_tools import ( + _chat_completion_request_kwargs, + _completion_budget_ceiling, + ) + from policybench.model_cards import MODEL_CARDS + + monkeypatch.setitem( + MODEL_CARDS, + model_id, + dataclasses.replace(MODEL_CARDS[model_id], completion_token_cap=24_576), + ) + assert _completion_budget_ceiling(model_id) >= 24_576 + + _, first = _chat_completion_request_kwargs(mini_scenario, ["income_tax"], model_id) + _, repair = _chat_completion_request_kwargs( + mini_scenario, + ["income_tax"], + model_id, + repair=True, + include_explanations=False, + ) + assert first["max_completion_tokens"] == 24_576 + assert repair["max_completion_tokens"] == 24_576 + + +def test_a_gemini_card_completion_token_cap_reaches_the_probe_and_batch_requests( + mini_scenario, monkeypatch +): + """The onboarding gauntlet's probes and the Gemini batch body build their + budget from the same controls, so they start at the card's value too.""" + from policybench import onboard + from policybench.batch_eval import BatchUnit, GeminiBatchAdapter + from policybench.model_cards import MODEL_CARDS, ModelCard + + model_id = "gemini/gemini-capped-test" + monkeypatch.setitem( + MODEL_CARDS, + model_id, + ModelCard( + litellm_id=model_id, + answer_contract="tool", + thinking_budget=True, + completion_token_cap=65_536, + provider_max_completion_tokens=65_536, + ), + ) + + for contract in ("tool", "json"): + _, probe, _ = onboard._probe_request( + mini_scenario, ["income_tax"], model_id, contract + ) + assert probe["max_completion_tokens"] == 65_536 + body = GeminiBatchAdapter(client=MagicMock()).build_request_body( + mini_scenario, BatchUnit(mini_scenario.id, ["income_tax"], 0), model_id + ) + assert body["config"]["max_output_tokens"] == 65_536 + + +@patch("policybench.eval_no_tools.completion") +def test_a_gemini_card_starting_at_its_ceiling_never_escalates( + mock_completion, mini_scenario, monkeypatch +): + """A first request at the ceiling is the only rung: a length finish with + the outputs missing ends after one request, with no escalation and no + repair request, and those outputs are recorded as + budget_exhausted_at_ceiling.""" + from policybench.model_cards import MODEL_CARDS, ModelCard + + model_id = "gemini/gemini-capped-test" + monkeypatch.setitem( + MODEL_CARDS, + model_id, + ModelCard( + litellm_id=model_id, + answer_contract="tool", + request_timeout_seconds=600, + thinking_budget=True, + completion_token_cap=65_536, + provider_max_completion_tokens=65_536, + ), + ) + mock_completion.return_value = _chat_tool_response( + None, finish_reason="length", completion_tokens=65_536 + ) + + result = run_single_no_tools(mini_scenario, "income_tax", model_id) + + assert [ + call.kwargs["max_completion_tokens"] for call in mock_completion.call_args_list + ] == [65_536] + assert result["budget_escalation_count"] == 0 + assert result["failure_sources"] == {"income_tax": "budget_exhausted_at_ceiling"} + + def test_claude_haiku_5_5_reasons_by_default_but_not_under_the_forced_tool(): """Haiku 5.5 thinks when the request omits the thinking parameter, so it is a thinking-default Claude: provider-default thinking, the thinking diff --git a/tests/test_model_cards.py b/tests/test_model_cards.py index 417b8ebb..0960e7ae 100644 --- a/tests/test_model_cards.py +++ b/tests/test_model_cards.py @@ -83,6 +83,7 @@ "gemini/gemini-4-argon": ("tool", None, 300, 16_384), "gemini/gemini-4-carbon": ("json", None, 900, 16_384), "gemini/gemini-4-hydrogen": ("tool", None, 600, 16_384), + "gemini/gemini-4-neon": ("tool", None, 600, 65_536), } @@ -257,6 +258,7 @@ def test_provider_max_clamps_initial_completion_budget(monkeypatch): ("gemini/gemini-4-argon", 32_768), ("gemini/gemini-4-carbon", 32_768), ("gemini/gemini-4-hydrogen", 65_536), + ("gemini/gemini-4-neon", 65_536), ], ) def test_roster_model_provider_maximums_limit_escalation(model_id, expected): diff --git a/tests/test_paper_results.py b/tests/test_paper_results.py index c6480a80..99660c21 100644 --- a/tests/test_paper_results.py +++ b/tests/test_paper_results.py @@ -128,6 +128,13 @@ def test_gemini_4_hydrogen_release_date_is_recorded(): assert MODEL_RELEASE_DATES["gemini-4-hydrogen"] == "2026-11-12" +def test_gemini_4_neon_release_date_is_recorded(): + """The Gemini API changelog lists Gemini 4 Neon as generally available on + 2026-11-18, on the paid tier, and Google's launch post, dated the same + day, says the model is rolling out that day in the Gemini API.""" + assert MODEL_RELEASE_DATES["gemini-4-neon"] == "2026-11-18" + + def test_gpt_6_1_terra_release_date_is_its_announcement_day(): """OpenAI announced GPT-6.1 Terra on 2026-10-26 and opened it in ChatGPT (Plus, Pro, Business, Enterprise and Edu), Codex and the API (id