Skip to content

fix(evaluator): give evaluations a free worker after a timeout - #611

Open
tushar-mahalya wants to merge 1 commit into
algorithmicsuperintelligence:mainfrom
tushar-mahalya:fix-evaluator-timeout-executor-starvation
Open

tushar-mahalya wants to merge 1 commit into
algorithmicsuperintelligence:mainfrom
tushar-mahalya:fix-evaluator-timeout-executor-starvation

Conversation

@tushar-mahalya

Copy link
Copy Markdown

Fixes #610

When an evaluation times out, asyncio.wait_for stops waiting but the call keeps running in its executor thread. With the default parallel_evaluations=1, that thread is the only worker, so every later evaluation queues behind it and times out without starting. One program with an infinite loop turns all the valid programs after it into timeouts for the rest of the run.

This adds Evaluator._run_with_timeout, which swaps in a fresh executor when a call times out. The stuck executor is shut down with wait=False, so it still doesn't block asyncio.run() cleanup, which was the point of #485. The four copies of the run_in_executor + wait_for code (direct evaluation and cascade stages 1 to 3) now all go through this helper. Timeout handling and the returned results are unchanged.

I added two tests, one for direct evaluation and one for the cascade. Each evaluates a hanging program and then a valid one, and checks that the second isn't reported as a timeout. Both fail on main and pass with this change. The full suite passes (1140 tests, 7 skipped).

I also checked it end to end with a fake OpenAI server. Before the change, iterations 2 to 5 (all valid code) reported timeouts. With it, only the hanging program and its child do, and the best score improves as expected.

Things to be aware of:

  • The hung thread itself still leaks, since Python can't kill it, so an infinite loop keeps using a core until the process exits. That's the same as before. Properly fixing it would need a subprocess per evaluation, which I left out of scope.
  • With parallel_evaluations > 1, evaluations already running when the executor is swapped still finish on the old one. Only new submissions use the new executor.
  • If you'd prefer a smaller diff, the swap could go into the four existing except asyncio.TimeoutError branches instead of a shared helper.

Found and fixed with help from Claude Code; I reproduced and tested it myself.

A timed-out evaluation keeps running in its executor thread. With the
default parallel_evaluations=1 that thread is the only one, so every later
evaluation queued behind it and timed out without starting, even for valid
programs. Replace the executor when a call times out.
@CLAassistant

CLAassistant commented Nov 23, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

After one evaluation times out, every later evaluation times out too (parallel_evaluations=1)

2 participants