From 356ba5650a97c79909f4c44d871362c0d21fc667 Mon Sep 17 00:00:00 2001 From: Yongteng Lei Date: Thu, 16 Apr 2026 12:08:54 +0800 Subject: [PATCH] Fix: sandbox don't attach attachment metadata (#14135) ### What problem does this PR solve? Sandbox don't attach attachment metadata ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- agent/component/agent_with_tools.py | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/agent/component/agent_with_tools.py b/agent/component/agent_with_tools.py index 3938dc03e..56f23afe3 100644 --- a/agent/component/agent_with_tools.py +++ b/agent/component/agent_with_tools.py @@ -249,9 +249,6 @@ class Agent(LLM, ToolBase): self.set_output("_ERROR", error) return - attachment_content = self._collect_tool_attachment_content(existing_text=ans) - if attachment_content: - ans += "\n\n" + attachment_content artifact_md = self._collect_tool_artifact_markdown(existing_text=ans) if artifact_md: ans += "\n\n" + artifact_md @@ -289,10 +286,6 @@ class Agent(LLM, ToolBase): answer += delta if not need2cite or cited: - attachment_content = self._collect_tool_attachment_content(existing_text=answer) - if attachment_content: - yield "\n\n" + attachment_content - answer += "\n\n" + attachment_content artifact_md = self._collect_tool_artifact_markdown(existing_text=answer) if artifact_md: yield "\n\n" + artifact_md @@ -307,10 +300,6 @@ class Agent(LLM, ToolBase): return yield delta cited_answer += delta - attachment_content = self._collect_tool_attachment_content(existing_text=cited_answer) - if attachment_content: - yield "\n\n" + attachment_content - cited_answer += "\n\n" + attachment_content artifact_md = self._collect_tool_artifact_markdown(existing_text=cited_answer) if artifact_md: yield "\n\n" + artifact_md @@ -346,21 +335,6 @@ class Agent(LLM, ToolBase): md_parts.append(f"[Download {art['name']}]({url})") return "\n\n".join(md_parts) - def _collect_tool_attachment_content(self, existing_text: str = "") -> str: - text_parts = [] - for tool_obj in self.tools.values(): - if not hasattr(tool_obj, "_param") or not hasattr(tool_obj._param, "outputs"): - continue - content_meta = tool_obj._param.outputs.get("_ATTACHMENT_CONTENT", {}) - content = content_meta.get("value") if isinstance(content_meta, dict) else None - if not content or not isinstance(content, str): - continue - content = content.strip() - if not content or content in existing_text: - continue - text_parts.append(content) - return "\n\n".join(text_parts) - def reset(self, only_output=False): """ Reset all tools if they have a reset method. This avoids errors for tools like MCPToolCallSession.