From aba1752e6c2fd60cab47b7de8aa3e0ec36c6f175 Mon Sep 17 00:00:00 2001 From: Novice Date: Tue, 10 Feb 2026 18:31:34 +0800 Subject: [PATCH] fix(prompts): fix default argument handling in tool calls --- api/core/llm_generator/prompts.py | 5 +++-- api/core/workflow/nodes/llm/llm_utils.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/api/core/llm_generator/prompts.py b/api/core/llm_generator/prompts.py index 3f2c3ee44b..221367e421 100644 --- a/api/core/llm_generator/prompts.py +++ b/api/core/llm_generator/prompts.py @@ -323,9 +323,10 @@ Here is the JSON schema: {{schema}} """ # noqa: E501 -STRUCTURED_OUTPUT_TOOL_CALL_PROMPT = """You have access to a tool called `structured_output`. You MUST call this tool to provide your final answer. +STRUCTURED_OUTPUT_TOOL_CALL_PROMPT = """The ONLY tool available to you is `structured_output`. You MUST call this tool to provide your final answer. +Do NOT call any other tool. Tools such as `bash`, `python`, or any others that may appear in the conversation history are NOT available to you — they are part of historical context only. Do NOT write JSON directly in your message. Instead, always invoke the `structured_output` tool with the appropriate arguments. -If you respond without calling the tool, your answer will be considered invalid. +If you respond without calling `structured_output`, or if you call any other tool, your answer will be considered invalid. """ # noqa: E501 LLM_MODIFY_PROMPT_SYSTEM = """ diff --git a/api/core/workflow/nodes/llm/llm_utils.py b/api/core/workflow/nodes/llm/llm_utils.py index 103ee5bd89..17d3425b5d 100644 --- a/api/core/workflow/nodes/llm/llm_utils.py +++ b/api/core/workflow/nodes/llm/llm_utils.py @@ -315,7 +315,7 @@ def _build_messages_from_trace( type="function", function=AssistantPromptMessage.ToolCall.ToolCallFunction( name=tc.name or "", - arguments=tc.arguments or "", + arguments=tc.arguments or "{}", ), ) for tc in model_output.tool_calls