deerflow2/backend/src/subagents
FangHao d43d60e53f fix(subagent): support async MCP tools in subagent executor (#917)
* fix(subagent): support async MCP tools in subagent executor

SubagentExecutor.execute() was synchronous and could not handle async-only                                                                                                                                  tools like MCP tools. This caused failures when trying to use MCP tools within subagents.

Changes:
- Add _aexecute() async method using agent.astream() for async execution
- Refactor execute() to use asyncio.run() wrapping _aexecute()
- This allows subagents to use async tools (MCP) within ThreadPoolExecutor

* test(subagent): add unit tests for executor async/sync paths

Add comprehensive tests covering:
- Async _aexecute() with success/error cases
- Sync execute() wrapper using asyncio.run()
- Async tool (MCP) support verification
- Thread pool execution safety

* fix(subagent): subagent-test-circular-depend

- Use session-scoped fixture with delayed import to handle circular dependencies
    without affecting other test modules

---------

Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
2026-03-06 14:40:56 +08:00
..
builtins feat(citations): inline citation links with [citation:Title](URL) 2026-02-09 21:40:20 +08:00
__init__.py feat: support sub agent mechanism 2026-02-05 19:59:25 +08:00
config.py fix: fix sub agent timeout 2026-02-08 21:09:18 +08:00
executor.py fix(subagent): support async MCP tools in subagent executor (#917) 2026-03-06 14:40:56 +08:00
registry.py feat(subagents): make subagent timeout configurable via config.yaml (#897) 2026-02-25 08:39:29 +08:00