MCPcopy
hub / github.com/langroid/langroid / test_done_sequence_tool_then_agent

Function test_done_sequence_tool_then_agent

tests/main/test_done_sequences.py:39–74  ·  view source on GitHub ↗

Test that task terminates after tool followed by agent response

(test_settings: Settings)

Source from the content-addressed store, hash-verified

37
38
39def test_done_sequence_tool_then_agent(test_settings: Settings):
40 """Test that task terminates after tool followed by agent response"""
41 set_global(test_settings)
42
43 # Mock LLM that always generates a tool
44 agent = ChatAgent(
45 ChatAgentConfig(
46 name="TestAgent",
47 llm=MockLMConfig(
48 response_fn=lambda x: '{"request": "simple_tool", "value": "test"}'
49 ),
50 )
51 )
52 agent.enable_message(SimpleTool)
53
54 # Configure task to be done after tool -> agent response
55 config = TaskConfig(
56 done_sequences=[
57 DoneSequence(
58 name="tool_then_agent",
59 events=[
60 AgentEvent(event_type=EventType.TOOL),
61 AgentEvent(event_type=EventType.AGENT_RESPONSE),
62 ],
63 )
64 ]
65 )
66
67 task = Task(agent, config=config, interactive=False)
68 result = task.run("Generate a tool", turns=10)
69
70 # Task should complete after tool generation and agent response
71 assert result is not None
72 # Should have: system, user, llm (with tool)
73 # Note: agent response is not added to message history
74 assert len(agent.message_history) == 3
75
76
77def test_done_sequence_specific_tool(test_settings: Settings):

Callers

nothing calls this directly

Calls 10

enable_messageMethod · 0.95
runMethod · 0.95
set_globalFunction · 0.90
ChatAgentClass · 0.90
ChatAgentConfigClass · 0.90
MockLMConfigClass · 0.90
TaskConfigClass · 0.90
DoneSequenceClass · 0.90
AgentEventClass · 0.90
TaskClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…