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

Function test_agent_hitl_timeout_reject

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

Source from the content-addressed store, hash-verified

744
745#[tokio::test]
746async fn test_agent_hitl_timeout_reject() {
747 use crate::hitl::{ConfirmationManager, ConfirmationPolicy, TimeoutAction};
748 use tokio::sync::broadcast;
749
750 let mock_client = Arc::new(MockLlmClient::new(vec![
751 MockLlmClient::tool_call_response(
752 "tool-1",
753 "bash",
754 serde_json::json!({"command": "echo test"}),
755 ),
756 MockLlmClient::text_response("Timed out, I understand."),
757 ]));
758
759 let tool_executor = Arc::new(ToolExecutor::new("/tmp".to_string()));
760
761 // Create HITL with very short timeout and Reject action
762 let (event_tx, _event_rx) = broadcast::channel(100);
763 let hitl_policy = ConfirmationPolicy {
764 enabled: true,
765 default_timeout_ms: 50, // Very short timeout
766 timeout_action: TimeoutAction::Reject,
767 ..Default::default()
768 };
769 let confirmation_manager = Arc::new(ConfirmationManager::new(hitl_policy, event_tx));
770
771 let permission_policy = PermissionPolicy::new();
772
773 let config = AgentConfig {
774 permission_checker: Some(Arc::new(permission_policy)),
775 confirmation_manager: Some(confirmation_manager),
776 ..Default::default()
777 };
778
779 // Don't approve - let it timeout
780 let agent = AgentLoop::new(mock_client, tool_executor, test_tool_context(), config);
781 let result = agent.execute(&[], "Echo", None).await.unwrap();
782
783 // Should get timeout rejection response from LLM
784 assert_eq!(result.text, "Timed out, I understand.");
785}
786
787#[tokio::test]
788async fn test_agent_hitl_timeout_auto_approve() {

Callers

nothing calls this directly

Calls 2

test_tool_contextFunction · 0.70
executeMethod · 0.45

Tested by

no test coverage detected