Skip to content

feat(verifiers): a judge call cut off by a time limit or a cancel marks its step's usage a lower bound - #880

Merged
earakely-scale merged 4 commits into
mainfrom
edgararakelyan/judge-cut-off-partial
Nov 23, 2026
Merged

earakely-scale merged 4 commits into
mainfrom
edgararakelyan/judge-cut-off-partial

Conversation

@earakely-scale

@earakely-scale earakely-scale commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

What changes

A judge call that gets cut off now marks its step's judge usage entry a lower bound, as #868 does for a prompt step's cut-off turn. Before this, a cut-off call was simply missing from the entry, with no mark. Its calls may still be billed, but their usage never came back. The chaos run on #877 hit it once in 106 runs.

  • An agent judge's turn cut off while its message is sent or while it waits for the reply counts as a call of unknown usage. That covers a time limit, a cancel (a sibling batch failed, or the run was cancelled) and a judge that stopped answering. A cancel during the send can't cancel the judge's task, since its id hasn't come back yet. A connection error on the send isn't counted, as fix(usage): count the rating step's user sim calls, and mark a turn cut off before its reply #868 decided for prompt steps.
  • A direct judge's call stopped by a cancel, or one whose every attempt ran out of time (a LiteLLM Timeout caused the failure), counts the same way.
  • A call the endpoint refused (a 500, a rate limit) still costs nothing and isn't counted.
  • StepUsage.cut_off_call(role, model=, endpoint_host=, reported_by=) records one such call. It starts the role when it's the role's first call, which cut_off doesn't do.
  • model_call.cut_off(exc) says which errors are cut-offs: a cancel, a LiteLLM Timeout, or a failure after retries that a Timeout caused.

An entry with a cut-off call is partial. When it's the role's only call, the entry has no counts and is unpriced (no_tokens), the same as #868's cut-off turns.

Decisions to review

  • Best effort, kept simple.
    • A cancel that lands before a direct judge's request went out also marks the entry, for example while the user-sim judge waits for the run's first call. That over-marks: the entry reads as a lower bound when it's exact.
    • Two attempts that timed out, followed by a third that was refused, aren't marked. Only the last failure's cause is read.
  • A timed-out attempt followed by one that answered isn't marked. Counting it would mean carrying a count out of _prompt_llm_judge. It can happen only after all three of the client's own tries time out and then the judge's next attempt answers, which no live run hit, so it was left out to keep this simpler.
  • A timeout LiteLLM's client recovers from on its own isn't seen. The OpenAI SDK under LiteLLM retries a timed-out request itself (max_retries, 2 by default), so one judge attempt can be up to 3 HTTP requests. When a retry answers, the judge never sees the timeout. The timed-out request may still be billed, as the live run below shows, and the entry isn't marked. When all of the client's retries time out, the judge sees the Timeout and marks the entry. Passing max_retries=0 would make every timeout visible, but it would also drop the SDK's backoff on 429s and 5xxs, so I left it alone. With the direct judge's default 1000 s limit, a timeout is rare anyway.
  • The endpoint host of a cut-off direct call is unknown. The route is resolved inside _prompt_llm_judge. When the step's first judge call is cut off, model_endpoints.judge.<step>.endpoint_host is null. Agent judges know their host.

Tests

  • test_rubrics_verifier_judge_usage.py:
    • an agent judge turn that runs out of time is a call of unknown usage;
    • a cancelled agent judge turn is too;
    • an agent judge cancelled while its message is sent is too;
    • a direct judge that timed out on every attempt leaves a call of unknown usage;
    • a cancelled direct judge call is a call of unknown usage;
    • a judge refused on every attempt records nothing.
  • usage_test.py: a judge's call cut off before any answered starts its role as a lower bound.
  • test_model_call.py: a call is cut off by a cancel or a timeout, even one a retry gave up on, and not by a refusal.

All of these but the refusal test fail on main.

E2E against the real proxy

On an admin host, through a logging pass-through in front of the real proxy, each run's ledger was compared with the proxy's own count of every call, role by role. The pass-through can stall a model's calls past the judge's time limit, so a timeout happens on demand. A stalled call is still forwarded, so it's billed after the judge gave up, as a real one would be. Solver: the plain pydantic-ai agent on gpt-4.1-mini.

Run What cut the judge off Ledger judge entry On main
agent judge, 5 s limit, one retry our poll's time limit, twice 2 turns, no counts, partial no entry
agent judge, SIGINT at 22 s or 30 s a cancel during its turn 1 turn, partial no entry
direct judge, 5 s limit, every gpt-4o-mini call stalled 30 s a Timeout on every attempt 1 turn, no counts, partial no entry
direct judge, one call stalled LiteLLM's client retried it itself 1 turn, exact counts of the answer, not marked same
normal runs (direct, batched, agent, simjudge) none exact exact
  • An agent judge whose own time limit fires first (we pass it the judge's) replies "failed" without usage. Claude Code does that: its entry is a turn with no counts, unpriced, which the ledger counts in unpriced_entries. That's the agent's report, not a cut-off on our side.
  • The fourth row is the limit under "Decisions to review": the OpenAI SDK under LiteLLM retried the timed-out request on its own, so the judge never saw it. The stalled request was answered upstream 30 s later.

Chaos, 20 minutes on two workers. 75 runs of the #877 chaos mix: faults at 20% or 35% on each model, interrupts during the solver's and the judge's turns, plus these cut-off scenarios every sixth run.

  • The ledger's own checks hold on all 75.
  • 62 judge entries are exact, and every cut-off judge is marked: 6 with no counts and 1 a lower bound. 3 entries were cut off before the judge made a call, so they're marked when the count was exact.
  • Six rows read short by one Claude Code call of about 34,500 tokens. Each such call came before the run's own solver had called the model, so it can't be that run's judge. It was the previous run's cut-off judge still working, landing in the next run's slice of the log.
  • Correction (after merge): those were model calls already in flight when the judge's task was cancelled. poll_a2a_task cancels the task on a timeout itself, since fix(a2a): give up on an agent whose sandbox died, and cancel a prompt that timed out #82. The proxy still answers and bills an in-flight call, and nothing on our side can stop it.

Model spend for these checks: about $1.02 at list prices.

Docs

For FD-6263 and FD-6442: replace "a judge call cut off by a time limit or a cancel isn't counted and isn't marked partial" with "it counts as a call of unknown usage, marking the entry partial, as a prompt step's cut-off turn does."

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge with the limits stated in its description.

Summary

Marks interrupted judge calls as usage lower bounds through StepUsage.cut_off_call.

  • Agent judge cutoffs now appear as partial usage calls.
  • Direct judge cancellations and timeouts now appear as partial usage calls.

No new actionable issues were found.

Reviews (8) · Last reviewed commit: "refactor(verifiers): drop the count of a..." · Reviewed by Greptile

earakely-scale and others added 2 commits November 22, 2026 21:33
…ks its step's usage a lower bound

As #868 marks a prompt step's cut-off turn: its calls may be billed but their usage never came back, so the judge
entry counts it as a call of unknown usage (partial) rather than leaving it out. An agent judge's turn cut off waiting
for the reply (a time limit, a cancel, a judge that stopped answering); a direct judge's call stopped by a cancel or a
LiteLLM Timeout, an attempt that timed out before a retry answered included. StepUsage.cut_off_call records one,
starting the role when it's the first call; model_call.cut_off says which errors are cut-offs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ied on its own isn't seen

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@earakely-scale
earakely-scale marked this pull request as ready for review November 23, 2026 06:03
@earakely-scale
earakely-scale requested a review from a team as a code owner November 23, 2026 06:03
earakely-scale and others added 2 commits November 22, 2026 22:07
…ts as a call of unknown usage

As send_and_wait's cut-off does for a prompt step: the judge may have taken the message before its task id came back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…empts before an answer

It needed a new key out of _prompt_llm_judge for a case no live run reaches: all three of the client's own tries timing
out, then the judge's next attempt answering. A cancel and a call whose every attempt timed out are still marked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@earakely-scale
earakely-scale merged commit 22db944 into main Nov 23, 2026
36 checks passed
@earakely-scale
earakely-scale deleted the edgararakelyan/judge-cut-off-partial branch November 23, 2026 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant