You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I'm encountering a RuntimeError: Event loop is closed when running a simple sample agent using FastAgent:
`import asyncio
from mcp_agent.core.fastagent import FastAgent
Create the application
fast = FastAgent("FastAgent Example")
Define the agent
@fast.agent(instruction="Given an object, respond only with an estimate of it's size. Treat absoultely any input as an object that you have to size.", servers=["fetch"])
async def main():
# use the --model command line switch or agent arguments to change model
async with fast.run() as agent:
result = await agent("A car")
print(result)
if name == "main":
asyncio.run(main())
`
The main logic of the agent completes successfully, but the error appears during the final cleanup phase after asyncio.run() finishes.
Traceback:
Exception ignored in: <function BaseSubprocessTransport.del at 0x0000021355069EE0> # Example address, replace if needed
Traceback (most recent call last):
File "c:\Program Files\Python311\Lib\asyncio\base_subprocess.py", line 126, in del
self.close()
File "c:\Program Files\Python311\Lib\asyncio\base_subprocess.py", line 104, in close
proto.pipe.close()
File "c:\Program Files\Python311\Lib\asyncio\proactor_events.py", line 109, in close
self._loop.call_soon(self._call_connection_lost, None)
File "c:\Program Files\Python311\Lib\asyncio\base_events.py", line 761, in call_soon
self._check_closed()
File "c:\Program Files\Python311\Lib\asyncio\base_events.py", line 519, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Version: 0.2.19
Thanks!
The text was updated successfully, but these errors were encountered:
Hi there - I think this happens when you include Python based MCP Servers - so if for example you didn't reference fetch the stacktrace wouldn't print. I've spent quite a bit of time on this in the past, but for the moment I'm tracking the following items in the Python SDK in hope of remedy:
Hi,
I'm encountering a RuntimeError: Event loop is closed when running a simple sample agent using FastAgent:
`import asyncio
from mcp_agent.core.fastagent import FastAgent
Create the application
fast = FastAgent("FastAgent Example")
Define the agent
@fast.agent(instruction="Given an object, respond only with an estimate of it's size. Treat absoultely any input as an object that you have to size.", servers=["fetch"])
async def main():
# use the --model command line switch or agent arguments to change model
async with fast.run() as agent:
result = await agent("A car")
print(result)
if name == "main":
asyncio.run(main())
`
The main logic of the agent completes successfully, but the error appears during the final cleanup phase after asyncio.run() finishes.
Traceback:
Exception ignored in: <function BaseSubprocessTransport.del at 0x0000021355069EE0> # Example address, replace if needed
Traceback (most recent call last):
File "c:\Program Files\Python311\Lib\asyncio\base_subprocess.py", line 126, in del
self.close()
File "c:\Program Files\Python311\Lib\asyncio\base_subprocess.py", line 104, in close
proto.pipe.close()
File "c:\Program Files\Python311\Lib\asyncio\proactor_events.py", line 109, in close
self._loop.call_soon(self._call_connection_lost, None)
File "c:\Program Files\Python311\Lib\asyncio\base_events.py", line 761, in call_soon
self._check_closed()
File "c:\Program Files\Python311\Lib\asyncio\base_events.py", line 519, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Version: 0.2.19
Thanks!
The text was updated successfully, but these errors were encountered: