Repository navigation
Conversation
The prompt and plugin presets call conversation.run() without arguments, so the SDK default of 3600 seconds applies to every run. With a longer automation timeout the preset raises ConversationRunError after an hour and the run is reported as failed while the agent keeps working. The dispatcher now exports the run's resolved timeout as AUTOMATION_RUN_TIMEOUT, the same value that bounds the bash command. The presets pass it to conversation.run(timeout=...) minus the time already spent in the script and a 60 second safety margin, with a 30 second floor, so the wait ends before the command is killed and the workspace context can still send the failure callback with the conversation id. When the variable is unset or not a positive finite number, the presets keep calling conversation.run() unchanged, so tarballs run by an older dispatcher behave as before.
1d59874 to
33f32d3
Compare
The prompt and plugin presets carried identical copies of the run timeout helper and its constants, kept equal by an AST comparison test. The presets already bundle presets/finish_tool_hook.py into every generated tarball for the same reason, so the resolver now lives in presets/run_timeout.py and ships the same way. Both main.py files import it, and the tests exercise it directly instead of extracting source nodes. Tarballs stored before this change keep their own main.py, which does not import the new module, so they are unaffected.
all-hands-bot
left a comment
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
Scope: In-repo and correctly owned — dispatcher env injection and preset tarball packaging both live in OpenHands/automation. Proceeding with the technical review.
What I verified
- Head
e8be15558e0c460a86054f77326f809ef795cfd0matches; PR is open withtype: feat, no linked closing issues, and no prior reviews or comments. RemoteConversation.run(blocking=True, poll_interval=1.0, timeout=3600.0)is identical in the pinned SDK1.53.0and in1.36.1, and_wait_for_run_completionraisesConversationRunErroronce elapsed exceedstimeout. The sandbox SDK always matches the service's pinned version (fetched from/sdk-version), so thetimeoutkwarg is always present.AUTOMATION_RUN_TIMEOUTis exported as exactlyeffective_timeout, the same value passed toexecute_in_context(timeout=...)and used for the bash command and watchdog deadline. It is serialized through the existing env-file path, so presetmain.pyreads it the same way as the otherAUTOMATION_*variables.- The new
presets/run_timeout.pyis stdlib-only and is bundled next tomain.pyin both prompt and plugin tarballs (including the variant path, which reuses_generate_plugin_tarball)._replace_prompt_in_tarballleaves the baked-inmain.pyuntouched, so stored automations are unaffected exactly as described. - On timeout the
ConversationRunErrorpropagates out of the workspace context, so__exit__sends the failure completion callback — the intended path. - Ran locally:
tests/test_preset_router.py(128 passed, 45 skipped; 19/19 inTestPresetRunTimeout),tests/test_backends.py+tests/test_execution.py(79 passed). Changed files compile.tests/test_dispatcher.pyrequires Docker (unavailable here) and its new timeout assertions depend on the PostgreSQL fixture. On GitHub theci/Run tests/Dockerruns for this head areaction_required(a fork PR awaiting approval), so CI has not yet validated this head.
Non-blocking observation
The safety margin is computed as AUTOMATION_RUN_TIMEOUT - (time since main.py start) - 60, but the bash command timeout starts before tarball extraction and setup.sh (a fresh-venv uv pip install of the SDK), which are not subtracted. When setup takes longer than the 60 s margin on a long run, the bash kill can still fire first and the run falls back to the watchdog path. This is acknowledged in the PR and is no worse than current behavior, so it does not block, but it bounds how often the new path actually delivers the completion callback.
No material correctness, security, compatibility, or acceptance-criterion defect found, and the change is in scope for this repository.
✅ APPROVED
Why
The prompt and plugin presets call
conversation.run()with no arguments, so every preset run is capped by the SDK default wait of 3600 seconds, whatever the automation's owntimeoutis.RemoteConversation.run(blocking=True, poll_interval=1.0, timeout=3600.0)raisesConversationRunError("Run timed out after 3600.0 seconds...")once the wait exceedstimeout. The default is the same in the pinned SDK (1.53.0) and in 1.36.1.dispatcher.py#L283) and uses it for the bash command timeout and the watchdog deadline, but the script running inside that command never learns it.With
AUTOMATION_MAX_RUN_DURATION=10800and an automationtimeoutof 10800, the preset raises after about one hour. The run is reported as failed while the agent keeps working, because the presets create the conversation withdelete_on_close=False.What changed
dispatcher.py#L353: export the resolved timeout to the run environment asAUTOMATION_RUN_TIMEOUT, in seconds, the same value as the bash command timeout. It is documented in the run env var table inAGENTS.md.presets/run_timeout.py: a stdlib-only resolver shared by both presets, bundled next tomain.pyin the prompt and plugin tarballs, the same waypresets/finish_tool_hook.pyalready is.presets/prompt/sdk_main.py#L547andpresets/plugin/sdk_main.py#L597: pass the resolved value toconversation.run(timeout=...).The wait has to end before the bash command timeout kills the process. Otherwise the workspace context never reaches
__exit__, and the failure completion callback is never sent. The bash timeout starts with the command, andmain.pyonly starts after the tarball extraction andsetup.sh, so the preset does not pass the raw value:SCRIPT_STARTED_AT = time.monotonic()is taken right after the stdlib imports, before the SDK imports, workspace setup and conversation creation, so all of that time is subtracted.conversation.close(). It also has to absorb thesetup.shtime, which runs beforemain.pyand cannot be measured from it.Before and after
timeout10800, run takes 2 hFAILED, agent keeps workingtimeoutAUTOMATION_RUN_TIMEOUTunset or invalidconversation.run(), identical to todayCompatibility and risk
AUTOMATION_RUN_TIMEOUTis unset or is not a positive finite number (empty,abc,nan,inf,0, negative), the presets callconversation.run()exactly as before.main.pybaked into their tarball (_replace_prompt_in_tarballcopies every member exceptprompt.txtunchanged), so they only pick up the new behaviour once their tarball is regenerated. New automations get it immediately. An oldmain.pydoes not importrun_timeout, so it is unaffected by the new file.setup.shtakes longer than the margin allows, the bash kill still happens first and the run falls back to today's watchdog path.Tests
tests/test_dispatcher.py:AUTOMATION_RUN_TIMEOUTequals the automation timeout (and thetimeoutpassed toexecute_in_context), and falls back todefault_run_duration. Both tests fail without the dispatcher change (KeyError: 'AUTOMATION_RUN_TIMEOUT').tests/test_preset_router.py: the shared resolver covers the budget arithmetic, the wait ending before the command would be killed, the floor, and unset or invalid values. Further tests check that the resolver needs only the standard library, that both presets import it instead of redefining it, that both tarballs shiprun_timeout.py, theconversation.run(timeout=...)wiring, and that the clock starts before the SDK imports.Verification
DOCKER_HOSTpointed at the colima socket.tests/test_preset_router.pycases probe/var/run/docker.sockdirectly, so they are skipped here. CI runs them.Jev-Fast-Audit
⚡ Jev fast audit · estimates · 0.37s · commit e8be155⚠️ reduced context — partial coverage; 28/28 hunks, 8/8 files (context budget: 23).
Strongest signal: No primary concern selected.
Evidence: No primary concern to locate.
Coverage:
All estimates and evidence