feat:优化timing门控逻辑,减少消耗,提高速度
This commit is contained in:
25
tests/test_maisaka_active_state_logic.py
Normal file
25
tests/test_maisaka_active_state_logic.py
Normal 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,
|
||||
)
|
||||
10
tests/test_maisaka_timing_gate_logic.py
Normal file
10
tests/test_maisaka_timing_gate_logic.py
Normal 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
|
||||
14
tests/test_maisaka_tool_visibility.py
Normal file
14
tests/test_maisaka_tool_visibility.py
Normal 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
|
||||
Reference in New Issue
Block a user