From 8ef2f79d0a65647b0322ac242fbf68c955a4613e Mon Sep 17 00:00:00 2001 From: buua436 <66937541+buua436@users.noreply.github.com> Date: Thu, 13 Nov 2025 09:49:12 +0800 Subject: [PATCH] =?UTF-8?q?Fix:reset=20the=20agent=20component=E2=80=99s?= =?UTF-8?q?=20output=20=20(#11222)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### What problem does this PR solve? change: “After each dialogue turn, the agent component’s output is not reset.” ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- agent/component/agent_with_tools.py | 10 +++++++++- agent/component/llm.py | 2 +- deepdoc/parser/docling_parser.py | 3 --- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/agent/component/agent_with_tools.py b/agent/component/agent_with_tools.py index 98dfbc92f..a27504139 100644 --- a/agent/component/agent_with_tools.py +++ b/agent/component/agent_with_tools.py @@ -368,11 +368,19 @@ Respond immediately with your final comprehensive answer. return "Error occurred." - def reset(self, temp=False): + def reset(self, only_output=False): """ Reset all tools if they have a reset method. This avoids errors for tools like MCPToolCallSession. """ + for k in self._param.outputs.keys(): + self._param.outputs[k]["value"] = None + for k, cpn in self.tools.items(): if hasattr(cpn, "reset") and callable(cpn.reset): cpn.reset() + if only_output: + return + for k in self._param.inputs.keys(): + self._param.inputs[k]["value"] = None + self._param.debug_inputs = {} diff --git a/agent/component/llm.py b/agent/component/llm.py index 6ce0f65a5..b08e0591e 100644 --- a/agent/component/llm.py +++ b/agent/component/llm.py @@ -222,7 +222,7 @@ class LLM(ComponentBase): output_structure = self._param.outputs['structured'] except Exception: pass - if output_structure: + if output_structure and isinstance(output_structure, dict) and output_structure.get("properties"): schema=json.dumps(output_structure, ensure_ascii=False, indent=2) prompt += structured_output_prompt(schema) for _ in range(self._param.max_retries+1): diff --git a/deepdoc/parser/docling_parser.py b/deepdoc/parser/docling_parser.py index dd0f57ea4..9d67478c8 100644 --- a/deepdoc/parser/docling_parser.py +++ b/deepdoc/parser/docling_parser.py @@ -186,9 +186,6 @@ class DoclingParser(RAGFlowPdfParser): yield (DoclingContentType.EQUATION.value, text, bbox) def _transfer_to_sections(self, doc) -> list[tuple[str, str]]: - """ - 和 MinerUParser 保持一致:返回 [(section_text, line_tag), ...] - """ sections: list[tuple[str, str]] = [] for typ, payload, bbox in self._iter_doc_items(doc): if typ == DoclingContentType.TEXT.value: