fix(mcp-tool): using the async invocation for MCP tools (#840)

This commit is contained in:
Willem Jiang
2026-01-28 21:25:16 +08:00
committed by GitHub
parent ee02b9f637
commit 756421c3ac
2 changed files with 18 additions and 17 deletions

View File

@@ -1125,10 +1125,11 @@ async def _execute_agent_step(
)
try:
# Use stream from the start to capture messages in real-time
# Use astream (async) from the start to capture messages in real-time
# This allows us to retrieve accumulated messages even if recursion limit is hit
# NOTE: astream is required for MCP tools which only support async invocation
accumulated_messages = []
for chunk in agent.stream(
async for chunk in agent.astream(
input=agent_input,
config={"recursion_limit": recursion_limit},
stream_mode="values",