Persist A Morning Report - alexherrero/agentm GitHub Wiki
Note
Status: implemented โ shipped by PLAN-observability-residue-trio.md#task-2 (agentm _harness/).
Goal: Write an overnight run's morning report to a file on disk instead of only printing it to stdout, so it can be re-derived or archived after the terminal session that produced it is gone.
Prereqs: A populated observability rollup (aggregator.default_db_path() or a --db-path you pass explicitly) with at least one event for the plan you're reporting on. See CI gates ยง The nightly health tier for the sibling scripts/health/ CLI family this script belongs to.
scripts/health/morning_report.py renders why an overnight run ended โ plan finished, gates green, an escalation parked, or the window ran out โ with the plan's spend attached (wiki/designs/agentm-autonomy.md ยง When the window runs out). The --out flag adds a second, on-disk copy of the same markdown without changing stdout behavior.
- Run
morning_report.pywith--plan,--ending-cause, and--db-pathas before, adding--out <path>to also write the rendered markdown to<path>:scripts/health/morning_report.py:110declares the flag (--out, defaultNone, "also write the rendered report to this path (stdout output is unchanged either way)"). - Stdout is unchanged whether or not
--outis passed:morning_report.py:127-128renders the page once (page = render_morning_report(data)) and always prints it (print(page, end="")) before the--outbranch runs. - When
--outis given,morning_report.py:129-132buildsPath(args.out), creates any missing parent directories (out_path.parent.mkdir(parents=True, exist_ok=True)), then writes the samepagestring to it (out_path.write_text(page, encoding="utf-8")) โ so a nested path likereports/morning.mdworks even ifreports/doesn't exist yet. - The trailing
{"total_cost_usd": 0.0}JSON line still prints to stdout after, unaffected by--out(morning_report.py:133). - Read back the persisted file to confirm it matches what was printed โ the file content and the stdout content are byte-identical copies of the same
pagestring.
-
test_main_with_out_writes_the_same_content_stdout_gets(scripts/health/test_morning_report.py:165-179) passes--out <tmp>/reports/morning.mdโ a nested, not-yet-existing directory, proving themkdir(parents=True)behavior โ and asserts the written file's content equalsrender_morning_report(...)'s output and that the same content also appears in stdout. -
test_main_without_out_writes_no_file_and_stdout_is_unchanged(scripts/health/test_morning_report.py:154-163) asserts that omitting--outproduces zero.mdfiles in the tmp dir and that stdout equals the exact pre-existing byte-identical format (expected + '{"total_cost_usd": 0.0}\n').
-
Health scorecard โ the sibling
scripts/health/surface, explains where the scorecard lives and how it's produced. - Read the morning note and the nightly scorecard โ the morning note, the nightly memory report, which is a different page from this overnight-run report.
- CI gates ยง The nightly health tier โ the reference page for the tier this script's data comes from.
-
wiki/designs/agentm-autonomy.mdยง When the window runs out โ the design line this flag closes out ("The morning report names why the run ended... with the spend attached").