deer-flow/backend/tests/test_generalization_report_policy.py
Eilen Shin aaca3eeaeb
refactor(agent): ground runtime decisions in structured evidence (#7986)
* refactor(agent): ground runtime decisions in structured evidence

Use producer status and structured errors for tool recovery, preserve memory context without lexical confirmation, and remove predetermined receipt and skill conclusions.

Require explicit MCP discovery and authenticated schedule trial actions. Preserve authorization, ownership, isolation, and bounded execution; update documentation and regression coverage.

* test(sandbox): expect read_file initialization error callback

* fix(agent): address evidence review follow-ups

* fix(agent): preserve retry budgets for OpenAI transport errors

* fix(agent): expose tool execution status in model requests

Project validated execution metadata and exact tool text into request-only JSON so status survives provider serialization. Preserve stored results and receipt hashes, cover SDK and graph boundaries, and migrate replay input hashes without changing recorded responses.

---------

Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
2026-11-08 22:00:23 +08:00

28 lines
1.3 KiB
Python

"""Evidence and proportional interaction regressions."""
from deerflow.agents.interaction_policy import RunInteractionPolicy
from deerflow.agents.middlewares.receipt_verification import render_citation_verdict, verify_receipt_citations
def test_negated_action_text_is_not_semantically_classified():
verdict = verify_receipt_citations("I did not modify report.py or run tests.", [])
assert verdict["no_citation_claims"] is False
assert verdict["citation_resolved"] is False
assert "no receipt citations" in render_citation_verdict(verdict)
def test_uncited_tool_execution_is_unresolved_regardless_of_language_or_length():
receipt = {"id": "r1", "status": "success", "tool_name": "bash"}
for text in ("42", "No changes were needed.", "??", "x" * 500):
verdict = verify_receipt_citations(text, [receipt])
assert verdict["citation_resolved"] is False
assert "action claims" not in render_citation_verdict(verdict)
def test_interactive_policy_allows_inspection_and_reversible_assumptions():
policy = RunInteractionPolicy.interactive()
assert "reversible" in policy.clarification_system
assert "independent" in policy.clarification_system
assert "Clarification ALWAYS comes BEFORE action" not in policy.clarification_system
assert "If anything is unclear" not in policy.thinking_guidance