From 0add2cd770c01260add25a4fac1031bcc0a9b53b Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 25 Aug 2025 12:23:12 +0000 Subject: [PATCH] Fix: Ensure response is generated when no tools are used This commit addresses an issue where the system would not generate a response if a query did not trigger any tool usage while `useSpecificAPI` was enabled. The fix involves two changes: 1. The `while` loop condition in `app/actions.tsx` has been modified to remove the dependency on `toolOutputs.length`. This ensures that the application waits for a response (`answer`) to be generated, regardless of whether tools are used. 2. The system prompt for the `researcher` agent in `lib/agents/researcher.tsx` has been enhanced to explicitly instruct the AI to provide a direct answer when no tools are necessary. --- app/actions.tsx | 2 +- lib/agents/researcher.tsx | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/actions.tsx b/app/actions.tsx index f3b3c44f..6617ab64 100644 --- a/app/actions.tsx +++ b/app/actions.tsx @@ -139,7 +139,7 @@ async function submit(formData?: FormData, skip?: boolean) { // If not using a tool, this model generates the answer while ( useSpecificAPI - ? toolOutputs.length === 0 && answer.length === 0 + ? answer.length === 0 : answer.length === 0 && !errorOccurred ) { // Search the web and generate the answer diff --git a/lib/agents/researcher.tsx b/lib/agents/researcher.tsx index 6ef6d53b..f2857bbd 100644 --- a/lib/agents/researcher.tsx +++ b/lib/agents/researcher.tsx @@ -43,6 +43,7 @@ Tool Usage Guide: - "What are some parks in San Francisco?" When you use 'geospatialQueryTool', you don't need to describe how the map will change; simply provide your textual answer based on the query, and trust the map will update appropriately. +When tools are not needed, provide direct, helpful answers based on your knowledge. Always aim to directly address the user's question. If using information from a tool (like web search), cite the source URL. Match the language of your response to the user's language.`;