Repository navigation
fix(eval): report trace exit when a local rollout is cancelled - #716
Closed
Monarch-25 wants to merge 1 commit into
Closed
Monarch-25 wants to merge 1 commit into
Monarch-25 wants to merge 1 commit into
Conversation
The CancelledError handler in rollout() tore down the client and re-raised without calling trace_exit(), leaving every entered trace open on the platform. Set the cancelled status (synthesizing a run when cancelled before launch), bind the trace id, and report the exit under a short timeout before propagating the cancellation. Fixes hud-evals#709.
Author
|
Can someone mention if there is some channel to contact maintainers for PR? Couldn't find in the guidelines |
Collaborator
|
Superseded or resolved by #700. |
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.
Fixes #709.
Problem
When a local rollout (
LocalRuntime,SubprocessRuntime,DockerRuntime,Runtime(url), ...) is cancelled, theexcept asyncio.CancelledErrorhandler inhud/eval/run.pytore down the client and re-raised without callingtrace_exit(run).POST /trace/{id}/enterwas already sent when the rollout started, so the platform never heard that the trace ended.Fix
In the cancellation path, before re-raising:
cancelled(errorwhen the stop reason istimeout, mirroringRun.__aexit__), synthesizing a cancelledRunwhen the rollout was cancelled before it went live;run.trace.trace_id(the normal path only binds receipt fields below the handlers, andtrace_exitskips runs without an id);client.cancel()bound) so Ctrl-C stays responsive.Tests
test_cancelled_rollout_reports_trace_exit_as_cancelled: cancel mid-run, assert one enter yields one exit with matching id andcancelledstatus.test_cancelled_rollout_before_launch_still_reports_trace_exit: cancel during provisioning, assert the exit is still reported.test_rollout.py + test_job.py: 59 passed.ruff format --check/ruff check: clean.ty check: no new diagnostics. Full suite: only the 11 pre-existingtest_docker_provider.pyfailures, identical on main.Note
Medium Risk
Changes eval rollout teardown and platform trace lifecycle on cancellation; bounded
trace_exitlimits hang risk but mis-reporting could affect trace state in production.Overview
Fixes orphaned traces when a local rollout is cancelled (e.g. Ctrl-C): after
trace_enter, cancellation used to tear down the client and re-raise without notifying the platform that the trace ended.The
asyncio.CancelledErrorpath inrolloutnow marks the tracecancelled(orerrorwhenstop_reasonistimeout, matchingRun.__aexit__), synthesizes aRunif cancel happens before the run is live, bindstrace.trace_id, and callstrace_exitunder a 2s shielded timeout before the existing cancel/abort cleanup.New tests cover cancel mid-agent-loop and cancel during provisioning; both assert one enter pairs with one exit and
cancelledstatus.Reviewed by Cursor Bugbot for commit 4255ca7. Bugbot is set up for automated code reviews on this repo. Configure here.