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

Function test_agent_streaming_events

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

Source from the content-addressed store, hash-verified

522
523#[tokio::test]
524async fn test_agent_streaming_events() {
525 let mock_client = Arc::new(MockLlmClient::new(vec![MockLlmClient::text_response(
526 "Hello!",
527 )]));
528
529 let tool_executor = Arc::new(ToolExecutor::new("/tmp".to_string()));
530 let config = AgentConfig::default();
531
532 let agent = AgentLoop::new(mock_client, tool_executor, test_tool_context(), config);
533 let (tx, mut rx) = mpsc::channel(100);
534 let cancel_token = tokio_util::sync::CancellationToken::new();
535
536 let result = agent
537 .execute_with_session(&[], "Hi", None, Some(tx), Some(&cancel_token))
538 .await
539 .unwrap();
540 let mut events = Vec::new();
541 while let Some(event) = rx.recv().await {
542 events.push(event);
543 }
544
545 assert_eq!(result.text, "Hello!");
546
547 // Check we received Start and End events
548 assert!(events.iter().any(|e| matches!(e, AgentEvent::Start { .. })));
549 assert!(events.iter().any(|e| matches!(e, AgentEvent::End { .. })));
550}
551
552#[tokio::test]
553async fn test_agent_max_tool_rounds() {

Callers

nothing calls this directly

Calls 2

execute_with_sessionMethod · 0.80
test_tool_contextFunction · 0.70

Tested by

no test coverage detected