fix(cron): record no_agent runs as sessions so they show in run history - #53692
Closed
yingliang-zhang wants to merge 1 commit into
Closed
fix(cron): record no_agent runs as sessions so they show in run history#53692yingliang-zhang wants to merge 1 commit into
yingliang-zhang wants to merge 1 commit into
Conversation
no_agent cron jobs short-circuit run_job() before any SessionDB work,
so they never produce the cron_{job_id}_{timestamp} session row that the
run-history endpoint (GET /api/cron/jobs/{id}/runs, backed by
SessionDB.list_cron_job_runs) is built from. Manually triggering such a
job from the Desktop GUI gives zero feedback: no running indicator, no
run record, no output — the script runs fine, the GUI just can't see it.
Fix: in the no_agent branch of run_job(), create the run session
(cron_{job_id}_{ts}, source='cron') BEFORE executing the script so the
runs endpoint's is_active computation yields a running indicator for
in-flight manual triggers. After execution, persist the outcome doc as
an assistant message, title the session, and end_session. Covers all
four exit paths: success, script failure, empty-stdout silent run, and
wakeAgent=false silent run.
Best-effort: a missing/broken state store degrades to the old no-record
behaviour and never blocks the script run. The no_agent cost contract
is preserved — run_agent/AIAgent are still never imported on this path.
Supersedes NousResearch#44087 (same approach, rebased on current main).
Fixes NousResearch#44080, NousResearch#42433.
Collaborator
Duplicate of #44087 — same fix for #44080: both create the |
Contributor
Author
|
Closing as duplicate of #44087 (open since 2026-06-11, earlier canonical). Both create the |
This was referenced Aug 3, 2026
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.
Problem
no_agent: truecron jobs short-circuitrun_job()(cron/scheduler.py) before anySessionDBwork, so they never produce thecron_{job_id}_{timestamp}session row that the run-history endpoint (GET /api/cron/jobs/{id}/runs, backed bySessionDB.list_cron_job_runs) is built from. Manually triggering such a job from the Desktop GUI gives zero feedback: no running indicator, no run record, no output — the script runs fine, the GUI just can't see it.Reported in #44080 and #42433.
Fix
In the
no_agentbranch ofrun_job():cron_{job_id}_{ts},source='cron'— the exact shape the agent path produces) plus a short user message (no_agent script: <path>) that becomes the run's preview. Because the session is open while the script runs, the runs endpoint's existingis_activecomputation now yields a running indicator for in-flight manual triggers, with no frontend changes needed._run_job_script) as an assistant message, title the session using the same scheme as the agent path, andend_session(..., "cron_complete").This covers all four exit paths: success, script failure, empty-stdout silent run, and
wakeAgent=falsesilent run.Design notes
SessionDBuse).run_agent/AIAgentare still never imported on this path (existingtest_run_job_no_agent_never_invokes_aiagentstill passes); the only addition is a cheap sqlite session write./runsendpoint, andlist_cron_job_runsalready do the right thing once the session rows exist — the fix is purely making the no_agent path produce the records everything else already consumes.Tests
Added to
tests/cron/test_cron_no_agent.py:test_run_job_no_agent_success_records_run_session— success run appears inlist_cron_job_runswithsource='cron', ended state,cron_complete, and the script output persisted in the run's messagestest_run_job_no_agent_failure_records_run_session— failed run is recorded (not silent) withcron_failedend reasontest_run_job_no_agent_silent_records_run_session— silent run (empty stdout) still leaves a run recordtest_run_job_no_agent_broken_session_store_does_not_break_run— a broken SessionDB raising doesn't break the run itselfThe shared
hermes_envfixture now also reloadshermes_statesoDEFAULT_DB_PATH(bound at import time) points at the per-testHERMES_HOME— keeping the new tests hermetic.tests/cron/: 22 passed, 0 failures.Relationship to existing PR
Supersedes #44087 — same approach, rebased on current
main(1479 commits ahead of #44087's base) so it merges cleanly without conflicts.Fixes #44080.
Related: #42433, #41935.