mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-07-25 23:48:00 +00:00
* feat: emit structured runtime metadata * fix: avoid subagent import cycle in replay gateway * fix: preserve legacy subtask result parsing * refactor: tighten runtime metadata contracts * fix(middleware): keep recovery hint on task exception wrapper content The structured-metadata stamp overwrote the wrapper text with the bare task-failure message, dropping the model-facing 'Continue with available context, or choose an alternative tool.' guidance that every other tool exception keeps. Append the shared hint after the formatted message. * fix(subagents): require lowercase hex for result_sha256 reader Length-only validation accepted any 64-char string; a faulty serializer or relaying wrapper could store a non-digest value in the delegation ledger. Enforce the producer's hexdigest shape with a fullmatch. --------- Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
"""Gateway import regression tests."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
def test_gateway_app_imports_first_without_subagent_import_cycle() -> None:
|
|
"""The replay gateway imports app.gateway.app in a clean process."""
|
|
backend_root = Path(__file__).resolve().parents[1]
|
|
env = {**os.environ, "PYTHONPATH": str(backend_root)}
|
|
result = subprocess.run(
|
|
[sys.executable, "-c", "from app.gateway.app import app"],
|
|
capture_output=True,
|
|
text=True,
|
|
env=env,
|
|
)
|
|
assert result.returncode == 0, result.stderr
|
|
|
|
|
|
def test_subagent_package_public_executor_exports_are_lazy_importable() -> None:
|
|
"""The package-level executor exports must not re-enter their own import."""
|
|
backend_root = Path(__file__).resolve().parents[1]
|
|
env = {**os.environ, "PYTHONPATH": str(backend_root)}
|
|
result = subprocess.run(
|
|
[
|
|
sys.executable,
|
|
"-c",
|
|
"from deerflow.subagents import SubagentExecutor, SubagentResult; print(SubagentExecutor.__name__, SubagentResult.__name__)",
|
|
],
|
|
capture_output=True,
|
|
text=True,
|
|
env=env,
|
|
)
|
|
assert result.returncode == 0, result.stderr
|
|
assert "SubagentExecutor SubagentResult" in result.stdout
|