fix: eventloop test
This commit is contained in:
@@ -789,7 +789,14 @@ class TestEscalate:
|
||||
|
||||
ctx = build_ctx(runtime, node_spec, memory, llm, stream_id="worker")
|
||||
node = EventLoopNode(event_bus=bus, config=LoopConfig(max_iterations=5))
|
||||
|
||||
async def queen_reply():
|
||||
await asyncio.sleep(0.05)
|
||||
await node.inject_event("Acknowledged, proceed.")
|
||||
|
||||
task = asyncio.create_task(queen_reply())
|
||||
result = await node.execute(ctx)
|
||||
await task
|
||||
|
||||
assert result.success is True
|
||||
assert len(received) == 1
|
||||
@@ -827,7 +834,14 @@ class TestEscalate:
|
||||
|
||||
ctx = build_ctx(runtime, node_spec, memory, llm, stream_id="worker")
|
||||
node = EventLoopNode(event_bus=bus, config=LoopConfig(max_iterations=5))
|
||||
|
||||
async def queen_reply():
|
||||
await asyncio.sleep(0.05)
|
||||
await node.inject_event("Queen acknowledges escalation.")
|
||||
|
||||
task = asyncio.create_task(queen_reply())
|
||||
result = await node.execute(ctx)
|
||||
await task
|
||||
|
||||
assert result.success is True
|
||||
queen_node.inject_event.assert_awaited_once()
|
||||
@@ -1756,9 +1770,9 @@ class TestIsToolDoomLoop:
|
||||
|
||||
def test_different_args_no_doom(self):
|
||||
node = EventLoopNode(config=LoopConfig(tool_doom_loop_threshold=3))
|
||||
fp1 = [("search", '{"q": "a"}')]
|
||||
fp2 = [("search", '{"q": "b"}')]
|
||||
fp3 = [("search", '{"q": "c"}')]
|
||||
fp1 = [("search", '{"q": "deploy kubernetes cluster to production"}')]
|
||||
fp2 = [("read_file", '{"path": "/etc/nginx/nginx.conf"}')]
|
||||
fp3 = [("execute", '{"command": "SELECT * FROM users WHERE active=true"}')]
|
||||
is_doom, _ = node._is_tool_doom_loop([fp1, fp2, fp3])
|
||||
assert is_doom is False
|
||||
|
||||
@@ -1886,6 +1900,7 @@ class TestToolDoomLoopIntegration:
|
||||
config=LoopConfig(
|
||||
max_iterations=10,
|
||||
tool_doom_loop_threshold=3,
|
||||
stall_similarity_threshold=1.0, # disable fuzzy stall detection
|
||||
),
|
||||
)
|
||||
result = await node.execute(ctx)
|
||||
@@ -1941,6 +1956,7 @@ class TestToolDoomLoopIntegration:
|
||||
config=LoopConfig(
|
||||
max_iterations=10,
|
||||
tool_doom_loop_threshold=3,
|
||||
stall_similarity_threshold=1.0, # disable fuzzy stall detection
|
||||
),
|
||||
)
|
||||
result = await node.execute(ctx)
|
||||
@@ -2005,6 +2021,7 @@ class TestToolDoomLoopIntegration:
|
||||
config=LoopConfig(
|
||||
max_iterations=10,
|
||||
tool_doom_loop_threshold=3,
|
||||
stall_similarity_threshold=1.0, # disable fuzzy stall detection
|
||||
),
|
||||
)
|
||||
result = await node.execute(ctx)
|
||||
@@ -2056,6 +2073,7 @@ class TestToolDoomLoopIntegration:
|
||||
config=LoopConfig(
|
||||
max_iterations=10,
|
||||
tool_doom_loop_enabled=False,
|
||||
stall_similarity_threshold=1.0, # disable fuzzy stall detection
|
||||
),
|
||||
)
|
||||
result = await node.execute(ctx)
|
||||
@@ -2144,6 +2162,7 @@ class TestToolDoomLoopIntegration:
|
||||
config=LoopConfig(
|
||||
max_iterations=10,
|
||||
tool_doom_loop_threshold=3,
|
||||
stall_similarity_threshold=1.0, # disable fuzzy stall detection
|
||||
),
|
||||
)
|
||||
result = await node.execute(ctx)
|
||||
@@ -2206,6 +2225,7 @@ class TestToolDoomLoopIntegration:
|
||||
config=LoopConfig(
|
||||
max_iterations=10,
|
||||
tool_doom_loop_threshold=3,
|
||||
stall_similarity_threshold=1.0, # disable fuzzy stall detection
|
||||
),
|
||||
)
|
||||
result = await node.execute(ctx)
|
||||
|
||||
Reference in New Issue
Block a user