deer-flow/backend/tests/blocking_io/test_subagent_checkpoints_offloop.py
Aurora_ c5d072af91
feat(subagents): add optional SQLite checkpoint history (#8265)
* feat(subagents): add optional SQLite checkpoint history

* docs(subagents): clarify checkpoint history limits

* fix(subagents): resolve checkpoint factory at startup

---------

Co-authored-by: Nan Gao <thunderggnn@gmail.com>
2026-11-16 13:29:26 +08:00

41 lines
1.6 KiB
Python

"""Opening the isolated saver must leave the Gateway loop responsive."""
from __future__ import annotations
import asyncio
import importlib
import sys
import pytest
@pytest.mark.asyncio
async def test_checkpoint_peer_lifetime_does_not_block_gateway_loop(monkeypatch, tmp_path):
import deerflow.agents.thread_state # noqa: F401
import deerflow.subagents as package
from deerflow.config.app_config import AppConfig
from deerflow.runtime.checkpointer.async_provider import make_checkpointer
from deerflow.subagents.checkpoints import subagent_checkpoint_runtime
monkeypatch.delitem(sys.modules, "deerflow.subagents.executor", raising=False)
monkeypatch.delattr(package, "executor", raising=False)
executor = importlib.import_module("deerflow.subagents.executor")
config = AppConfig.model_validate(
{
"database": {"backend": "sqlite", "sqlite_dir": str(tmp_path)},
"subagent_runtime": {"checkpoint_enabled": True},
"sandbox": {"use": "deerflow.sandbox.local:LocalSandboxProvider"},
}
)
try:
async with make_checkpointer(config) as saver:
async with subagent_checkpoint_runtime(config, saver) as runtime:
assert runtime.loop is not asyncio.get_running_loop()
assert runtime.saver is not saver
await saver.setup()
assert runtime.closed
finally:
await asyncio.to_thread(executor._shutdown_isolated_subagent_loop)
if getattr(package, "executor", None) is executor:
delattr(package, "executor")