Repository navigation
Fixed
Background-job poll and cleanup tasks are now created on the event loop's own thread, not on the calling worker thread.
post_tool_call runs on a Hermes worker thread, so _schedule_background_job_poll and _schedule_background_job_cleanup called loop.create_task from outside the loop thread. The task landed in the loop's ready queue without waking the selector, so a poll could wait until some unrelated event woke the loop, and asyncio debug mode raised RuntimeError: Non-thread-safe operation invoked on an event loop other than the current one.
Both now go through schedule_task_on_loop (hermes_progress_tail/utils/scheduling.py): the task is created immediately when the caller already runs on the loop, and otherwise the creation is handed to loop.call_soon_threadsafe. The coroutine is built inside that callback, so a loop that closes before the callback runs leaves nothing unawaited. The poll_task dedupe check and claim moved into the loop-side callback, and _poll claims its own task once the job record exists — the started render and the callback race, and the record was often created only after the callback had looked for it.
Unchanged
The other create_task_or_close callers (delayed live flush, auto-delete, delegate cleanup, the clarify same-loop bridges) only run inside coroutines that are already on the loop, so they keep the direct call. clarify._on_loop is now the shared on_loop_thread.
Verification
Three new tests drive a real debug-mode event loop on its own thread and schedule the poll, the cleanup, and plugin._on_post_tool_call from a foreign thread. All three fail on v0.2.24 with the non-thread-safe RuntimeError, and the hook test fails when the poll_task claim block is removed. Full suite with the venv active: 0 failed, coverage above the 90% gate.