mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-09-25 22:16:19 +00:00
* fix(agent): align autonomous interaction guidance * fix(agent): harden interaction policy selection * fix(gateway): protect legacy interaction flags * fix(channels): honor explicit interaction mode * docs(agent): reduce inherited guidance size * fix(agent): honor unattended policy across approval paths --------- Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
52 lines
1.9 KiB
Python
52 lines
1.9 KiB
Python
import pytest
|
|
|
|
from deerflow.agents.interaction_policy import (
|
|
ASK_CLARIFICATION_TOOL_NAME,
|
|
RunInteractionMode,
|
|
RunInteractionPolicy,
|
|
resolve_run_interaction_policy,
|
|
)
|
|
|
|
|
|
def test_interactive_policy_keeps_clarification_available():
|
|
policy = resolve_run_interaction_policy({})
|
|
|
|
assert policy.mode is RunInteractionMode.INTERACTIVE
|
|
assert policy.allows_clarification
|
|
assert policy.disabled_tool_names == frozenset()
|
|
assert "MUST call ask_clarification" in policy.clarification_system
|
|
|
|
|
|
def test_scheduled_policy_disables_tool_and_uses_autonomous_guidance():
|
|
policy = resolve_run_interaction_policy({"context": {"non_interactive": True}})
|
|
|
|
assert policy.mode is RunInteractionMode.SCHEDULED
|
|
assert not policy.allows_clarification
|
|
assert policy.disabled_tool_names == frozenset({ASK_CLARIFICATION_TOOL_NAME})
|
|
assert "MUST call ask_clarification" not in policy.clarification_system
|
|
assert "minimal reversible assumptions" in policy.clarification_reminder
|
|
|
|
|
|
def test_github_policy_resolves_as_webhook_without_legacy_flag():
|
|
policy = resolve_run_interaction_policy({"context": {"channel_name": "github", "disable_clarification": True}})
|
|
|
|
assert policy.mode is RunInteractionMode.WEBHOOK
|
|
assert not policy.allows_clarification
|
|
assert "issue, pull request, repository, event context" in policy.clarification_system
|
|
|
|
|
|
def test_explicit_mode_takes_precedence_over_legacy_flags():
|
|
policy = resolve_run_interaction_policy(
|
|
{
|
|
"configurable": {"interaction_mode": "autonomous"},
|
|
"context": {"non_interactive": True, "channel_name": "github"},
|
|
}
|
|
)
|
|
|
|
assert policy == RunInteractionPolicy(RunInteractionMode.AUTONOMOUS)
|
|
|
|
|
|
def test_invalid_explicit_mode_fails_closed():
|
|
with pytest.raises(ValueError, match="Invalid interaction_mode 'Scheduled'"):
|
|
resolve_run_interaction_policy({"context": {"interaction_mode": "Scheduled"}})
|