MCPcopy Create free account
hub / github.com/AI45Lab/Code / test_agent_max_tool_rounds

Function test_agent_max_tool_rounds

core/src/agent/tests.rs:553–579  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

551
552#[tokio::test]
553async fn test_agent_max_tool_rounds() {
554 // Create a mock that always returns tool calls (infinite loop)
555 let responses: Vec<LlmResponse> = (0..100)
556 .map(|i| {
557 MockLlmClient::tool_call_response(
558 &format!("tool-{}", i),
559 "bash",
560 serde_json::json!({"command": "echo loop"}),
561 )
562 })
563 .collect();
564
565 let mock_client = Arc::new(MockLlmClient::new(responses));
566 let tool_executor = Arc::new(ToolExecutor::new("/tmp".to_string()));
567
568 let config = AgentConfig {
569 max_tool_rounds: 3,
570 ..Default::default()
571 };
572
573 let agent = AgentLoop::new(mock_client, tool_executor, test_tool_context(), config);
574 let result = agent.execute(&[], "Loop forever", None).await;
575
576 // Should fail due to max tool rounds exceeded
577 assert!(result.is_err());
578 assert!(result.unwrap_err().to_string().contains("Max tool rounds"));
579}
580
581#[tokio::test]
582async fn test_agent_no_permission_policy_defaults_to_ask() {

Callers

nothing calls this directly

Calls 2

test_tool_contextFunction · 0.70
executeMethod · 0.45

Tested by

no test coverage detected