test: spend enough Gemini tokens to exhaust account credit

eb479349f492 · AtlantisPleb · · parent a2d363f87477

test: spend enough Gemini tokens to exhaust account credit

Floor-dividing the allowance by Gemini 3.7 Flash's declared promo output
rate left 2 microUSD, so the thread-open refusal never fired. Ceil the
token count so the metered spend covers the grant.

Deploy story

What this commit did to the running system — joined from the forge receipt chain, the part a commit page elsewhere cannot show.

pushed
by user · WAL seq 476 · 2026-08-28T06:32:40.593469Z
built
5 modules in 151.6 s
deployed
live · 5 modules on 3 nodes · push→live —
deployed
needs_rolling_replace · 5 modules on 0 nodes · push→live —

Changed files

  • modified test/openagents_web/controllers/thread_controller_test.exs

Diff

1 file changed, +4 -1

test/openagents_web/controllers/thread_controller_test.exs modified +4 -1

@@ -304,7 +304,10 @@ defmodule OpenAgentsWeb.ThreadControllerTest do

304 304
305 305
      {:ok, _metered} =
306 306
        Inference.record_usage(grant, %{
307
          "output_tokens" => div(allowance * 1_000_000, rate)
307
          # Ceil the token count so a rate that does not divide the allowance
308
          # still spends it all. Floor division left 2 microUSD on Gemini's
309
          # declared promo rate and the next open was not refused.
310
          "output_tokens" => div(allowance * 1_000_000 + rate - 1, rate)
308 311
        })
309 312
310 313
      assert Credit.remaining(grant.owner_visitor_id) == 0

This page updates live while a promote is in flight · changelog