fix(cron): record no_agent runs as sessions so they show in run history - #62587
fix(cron): record no_agent runs as sessions so they show in run history#62587yingliang-zhang wants to merge 1 commit into
Conversation
teknium1
left a comment
There was a problem hiding this comment.
Thanks for tracing the missing session-backed history path. The gap is real: current main's no_agent branch returns before the SessionDB import at cron/scheduler.py:2514-2623, while /api/cron/jobs/{id}/runs reads cron session rows in hermes_cli/web_server.py:10188-10230.
Problems
- The new
SessionDB()initialization in this branch reverses commit2008f5421, which deliberately moved SessionDB below theno_agentreturn path so pure script ticks do not pay the DB-open/agent-machinery cost. This is a design-contract conflict, not just bookkeeping. - The added tests cover terminal records, but not the claimed in-flight indicator. They should observe the run-history endpoint while a script is still blocked.
Suggested changes
- Preserve the no-agent no-SessionDB contract, or obtain an explicit decision to change it before wiring state.db here.
- If session-backed history is retained, add a blocked-script lifecycle test that verifies an unfinished active row before completion.
Automated hermes-sweeper review.
|
This PR overlaps with two other open PRs for the same defect (desktop run history shows "No runs yet" for
One behavioral note on this diff: Closed precursors for context: #44087 (2026-06-11, earliest write-side implementation, closed "superseded/conflicting" in a cleanup sweep), #53692 (closed as duplicate of #44087), #66954 (closed without verdict). Resolution options: consolidate on one write-side PR covering all outcomes, take the read-side fallback (which also surfaces pre-existing output docs retroactively), or deliberately layer both. Flagging so the three authors and maintainers can decide once rather than three PRs iterating independently. Filed by an AI agent (Claude Fable 5) operating autonomously on @jeff-mettel's behalf. PR diffs read programmatically and code references verified against |
|
Thanks for the thorough triage, @jeff-mettel — the overlap table is accurate and the behavioral note is a fair characterization. On the failure/silent-branch gap: The omission is deliberate, and the PR documents the tradeoff in the updated comment block: silent and failed ticks retain the zero- That said, the point about a persistently failing script still showing "No runs yet" is well-taken — that's the state where run history matters most. I'm open to extending On consolidation: I'd lean toward keeping this PR as the minimal write-side fix (success-only, post-completion) and layering failure-branch coverage as either an expansion here or in #62247, rather than consolidating both write-side PRs into one — the recording strategies differ enough (post-completion vs. pre-script |
0d595ee to
5805ef1
Compare
f7eedbe to
c706e9c
Compare
47862b2 to
441dccd
Compare
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.
1286f49 to
21c7de0
Compare
Problem
no_agent: truecron jobs (script-only watchdogs) create zero feedback when manually triggered from the Desktop GUI — no running indicator, no run record in Run History. The script executes and output files are written, but without a session row instate.dbthe GUI has nothing to display.Root Cause
In
cron/scheduler.py, theno_agentbranch short-circuits beforeSessionDBis ever touched. Nocreate_session()orappend_message()call means the run is invisible to the Desktop's session-based Run History.Fix
Create a
cron_{job_id}_{timestamp}session row in theno_agentbranch, mirroring what the agent path does:SessionDB.create_session(session_id, source="cron")— creates the rowSessionDB.append_message(session_id, "user", "no_agent script: {path}")— seeds the previewSessionDB.append_message(session_id, "assistant", run_doc)— records the output on completionThis is the same pattern already used by the agent path. The
no_agentcost contract (no LLM tokens) is preserved — this only adds DB bookkeeping.History
This is the third submission of the same fix:
origin/main, all tests passThe fix has been confirmed effective by 3 independent users: AIalliAI, rebootcrab-blip, and yingliang-zhang.
Test
test_cron_no_agent.py(114) andtest_scheduler.py(123), 0 failedno_agentruns