-
Notifications
You must be signed in to change notification settings - Fork 347
Open
Labels
defectSomething isn't workingSomething isn't working
Description
π Bug Description
When running a FastAgent chain with multiple agents in MCP Server mode, requests time out with error -32001
. However, the same code works perfectly in interactive mode.
π Expected Behavior
The multi-agent chain should process requests and return results successfully when running in MCP Server mode, just as it does in interactive mode.
π« Actual Behavior
In MCP Server mode, the chain starts processing (fetches URLs successfully) but then fails with:
- Client error
@modelcontextprotocol/inspector
:MCP error -32001: Request timed out
- Server error:
RuntimeError: Unexpected ASGI message 'http.response.start' sent, after response already completed
π§ͺ Reproduction Steps
- Create a FastAgent with multiple agents in a chain (code below)
- Run in server mode with:
poetry run python testing_fastagent/multiagent.py --server --transport sse --port 8081 --http-timeout 60
- Connect to the server via MCP/inspector
- Send a request that requires both agents to process
- Observe the timeout error
π Code Sample
import asyncio
from mcp_agent.core.fastagent import FastAgent
import argparse
fast = FastAgent("Collaborative Agents Example")
# Agent to search for information on the web
@fast.agent(
"web_agent",
instruction="You are an assistant that searches for information on the web and processes it. Obtain the content from the provided URLs and create a comparative summary.",
servers=["fetch"]
)
# Agent to save files locally
@fast.agent(
"file_agent",
instruction="You are an assistant that saves information to local files in /home/basf/agentes/alpha_repos/testing_fastagent.",
servers=["filesystem"]
)
# Sequential workflow that runs the agents in order
@fast.chain(
name="sequential_search",
sequence=["web_agent", "file_agent"],
instruction="First obtain information from the URLs and then save it to a local file."
)
async def main():
async with fast.run() as agent:
# Interactive chat session
await agent.interactive()
asyncio.run(main())
Input message
Obtain the following sources and create a comparative summary of them:
1. https://raw.githubusercontent.com/pablotoledo/Readium/refs/heads/main/README.md
2. https://raw.githubusercontent.com/pablotoledo/Readium-MCP/refs/heads/main/README.md
Save this summary in a file called "summary.txt" in the directory you can see
π» Environment Information
- FastAgent version: v0.2.25
- Python version: 3.10
- OS: macOS
- Transport: SSE
- Additional flags: --http-timeout 60
poetry run python testing_fastagent/agent.py --server --transport sse --port 8081 --http-timeout 60
π Debugging Information
Server logs show the chain starts running successfully:
- URLs are fetched correctly by the web_agent
- The web_agent processes the results
- Then an ASGI error occurs:
RuntimeError: Unexpected ASGI message 'http.response.start' sent, after response already completed
π Additional Notes
- The issue only occurs when running in MCP Server mode
- Interactive mode works perfectly with the exact same code
- Increasing the HTTP timeout doesn't resolve the issue
- The error seems to occur during the transition between agents in the chain
π Attachments
Server logs showing the error trace (attached separately)
Metadata
Metadata
Assignees
Labels
defectSomething isn't workingSomething isn't working