deer-flow/backend/tests/blocking_io/test_run_journal_callbacks.py
Vanzeren 1c7531242c
feat(runtime): record terminal artifact delivery receipts (slice 1 of #4272) (#4365)
* feat(runtime): record terminal artifact delivery receipts (#4272)

* fix(runtime): persist delivery receipts across recovery

* test(runtime): cover delivery receipt invariants

* fix(runtime): preserve terminal status on receipt outages
2026-07-26 21:45:47 +08:00

40 lines
1.2 KiB
Python

"""Regression anchor: inline RunJournal callbacks stay event-loop safe."""
from __future__ import annotations
from uuid import uuid4
import pytest
from langchain_core.callbacks.manager import ahandle_event
from langchain_core.messages import AIMessage, ToolMessage
from langgraph.types import Command
from deerflow.runtime.events.store.memory import MemoryRunEventStore
from deerflow.runtime.journal import RunJournal
pytestmark = pytest.mark.asyncio
async def test_inline_tool_callback_does_not_block_event_loop() -> None:
journal = RunJournal("run-1", "thread-1", MemoryRunEventStore(), flush_threshold=100)
journal._remember_current_run_tool_calls(
AIMessage(content="", tool_calls=[{"id": "call-1", "name": "present_files", "args": {}}]),
caller="lead_agent",
)
command = Command(
update={
"artifacts": ["/mnt/user-data/outputs/report.md"],
"messages": [ToolMessage("Successfully presented files", tool_call_id="call-1")],
}
)
await ahandle_event(
[journal],
"on_tool_end",
"ignore_agent",
command,
run_id=uuid4(),
)
assert journal.get_delivery_content()["paths"] == ["/mnt/user-data/outputs/report.md"]