refactor: bind cron jobs to origin sessions
This commit is contained in:
@@ -246,8 +246,8 @@ async def test_cron_tool_basic_set_context_and_execute(tmp_path) -> None:
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_webui_cron_tool_uses_unified_session_when_enabled(tmp_path) -> None:
|
||||
"""WebUI-created automations should follow unified session ownership."""
|
||||
async def test_webui_cron_tool_uses_origin_session_when_unified_enabled(tmp_path) -> None:
|
||||
"""WebUI-created cron jobs stay attached to the creating chat."""
|
||||
tool = CronTool(CronService(tmp_path / "jobs.json"))
|
||||
|
||||
class _Tools:
|
||||
@@ -271,7 +271,7 @@ async def test_webui_cron_tool_uses_unified_session_when_enabled(tmp_path) -> No
|
||||
|
||||
jobs = tool._cron.list_jobs()
|
||||
assert len(jobs) == 1
|
||||
assert jobs[0].payload.session_key == UNIFIED_SESSION_KEY
|
||||
assert jobs[0].payload.session_key == "websocket:chat-123"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -280,4 +280,4 @@ async def test_cron_tool_no_context_returns_error(tmp_path) -> None:
|
||||
tool = CronTool(CronService(tmp_path / "jobs.json"))
|
||||
|
||||
result = await tool.execute(action="add", message="test", every_seconds=60)
|
||||
assert result == "Error: scheduled automations must be created from a chat session"
|
||||
assert result == "Error: scheduled cron jobs must be created from a chat session"
|
||||
|
||||
Reference in New Issue
Block a user