Skip to content

feat(cron): write execution summary to agent memory after job completion - #4696

Closed
kagura-agent wants to merge 0 commit into
NousResearch:mainfrom
kagura-agent:feat/cron-memory-writeback
Closed

feat(cron): write execution summary to agent memory after job completion#4696
kagura-agent wants to merge 0 commit into
NousResearch:mainfrom
kagura-agent:feat/cron-memory-writeback

Conversation

@kagura-agent

Copy link
Copy Markdown
Contributor

Problem

When cron jobs run, they execute in isolation. The main conversational agent has no knowledge of what cron jobs did. Users ask "did you send me a briefing?" and the agent says "no" even though it did.

Solution

After a cron job completes successfully, write a lightweight record to the agent's MEMORY.md via the existing MemoryStore mechanism.

Entry format

[Cron] daily-briefing ran at 2026-04-03 09:00 — Weather is sunny, 22°C. Top news: ...
  • [Cron] prefix helps the agent distinguish cron records from its own notes
  • Summary truncated to 150 chars to stay within memory budget
  • Respects the existing § delimited entry format (handled by MemoryStore.add())

Opt-out configuration

Two levels of opt-out, both defaulting to enabled:

  1. Per-job: set memory_writeback: false in the job definition
  2. Global: set cron.memory_writeback: false in config.yaml

Safety

  • Only writes for successful jobs (failures are already logged to output files)
  • Memory write errors are caught and logged at debug level — never crashes the tick loop
  • If memory is full (MemoryStore.add() returns an error), it's silently ignored

Changes

File What
cron/scheduler.py Added _write_memory_summary() function; called in tick() after save_job_output
cron/jobs.py Added memory_writeback parameter to create_job()
tests/cron/test_scheduler.py 9 new tests for memory writeback behavior
tests/cron/test_jobs.py 3 new tests for memory_writeback field persistence

Tests

All 99 cron tests pass:

pytest tests/cron/ -q
99 passed, 4 skipped in 3.62s

Closes #2704

@kagura-agent

Copy link
Copy Markdown
Contributor Author

CI Note

The 5 test failures are pre-existing and unrelated to this PR:

Failed Test Reason Related to this PR?
test_parallel_mixed_approve_deny Gateway approval logic ❌ No
test_gateway_run_agent_codex_path_handles_internal_401_refresh Codex execution path ❌ No
test_content_under_limit_passes Timeout (30s) ❌ No
test_oversized_read_rejected Timeout (30s) ❌ No
test_custom_config_raises_limit Timeout (30s) ❌ No

Verification: The same test job also fails on the most recently merged PR (#4660) with the same pattern. Our changes only touch cron/ files — all 99 cron-related tests pass locally and in CI.

@kagura-agent

Copy link
Copy Markdown
Contributor Author

Gentle ping — any feedback on this? Happy to adjust the approach. 🙏

@kagura-agent
kagura-agent force-pushed the feat/cron-memory-writeback branch from b6e7cc9 to 3e99964 Compare April 13, 2026 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: cron job execution results should be written back to conversational memory

1 participant