From e1c6bb7be0823a6a274911bda1274e28f97dd095 Mon Sep 17 00:00:00 2001 From: hehaoqi Date: Fri, 3 Oct 2025 18:56:45 +0800 Subject: [PATCH] Modify the ollama_client.py because the ollama needs the role of "function" to support function call output. Meanwhile, "if not matched_tags: return []" in lake_view.py is to handle the case that the llm response does not contain any tags. --- trae_agent/utils/lake_view.py | 2 ++ trae_agent/utils/llm_clients/ollama_client.py | 1 + 2 files changed, 3 insertions(+) diff --git a/trae_agent/utils/lake_view.py b/trae_agent/utils/lake_view.py index 5e420846..a3090e25 100644 --- a/trae_agent/utils/lake_view.py +++ b/trae_agent/utils/lake_view.py @@ -166,6 +166,8 @@ async def extract_tag_in_step(self, step: str) -> list[str]: content = "" + llm_response.content.lstrip() matched_tags: list[str] = tags_re.findall(content) + if not matched_tags: + return [] tags: list[str] = [tag.strip() for tag in matched_tags[0].split(",")] if all(tag in KNOWN_TAGS for tag in tags): return tags diff --git a/trae_agent/utils/llm_clients/ollama_client.py b/trae_agent/utils/llm_clients/ollama_client.py index 845e9bf6..56d3e9c6 100644 --- a/trae_agent/utils/llm_clients/ollama_client.py +++ b/trae_agent/utils/llm_clients/ollama_client.py @@ -185,6 +185,7 @@ def parse_tool_call_result(self, tool_call_result: ToolResult) -> FunctionCallOu result = result.strip() return FunctionCallOutput( + role="function", call_id=tool_call_result.call_id, id=tool_call_result.id, output=result,