Repository navigation
fix(cron): import run_agent before consuming worker handoff payload - #124886
Arno-MA-73 wants to merge 1 commit into
Conversation
Moving P1 — the gateway's own ack deadline reaps the payload this PR protects. The parent creates So the re-exec only works if the import returns inside those 30s. If it doesn't, the Running the real module on both revisions (asserting the resolved P2 — the new test's stub makes that cost unmeasurable.
Unverified: the 30s trigger is path inference, not a measurement. |
|
Fixed on main by de116d8 (#134358), salvaged from #133720 (thanks @mzyas, authorship kept). The external cron worker now runs Thanks @Arno-MA-73 for this alternative, and for the precise root-cause report. Closing in favour of #134358. If you still see #124827 on a build that includes de116d8, please comment and we'll reopen. |
What this changes
Fixes #124827: an external cron worker that re-execs or relaunches during
run_agentimport after its one-shot handoff payload was already deleted, so the execution is recovered asunknownwith no output or delivery.Move the
run_agentimport inside the worker's profile scope before the payload is consumed and before adoption/acknowledgement. That import runshermes_bootstrap(which canexecvinto another interpreter) and interrupted-update recovery (restore_interrupted_pull→relaunch_after_restore). Keeping the handoff file until both finish means a relaunched process still has its argv payload; only after the import completes does the worker adopt ownership and publish the ready acknowledgement. A worker that cannot load the agent now fails before acknowledgement, where the gateway records a realfailedrun instead of a silentunknown.Relationship to #122222 / #122936
#122222 is the separate pre-ack missing-dependency bug (the worker spawns via
sys.executableand never reaches any Hermes import); #122936 is the in-flight fix for that. This change is independent of it and does not include it — the two fix different phases of the worker lifecycle. On installs affected by both, both are needed; this PR only addresses the post-ack re-exec.Verification
tests/cron/test_restart_safe_worker.py: 31 passed onmainplus this change (direct pytest against this host's test venv; not a CI claim).os.execvsubprocess round trip proving the payload survives across the exec and is consumed only by the second process.unknown) to pre-ack (recordedfailed) when the agent cannot be loaded.Scope and compatibility
No
HERMES_DISABLE_LAZY_INSTALLSsuppression is applied, so tool-time lazy installs (including security scanners) are unaffected. The change touches only the external-worker adoption path; the gateway ticker and in-process cron path are unchanged.