File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 11import pytest
22from pydantic import AnyUrl
33
4+ from agents import Agent , Runner
5+
46from .helpers import FakeMCPServer
57
68
@@ -43,3 +45,27 @@ async def test_read_resource_not_found():
4345 uri = "docs://api/reference"
4446 with pytest .raises (KeyError , match = f"Resource { uri } not found" ):
4547 await server .read_resource (AnyUrl (uri ))
48+
49+ @pytest .mark .asyncio
50+ @pytest .mark .parametrize ("streaming" , [False , True ])
51+ async def test_agent_with_resources (streaming : bool ):
52+ """Test agent with resources"""
53+ server = FakeMCPServer ()
54+
55+ agent = Agent (
56+ name = "Assistant" ,
57+ instructions = "Answer users queries using the available resources" ,
58+ mcp_servers = [server ],
59+ )
60+
61+ message = "What's the process to access the APIs? What are the available endpoints?"
62+ if streaming :
63+ streaming_result = Runner .run_streamed (agent , input = message )
64+ async for _ in streaming_result .stream_events ():
65+ pass
66+ final_result = streaming_result .final_output
67+ else :
68+ result = await Runner .run (agent , input = message )
69+ final_result = result .final_output
70+
71+ assert final_result is not None
You can’t perform that action at this time.
0 commit comments