()
| 786 | |
| 787 | #[tokio::test] |
| 788 | async fn test_agent_hitl_timeout_auto_approve() { |
| 789 | use crate::hitl::{ConfirmationManager, ConfirmationPolicy, TimeoutAction}; |
| 790 | use tokio::sync::broadcast; |
| 791 | |
| 792 | let mock_client = Arc::new(MockLlmClient::new(vec![ |
| 793 | MockLlmClient::tool_call_response( |
| 794 | "tool-1", |
| 795 | "bash", |
| 796 | serde_json::json!({"command": "echo hello"}), |
| 797 | ), |
| 798 | MockLlmClient::text_response("Auto-approved and executed!"), |
| 799 | ])); |
| 800 | |
| 801 | let tool_executor = Arc::new(ToolExecutor::new("/tmp".to_string())); |
| 802 | |
| 803 | // Create HITL with very short timeout and AutoApprove action |
| 804 | let (event_tx, _event_rx) = broadcast::channel(100); |
| 805 | let hitl_policy = ConfirmationPolicy { |
| 806 | enabled: true, |
| 807 | default_timeout_ms: 50, // Very short timeout |
| 808 | timeout_action: TimeoutAction::AutoApprove, |
| 809 | ..Default::default() |
| 810 | }; |
| 811 | let confirmation_manager = Arc::new(ConfirmationManager::new(hitl_policy, event_tx)); |
| 812 | |
| 813 | let permission_policy = PermissionPolicy::new(); |
| 814 | |
| 815 | let config = AgentConfig { |
| 816 | permission_checker: Some(Arc::new(permission_policy)), |
| 817 | confirmation_manager: Some(confirmation_manager), |
| 818 | ..Default::default() |
| 819 | }; |
| 820 | |
| 821 | // Don't approve - let it timeout and auto-approve |
| 822 | let agent = AgentLoop::new(mock_client, tool_executor, test_tool_context(), config); |
| 823 | let result = agent.execute(&[], "Echo", None).await.unwrap(); |
| 824 | |
| 825 | // Should auto-approve on timeout and execute |
| 826 | assert_eq!(result.text, "Auto-approved and executed!"); |
| 827 | assert_eq!(result.tool_calls_count, 1); |
| 828 | } |
| 829 | |
| 830 | #[tokio::test] |
| 831 | async fn test_agent_hitl_confirmation_events() { |
nothing calls this directly
no test coverage detected