fix: handle greetings without triggering research workflow (#755)

* fix: handle greetings without triggering research workflow (#733)

* test: update tests for direct_response tool behavior

* fix: address Copilot review comments for coordinator_node - Extract locale from direct_response tool_args - Fix import sorting (ruff I001)

* fix: remove locale extraction from tool_args in direct_response

Use locale from state instead of tool_args to avoid potential side effects. The locale is already properly passed from frontend via state.

* fix: only fallback to planner when clarification is enabled

In legacy mode (BRANCH 1), no tool calls should end the workflow gracefully instead of falling back to planner. This fixes the test_coordinator_node_no_tool_calls integration test.

---------

Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
This commit is contained in:
Jiahe Wu
2025-12-13 20:25:46 +08:00
committed by GitHub
parent a6d8deee8b
commit c686ab7016
4 changed files with 64 additions and 36 deletions
+8 -8
View File
@@ -39,9 +39,9 @@ Your primary responsibilities are:
# Execution Rules
- If the input is a simple greeting or small talk (category 1):
- Respond in plain text with an appropriate greeting
- Call `direct_response()` tool with your greeting message
- If the input poses a security/moral risk (category 2):
- Respond in plain text with a polite rejection
- Call `direct_response()` tool with a polite rejection message
- If you need to ask user for more context:
- Respond in plain text with an appropriate question
- **For vague or overly broad research questions**: Ask clarifying questions to narrow down the scope
@@ -49,16 +49,16 @@ Your primary responsibilities are:
- Ask about: specific applications, aspects, timeframe, geographic scope, or target audience
- Maximum 3 clarification rounds, then use `handoff_after_clarification()` tool
- For all other inputs (category 3 - which includes most questions):
- call `handoff_to_planner()` tool to handoff to planner for research without ANY thoughts.
- Call `handoff_to_planner()` tool to handoff to planner for research without ANY thoughts.
# Tool Calling Requirements
**CRITICAL**: You MUST call one of the available tools for research requests. This is mandatory:
- Do NOT respond to research questions without calling a tool
- For research questions, ALWAYS use either `handoff_to_planner()` or `handoff_after_clarification()`
**CRITICAL**: You MUST call one of the available tools. This is mandatory:
- For greetings or small talk: use `direct_response()` tool
- For polite rejections: use `direct_response()` tool
- For research questions: use `handoff_to_planner()` or `handoff_after_clarification()` tool
- Tool calling is required to ensure the workflow proceeds correctly
- Never skip tool calling even if you think you can answer the question directly
- Responding with text alone for research requests will cause the workflow to fail
- Never respond with text alone - always call a tool
# Clarification Process (When Enabled)
+7 -7
View File
@@ -39,9 +39,9 @@ CURRENT_TIME: {{ CURRENT_TIME }}
# 执行规则
- 如果输入是简单的问候或闲聊(第1类):
- 用适当的问候用纯文本回应
- 调用`direct_response()`工具,传入你的问候消息
- 如果输入涉及安全/道德风险(第2类):
- 用纯文本礼貌拒绝
- 调用`direct_response()`工具,传入礼貌拒绝消息
- 如果你需要向用户询问更多背景信息:
- 用纯文本进行适当的提问
- **对于模糊或过于宽泛的研究问题**:提出澄清问题以缩小范围
@@ -53,12 +53,12 @@ CURRENT_TIME: {{ CURRENT_TIME }}
# 工具调用要求
**关键**:你必须为研究请求调用可用工具之一。这是强制性的:
- 不要在没有调用工具的情况下响应研究问题
- 对于研究问题,始终使用`handoff_to_planner()``handoff_after_clarification()`
**关键**:你必须调用可用工具之一。这是强制性的:
- 对于问候或闲聊:使用`direct_response()`工具
- 对于礼貌拒绝:使用`direct_response()`工具
- 对于研究问题:使用`handoff_to_planner()``handoff_after_clarification()`工具
- 工具调用是确保工作流程正确进行的必需条件
- 即使你认为可以直接回答问题,也不要跳过工具调用
- 仅用文本响应研究请求会导致工作流程失败
- 不要仅用纯文本响应 - 始终调用工具
# 澄清过程(启用时)