Repository navigation
Conversation
…n both sides, the selection survives a usage mismatch
…wire name, the run length checked first; drop unit tests the integration tests cover
… sides, the selection survives a usage mismatch The proxy marks a request it refuses for its request or cost limit with x-agent-eval-refusal and counts it per wire. The Python bridge counts responses carrying that header as refused attempts, reports them in tokenUsage, and adds a stopper that ends the GEPA engine run at the first refusal: GEPA otherwise treats a refused reflection as a proposal that did not happen and spends the rest of its evaluation budget on minibatches it cannot reflect on. The completion check compares the bridge's attempts with the proxy's admitted plus refused requests, and the refused counts with each other. The method writes the bridge output to external/selection-<attempt>.json before any check runs, and a usage-count disagreement now marks the cost incomplete with the reason instead of throwing away a finished search.
…nd counts as refused
tangletools
approved these changes
Nov 23, 2026
tangletools
left a comment
Contributor
There was a problem hiding this comment.
✅ Auto-approved PR — 2c1914bd
Blanket team auto-approval is intentional. This is not a code review.
No automated review runs on this PR. This approval rests on the rule above alone.
tangletools · auto-approval · reason: blanket_auto_approve · 2026-11-23T09:12:48Z
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A Casework GEPA
omnisearch failed on 2026-11-23 at 08:09Z withSelfImproveRunError: docket-reader-gepa-omni: GEPA reported 691 model attempts but the proxy received 300. It had run 4 h 14 min, and the method threw away its selection with the error.Cause, from the run's ledger, GEPA state and bridge log:
maxRequests: 300at 06:55:55Z. Only 11 of the 300 requests had succeeded.optimizer model request limit reached.nextReservationrefused these beforerequestAttemptswas incremented, so the proxy did not count them. The bridge's httpx hook counted all 391 of them. 300 + 391 = 691.gepaCoststhrew on the count mismatch. The bridge output was in the subprocess temp directory, which is removed on return, so the selection was lost with it. (The recovered pick was the seed, so in this run nothing better was lost.)Change
x-agent-eval-refusal: <reason>and counts the request asrefusedRequestson its wire. The bridge counts responses that carry the header asrefusedAttemptsand reports them intokenUsage. The completion check compares the bridge's attempts with the proxy's admitted plus refused requests, and compares the two refused counts. A request that never reached the proxy still shows up as a mismatch. The refusal now also returns the header on the Anthropic wire, and the provenance carries the OpenAI-wire counts asoptimizerModelRequests.ProxyBudgetStopper) to every proxied standardgeparun, in both config shapes. It stops the run at the first refusal, and later stages of a composed recipe stop at once. A caller-suppliedengineConfig.stop_callbacksis refused in both shapes. Before this change it was refused only alongsidestopAtScore.optimizewrites the bridge output toexternal/selection-<attempt>.jsonbefore it runs any check. The usage check (execution receipts, OpenAI-wire counts, Anthropic receipts) now returns its failures instead of throwing. Any failure marks the method costaccountingComplete: false, with reasonusage check failed: .... A run that declares a dollar budget then holds at the gate, and the pick is kept.Proof
All tests run the real Python bridge and official GEPA against a local model server.
maxRequests: 1and a reply that never scores push the run past the cap.a87b2605)cb393af1TS,2c1914bdPython)test_official_gepa_engine_stops_at_the_first_proxy_refusalassert 40 <= 4: the engine spent all 40 evaluationsends the GEPA run at the reflection request cap and counts refusals on both sidesGEPA reported 297 model attempts but the proxy received 1(the production failure shape)keeps the selection and reports a failed usage check when the attempt counts disagree(the runner adds one uncounted attempt)GEPA reported 298 model attempts but the proxy received 1accountingComplete: false,selection-<attempt>.jsonpresentReceipts:
beelink2-21abad4ed7caa107a4adce4a636acbdb, exit 1 after 880 s. Most of that time was the unfixed engine running on past the cap.beelink1-8a964405a7686291cf462f90cd5d028c, exit 0 in 106 s. It ranpnpm typecheck,pnpm lintand 10 optimizer test files (105 passed), including both official integration files on GEPA source.beelink1-ac02b313d926ff3b2c4918273cc5349c, exit 0 in 71 s. It ranruff check .and the wholeclients/pythonsuite. The skips are the published-GEPA,dspyandpnpm buildtests.beelink1-77065c85acb1c26a06856ad225c3e37b, exit 0 in 79 s. It ran the release compatibility set frompublish.yml, then the TypeScript official integration file against GEPA 0.1.4 (3 passed).2c1914bddiffers fromcb393af1by one Python test line.Before the fix, the 40-evaluation red run sent 297 requests, about 7.4 per iteration. Production sent about 7.8 per failed iteration.
Growth: +152 source lines (TypeScript and Python) and +202 test lines. That count already subtracts one unit test that was deleted (
test_gepa_proxy_counts_failed_attempt_before_success_separately); the official LM test covers the same counts against a real server. This keeps a finished search from being discarded by an accounting mismatch, and ends a search when it can no longer reflect instead of letting it run up to 75 minutes of evaluations. No concept is duplicated: the refusal count lives on the proxy's existing wire counts, and the stopper is GEPA's own stopper protocol.Not changed here, for the owner's decision:
tenacity, so the reflection client'snum_retriesraisesModuleNotFoundErrorinstead of retrying.Run ID: run_f0dcc5c9530cf0786dfa8ba93b8909b8
Session: 5642814c-05e6-4613-aff1-cdce74cc5dab