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)