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

Function test_agent_with_tool_call

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

Source from the content-addressed store, hash-verified

406
407#[tokio::test]
408async fn test_agent_with_tool_call() {
409 let mock_client = Arc::new(MockLlmClient::new(vec![
410 // First response: tool call
411 MockLlmClient::tool_call_response(
412 "tool-1",
413 "bash",
414 serde_json::json!({"command": "echo hello"}),
415 ),
416 // Second response: final text
417 MockLlmClient::text_response("The command output was: hello"),
418 ]));
419
420 let tool_executor = Arc::new(ToolExecutor::new("/tmp".to_string()));
421 let config = AgentConfig::default();
422
423 let agent = AgentLoop::new(
424 mock_client.clone(),
425 tool_executor,
426 test_tool_context(),
427 config,
428 );
429 let result = agent.execute(&[], "Run echo hello", None).await.unwrap();
430
431 assert_eq!(result.text, "The command output was: hello");
432 assert_eq!(result.tool_calls_count, 1);
433 assert_eq!(mock_client.call_count.load(Ordering::SeqCst), 2);
434}
435
436#[tokio::test]
437async fn test_agent_permission_deny() {

Callers

nothing calls this directly

Calls 3

test_tool_contextFunction · 0.70
cloneMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected