feat:优化timing门控逻辑,减少消耗,提高速度

This commit is contained in:
SengokuCola
2026-04-09 13:56:34 +08:00
parent daef71b7e9
commit b28481d205
17 changed files with 371 additions and 49 deletions

View File

@@ -0,0 +1,25 @@
from src.maisaka.reasoning_engine import MaisakaReasoningEngine
def test_retry_planner_after_interrupt_only_when_has_new_messages_and_more_rounds() -> None:
assert MaisakaReasoningEngine._should_retry_planner_after_interrupt(
round_index=0,
max_internal_rounds=6,
has_pending_messages=True,
)
def test_do_not_retry_planner_after_interrupt_without_pending_messages() -> None:
assert not MaisakaReasoningEngine._should_retry_planner_after_interrupt(
round_index=0,
max_internal_rounds=6,
has_pending_messages=False,
)
def test_do_not_retry_planner_after_interrupt_on_last_round() -> None:
assert not MaisakaReasoningEngine._should_retry_planner_after_interrupt(
round_index=5,
max_internal_rounds=6,
has_pending_messages=True,
)

View File

@@ -0,0 +1,10 @@
from src.maisaka.reasoning_engine import MaisakaReasoningEngine
def test_continue_action_closes_timing_gate_for_following_rounds() -> None:
assert MaisakaReasoningEngine._mark_timing_gate_completed("continue") is False
def test_non_continue_actions_require_next_timing_gate() -> None:
assert MaisakaReasoningEngine._mark_timing_gate_completed("wait") is True
assert MaisakaReasoningEngine._mark_timing_gate_completed("no_reply") is True

View File

@@ -0,0 +1,14 @@
from src.maisaka.builtin_tool import get_action_tool_specs, get_timing_tool_specs
def test_wait_tool_available_in_timing_stage() -> None:
tool_names = {tool_spec.name for tool_spec in get_timing_tool_specs()}
assert "wait" in tool_names
def test_wait_tool_not_available_in_action_stage() -> None:
tool_names = {tool_spec.name for tool_spec in get_action_tool_specs()}
assert "wait" not in tool_names
assert "finish" in tool_names