()
| 406 | |
| 407 | #[tokio::test] |
| 408 | async 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] |
| 437 | async fn test_agent_permission_deny() { |
nothing calls this directly
no test coverage detected