Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cron/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ def run_job(job: dict) -> tuple[bool, str, str, Optional[str]]:
disabled_toolsets=["cronjob", "messaging", "clarify"],
quiet_mode=True,
skip_context_files=True, # Don't inject SOUL.md/AGENTS.md from scheduler cwd
skip_memory=True, # Cron system prompts would corrupt user representations
skip_memory=_cfg.get("cron", {}).get("skip_memory", True), # Configurable; default True for backward compat

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skip_memory is also the built-in MEMORY.md/USER.md gate: agent/agent_init.py:1333-1345 initializes that store and 1353-1417 initializes providers under the same condition. Setting this false therefore enables local-memory reads and writes as well as provider tools, rather than preserving the cron isolation described by the replaced comment. Please separate the provider-only behavior or guard the built-in memory effects explicitly.

platform="cron",
session_id=_cron_session_id,
session_db=_session_db,
Expand Down
41 changes: 41 additions & 0 deletions tests/cron/test_scheduler_skip_memory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""Tests for cron scheduler skip_memory configuration.

Regression for issue #9763: skip_memory was hardcoded to True in
cron/scheduler.py, making external memory providers (e.g. mem0) unusable
in cron jobs.
"""
import textwrap


class TestCronSkipMemoryConfig:
"""Verify cron reads skip_memory from config.yaml."""

def test_skip_memory_defaults_to_true(self):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests only evaluate a locally copied dict expression, so they pass on the base revision where cron/scheduler.py still hard-codes skip_memory=True. Please exercise run_job with a mocked AIAgent (or an imported production resolver) and assert the actual constructor kwarg.

"""When no cron.skip_memory is configured, default to True."""
config = {}
result = config.get("cron", {}).get("skip_memory", True)
assert result is True

def test_skip_memory_false_when_configured(self):
"""When cron.skip_memory is set to false, use False."""
config = {"cron": {"skip_memory": False}}
result = config.get("cron", {}).get("skip_memory", True)
assert result is False

def test_skip_memory_true_when_explicitly_set(self):
"""When cron.skip_memory is explicitly true, use True."""
config = {"cron": {"skip_memory": True}}
result = config.get("cron", {}).get("skip_memory", True)
assert result is True

def test_empty_cron_section_defaults_to_true(self):
"""When cron section exists but skip_memory is missing, default to True."""
config = {"cron": {}}
result = config.get("cron", {}).get("skip_memory", True)
assert result is True

def test_other_cron_settings_preserved(self):
"""Other cron config settings don't affect skip_memory default."""
config = {"cron": {"timeout": 300}}
result = config.get("cron", {}).get("skip_memory", True)
assert result is True