Repository navigation
Conversation
…s transiently Fixes #797 Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Contributor
|
📁 PR Artifacts Notice This PR adds or changes temporary PR-specific documents under |
Contributor
|
Warning Your comment is too long (maximum is 65536 characters), so the coverage report was not added. See the job log for how to reduce it. |
This branch has not been deployed
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.
This PR was created by an AI agent (OpenHands) on behalf of @neubig.
Why
The watchdog checks runs that did not send their completion callback. In cloud mode,
CloudSandboxBackend.verify_runfirst mints a new per-user API key. Then it reads the sandbox's bash history.If the key mint failed once with a network error or a 5xx,
verify_runraisedAPIKeyError._verify_and_mark_runtreats any exception as terminal. So it marked the runFAILED("Timed out: verification failed: ...") withtransient: false, then cleaned up the sandbox. This happened even when the run's command had already exited with code 0.The other transient verification errors already leave the run
RUNNINGfor the next scan: the sandbox-API 429/5xx and the agent-server errors. Only the key mint was missing this behavior.Summary of the change
_verify_runwrapsbackend.verify_run. It turns a transient error into aVerificationResultwith outcomeTRANSIENT_ERROR, usingclassify_httpx_transient_error. A transient error here is a timeout, a transport error, or an HTTP 408, 429 or 5xx.APIKeyError, the code classifies the httpx error it was raised from (its__cause__). Thestatus_detailthen namesopenhands_api/create_api_key.TRANSIENT_ERRORbranch. The run staysRUNNING, gets a transientstatus_detailand keeps its sandbox. The next watchdog scan checks it again.APIKeyErrorthat no httpx error caused, such as a bad response bodyNotes:
TRANSIENT_ERRORbranch, in a separate change.Fixes #797
How to Test
uv sync --frozen uv run python -m pytest tests/test_watchdog.py -k 'TransientKeyMint or VerificationFailed or transient' -vResult on this branch:
7 passed.The new tests run the real
mark_stale_runs,_verify_and_mark_run,CloudSandboxBackend.verify_runandverify_run_statusagainst the PostgreSQL test fixture. These external boundaries are stubbed: the key mint (get_api_key_for_automation_run), the sandbox-API lookup, the agent-server bash read, and the sandbox delete call.test_one_failed_key_mint_does_not_fail_a_finished_run: the first mint raises anAPIKeyErrorcaused byhttpx.ConnectError, and the command exited with code 0. After the first scan, the run isRUNNINGwith a transienttransportstatus. After the second scan, it isCOMPLETED.test_permanent_key_mint_failure_still_fails_the_run: a 403 mint failure, or anAPIKeyErrorwith no httpx cause, still marks the runFAILEDwithtransient: false.I also ran
tests/test_watchdog.py,tests/test_backends.py,tests/test_verification_result.pyandtests/test_workspace_purge.py:151 passed, 7 skipped. Pre-commit (ruff, pycodestyle, pyright) is clean on the changed files.Video/Screenshots
Before: on
main, one failed key mint marks a runFAILED("Timed out: verification failed: Request failed: connection reset"), although its command exited with code 0.After: on this branch, the run stays
RUNNINGand completes on the next scan. The existing verification-failure tests still pass.