qwen_agent/agent
朱潮 06974e9744 feat: recover tool exceptions into ToolMessage so SSE stream keeps flowing
Add ToolErrorRecoveryMiddleware as the outermost agent middleware so any
tool-call exception (notably MCP ToolException) is converted into a
ToolMessage with status="error" carrying the raw error text. The agent
can then loop once more and reply to the user in natural language about
what failed, instead of bubbling the exception up through agent.astream
and breaking the SSE response in routes/chat.py.

The recovery layer extracts the inner `text="..."` payload out of the MCP
TextContent repr when present, falling back to str(error) otherwise. It
deliberately re-raises asyncio.CancelledError so task cancellation still
propagates, and sits *outside* ToolMetricsMiddleware so the existing
status=error metric is still emitted before recovery kicks in.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-20 13:07:19 +08:00
..
__init__.py 新增agent文件夹,修改import引用,增加custom_mcp_manager 2025-11-26 17:23:02 +08:00
agent_config.py safe print 的base64 字段替换为 [truncated] 2026-06-19 07:49:53 +08:00
agent_memory_cache.py chore: replace Chinese comments and log messages with English 2026-04-30 19:45:35 +08:00
chat_history_manager.py chore: replace Chinese comments and log messages with English 2026-04-30 19:45:35 +08:00
checkpoint_manager.py chore: replace Chinese comments and log messages with English 2026-04-30 19:45:35 +08:00
checkpoint_utils.py feat: support multimodal image (base64) input in chat API 2026-06-18 11:34:57 +08:00
config_cache.py chore: replace Chinese comments and log messages with English 2026-04-30 19:45:35 +08:00
custom_filesystem_middleware.py chore: replace Chinese comments and log messages with English 2026-04-30 19:45:35 +08:00
db_pool_manager.py chore: replace Chinese comments and log messages with English 2026-04-30 19:45:35 +08:00
deep_assistant.py feat: recover tool exceptions into ToolMessage so SSE stream keeps flowing 2026-06-20 13:07:19 +08:00
filepath_fix_middleware.py chore: replace Chinese comments and log messages with English 2026-04-30 19:45:35 +08:00
guideline_middleware.py chore: replace Chinese comments and log messages with English 2026-04-30 19:45:35 +08:00
logging_handler.py chore: improve agent error logging 2026-05-11 20:29:27 +08:00
mcp_trace_meta.py chore: Add methods tools/call. 2026-05-11 21:05:41 +08:00
mem0_config.py chore: replace Chinese comments and log messages with English 2026-04-30 19:45:35 +08:00
mem0_manager.py add no answer tag 2026-06-16 13:19:23 +08:00
mem0_middleware.py chore: replace Chinese comments and log messages with English 2026-04-30 19:45:35 +08:00
plugin_hook_loader.py add mainAgentHiddenTools 2026-06-12 11:03:30 +08:00
prompt_loader.py chore: replace Chinese comments and log messages with English 2026-04-30 19:45:35 +08:00
subagent_context_middleware.py add subagent_context_middleware 2026-06-12 15:56:26 +08:00
subagent_loader.py add subagent_context_middleware 2026-06-12 15:56:26 +08:00
summarization_middleware.py update summary 2026-02-04 15:31:41 +08:00
tool_error_recovery_middleware.py feat: recover tool exceptions into ToolMessage so SSE stream keeps flowing 2026-06-20 13:07:19 +08:00
tool_metrics_middleware.py Add tool call metrics middleware 2026-05-29 11:10:31 +08:00
tool_output_length_middleware.py chore: replace Chinese comments and log messages with English 2026-04-30 19:45:35 +08:00
tool_use_cleanup_middleware.py chore: replace Chinese comments and log messages with English 2026-04-30 19:45:35 +08:00