Skip to content

Feat: Improve prompting for exploration efficiency#372

Merged
ngoiyaeric merged 5 commits into
mainfrom
improve-prompting-efficiency
Nov 21, 2025
Merged

Feat: Improve prompting for exploration efficiency#372
ngoiyaeric merged 5 commits into
mainfrom
improve-prompting-efficiency

Conversation

@ngoiyaeric
Copy link
Copy Markdown
Collaborator

@ngoiyaeric ngoiyaeric commented Nov 21, 2025

User description

This pull request updates the system prompts for the taskManager and researcher agents to explicitly prioritize Exploration Efficiency. \n\nChanges in taskManager.tsx:\n- The prompt is updated to act as an efficient Task Manager.\n- New Exploration Efficiency Principles are introduced to guide the decision between proceed and inquire.\n- The inquire option is now strongly tied to the Clarity First principle, especially for geospatial queries, to prevent the researcher from starting broad, token-intensive searches.\n\nChanges in researcher.tsx:\n- The system prompt is updated with an Exploration Efficiency Directives section.\n- Directives emphasize Tool First, Geospatial Priority, and Search Specificity to ensure the most efficient use of resources and tools.


PR Type

Enhancement


Description

  • Restructured system prompts to prioritize exploration efficiency

  • Added explicit "Exploration Efficiency Directives" to researcher agent

  • Introduced "Clarity First" principle to task manager for better query clarification

  • Reorganized tool usage guidance with clearer formatting and examples


Diagram Walkthrough

flowchart LR
  A["User Query"] --> B["Task Manager<br/>Clarity First Principle"]
  B --> C{"Query Clear?"}
  C -->|No| D["Inquire<br/>Gather Context"]
  C -->|Yes| E["Proceed"]
  D --> F["Researcher Agent<br/>Exploration Efficiency"]
  E --> F
  F --> G["Tool First:<br/>Select Optimal Tool"]
  G --> H["Geospatial Priority<br/>Location-based Queries"]
  H --> I["Search Specificity<br/>Focused Searches"]
  I --> J["Response with Citations"]
Loading

File Walkthrough

Relevant files
Enhancement
researcher.tsx
Restructure researcher prompt for efficiency directives   

lib/agents/researcher.tsx

  • Restructured default system prompt with explicit "Exploration
    Efficiency Directives" section
  • Added numbered directives: Tool First, Geospatial Priority, Search
    Specificity, Concise Response, and Citations
  • Simplified tool usage guide with clearer formatting and bullet points
  • Condensed geospatialQueryTool examples into single-line format for
    each category
  • Reorganized pre-configured responses section with bullet formatting
+27/-33 
task-manager.tsx
Refactor task manager prompt with clarity-first principle

lib/agents/task-manager.tsx

  • Replaced generic accuracy principles with focused "Exploration
    Efficiency Principles"
  • Introduced "Clarity First" principle emphasizing inquire option for
    ambiguous queries
  • Added "Proceed When Sufficient" principle for clear, specific queries
  • Expanded inquiry guidance section with specific geospatial query
    clarification requirements
  • Added concrete examples demonstrating when to proceed vs inquire
  • Improved formatting with bold headers and structured sections
+26/-16 

Summary by CodeRabbit

  • Enhancements

    • Task Manager prompt rewritten with explicit "proceed" vs "inquire" decisions and exploration-efficiency guidance (better geospatial/context handling).
    • UI now reveals the answer section earlier and appends tool results as they arrive.
  • Changes

    • System prompts selected dynamically and allow larger model responses (higher token limit).
    • Improved and clearer error messaging for tool execution failures.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Nov 21, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
qcx Ready Ready Preview Comment Nov 21, 2025 8:18am

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Nov 21, 2025

Warning

Rate limit exceeded

@ngoiyaeric has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 52 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between aa301fc and db1a02b.

📒 Files selected for processing (1)
  • lib/agents/researcher.tsx (1 hunks)

Walkthrough

Replaced hard-coded system prompts with a dynamic/default prompt in researcher, removed the mcp parameter, updated tool wiring and UI streaming/delta handling; rewrote the Task Manager system prompt to an explicit "proceed" vs "inquire" exploration-efficiency framework with geospatial guidance.

Changes

Cohort / File(s) Change Summary
Researcher — signature, prompts & tooling
lib/agents/researcher.tsx
Made dynamicSystemPrompt?: string the (optional) first parameter; removed mcp from signature and from getTools call; added getDefaultSystemPrompt(date) and use dynamicSystemPrompt ?? getDefaultSystemPrompt(currentDate); increased maxTokens (2500 → 4096); updated UI streaming flow (first-text-delta shows answer earlier, spinner removal), tightened tool-result handling and error messages, and append tool call results into assistant content.
Task Manager — prompt content & decision flow
lib/agents/task-manager.tsx
Replaced the agent system prompt with a concise Task Manager prompt that formalizes main actions ("proceed" vs "inquire"), adds "Exploration Efficiency Principles" with explicit geospatial guidance, restructures examples and decision guidance; no exported signatures changed.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant User
  participant TaskMgr as Task Manager Agent
  participant Researcher as Researcher Agent
  participant Tools as Tools/GeoTools
  Note over TaskMgr: Decision: "proceed" vs "inquire"
  User->>TaskMgr: submit query
  TaskMgr->>TaskMgr: evaluate clarity & geospatial needs
  alt inquire needed
    TaskMgr-->>User: ask clarifying questions ("inquire")
  else proceed
    TaskMgr->>Researcher: call researcher(dynamicSystemPrompt?, uiStream, streamText, messages, useSpecificModel?)
    Researcher->>Tools: invoke tools (getTools({ uiStream, fullResponse }))
    Tools-->>Researcher: tool results / errors
    Researcher-->>TaskMgr: assembled assistant message (includes tool results or Error: Tool execution failed.)
    TaskMgr-->>User: final response
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30 minutes

  • Pay extra attention to:
    • lib/agents/researcher.tsx — signature change impact, default prompt logic, token limit change, UI streaming/delta edge cases, and tool-result appending.
    • Call sites invoking researcher(...) elsewhere — parameter ordering and optional dynamicSystemPrompt.
    • getTools callsites and any expectations previously satisfied by mcp.

Possibly related PRs

Suggested reviewers

  • CharlieHelps

Poem

🐇 I nibble prompts and tidy flows,

"Proceed" or "inquire" — which path flows?
Tools at paw, answers neatly spun,
Tokens raised, default prompts begun,
A hop of joy — the changes done.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Feat: Improve prompting for exploration efficiency' directly and clearly summarizes the main change—restructuring system prompts in both researcher.tsx and task-manager.tsx to prioritize exploration efficiency.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@qodo-code-review
Copy link
Copy Markdown
Contributor

qodo-code-review Bot commented Nov 21, 2025

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status:
Action logging: The new prompt logic adds decision-making for "proceed" vs "inquire"
without adding any audit logging of these critical actions or their rationale.

Referred Code
    const result = await generateObject({
      model: getModel() as LanguageModel,
      system: `As a planet computer, your primary objective is to act as an efficient **Task Manager** for the user's query. Your goal is to minimize unnecessary steps and maximize the efficiency of the subsequent exploration phase (researcher agent).

	    You must first analyze the user's input and determine the optimal course of action. You have two options at your disposal:

	    **Exploration Efficiency Principles:**
	    - **Principle 1: Clarity First (Inquire):** If the query is ambiguous, lacks critical context (especially for geospatial tasks), or could be significantly narrowed down with a simple question, you MUST choose **"inquire"**. This prevents the researcher from wasting tokens and time on broad, inefficient searches.
	    - **Principle 2: Proceed When Sufficient:** If the query is clear, specific, and ready for immediate research, choose **"proceed"**.

	    **Options:**
	    1. **"proceed"**: Choose this if the query is specific enough for the researcher to start a focused exploration immediately.
	    2. **"inquire"**: Choose this if the query is too vague, broad, or requires essential missing parameters (like location, time, or specific metrics) to ensure an efficient and high-quality response.

	    **Inquiry Guidance (If "inquire" is chosen):**
	    - **Geospatial Queries:** If the query involves a location, you MUST clarify the following details to ensure the most efficient use of the 'geospatialQueryTool':
	        - **Location Specificity:** Ask for full addresses, landmark names, or precise coordinates.
	        - **Context:** Ask for time constraints ("during rush hour", "at 3 PM") or specific travel methods (driving, walking).
	        - **Output Format:** Ask for specific output formats when needed ("as a map image", "in JSON format").

	    **Examples for Efficiency:**


 ... (clipped 11 lines)

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
Missing fallback: The updated system prompt adds new decision paths but no additional error handling or
fallback if generateObject fails or returns unexpected schema output.

Referred Code
    const result = await generateObject({
      model: getModel() as LanguageModel,
      system: `As a planet computer, your primary objective is to act as an efficient **Task Manager** for the user's query. Your goal is to minimize unnecessary steps and maximize the efficiency of the subsequent exploration phase (researcher agent).

	    You must first analyze the user's input and determine the optimal course of action. You have two options at your disposal:

	    **Exploration Efficiency Principles:**
	    - **Principle 1: Clarity First (Inquire):** If the query is ambiguous, lacks critical context (especially for geospatial tasks), or could be significantly narrowed down with a simple question, you MUST choose **"inquire"**. This prevents the researcher from wasting tokens and time on broad, inefficient searches.
	    - **Principle 2: Proceed When Sufficient:** If the query is clear, specific, and ready for immediate research, choose **"proceed"**.

	    **Options:**
	    1. **"proceed"**: Choose this if the query is specific enough for the researcher to start a focused exploration immediately.
	    2. **"inquire"**: Choose this if the query is too vague, broad, or requires essential missing parameters (like location, time, or specific metrics) to ensure an efficient and high-quality response.

	    **Inquiry Guidance (If "inquire" is chosen):**
	    - **Geospatial Queries:** If the query involves a location, you MUST clarify the following details to ensure the most efficient use of the 'geospatialQueryTool':
	        - **Location Specificity:** Ask for full addresses, landmark names, or precise coordinates.
	        - **Context:** Ask for time constraints ("during rush hour", "at 3 PM") or specific travel methods (driving, walking).
	        - **Output Format:** Ask for specific output formats when needed ("as a map image", "in JSON format").

	    **Examples for Efficiency:**


 ... (clipped 11 lines)

Learn more about managing compliance generic rules or creating your own custom rules

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-code-review
Copy link
Copy Markdown
Contributor

qodo-code-review Bot commented Nov 21, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
High-level
Consider the trade-off of prompt rigidity

The new, highly prescriptive prompts improve efficiency but may reduce the
system's flexibility for handling novel or nuanced user requests. This trade-off
between efficiency and robustness should be considered.

Examples:

lib/agents/researcher.tsx [38]
2.  **Geospatial Priority:** For any query involving locations, places, addresses, geographical features, finding businesses, distances, or directions, you **MUST** use the 'geospatialQueryTool'. This is the most efficient way to handle location-based exploration.
lib/agents/task-manager.tsx [25]
	    - **Principle 1: Clarity First (Inquire):** If the query is ambiguous, lacks critical context (especially for geospatial tasks), or could be significantly narrowed down with a simple question, you MUST choose **"inquire"**. This prevents the researcher from wasting tokens and time on broad, inefficient searches.

Solution Walkthrough:

Before:

// lib/agents/task-manager.tsx
system: `As a planet computer, your primary objective is to fully comprehend the user's query...
You have two options at your disposal:
1. "proceed": If the provided information is sufficient...
2. "inquire": If you believe that additional information from the user would enhance your ability...

Your decision should be based on a careful assessment of the context, location and the potential for further information to improve the quality and relevance of your response.
...
Make your choice wisely to ensure that you fulfill your mission as a web researcher effectively...`

After:

// lib/agents/task-manager.tsx
system: `As a planet computer, your primary objective is to act as an efficient **Task Manager**...
**Exploration Efficiency Principles:**
- **Principle 1: Clarity First (Inquire):** If the query is ambiguous, lacks critical context ..., you MUST choose **"inquire"**. This prevents the researcher from wasting tokens and time...
- **Principle 2: Proceed When Sufficient:** If the query is clear, specific, and ready for immediate research, choose **"proceed"**.

**Inquiry Guidance (If "inquire" is chosen):**
- **Geospatial Queries:** If the query involves a location, you MUST clarify the following details...`
Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies a fundamental design trade-off in the PR: the increased prompt rigidity using MUST improves efficiency but may reduce flexibility for novel queries, which is a significant, high-level observation.

Medium
Possible issue
Clarify missing user location in prompt

Update the "Inquiry Guidance" in the system prompt to explicitly instruct the AI
to ask for the user's origin location for geospatial queries when it is missing
but required.

lib/agents/task-manager.tsx [32-36]

 	    **Inquiry Guidance (If "inquire" is chosen):**
 	    - **Geospatial Queries:** If the query involves a location, you MUST clarify the following details to ensure the most efficient use of the 'geospatialQueryTool':
-	        - **Location Specificity:** Ask for full addresses, landmark names, or precise coordinates.
+	        - **Origin Location:** If the query implies a starting point (e.g., "nearby", "directions from here"), ask for the user's current location if it's missing.
+	        - **Location Specificity:** Ask for full addresses, landmark names, or precise coordinates for destinations.
 	        - **Context:** Ask for time constraints ("during rush hour", "at 3 PM") or specific travel methods (driving, walking).
 	        - **Output Format:** Ask for specific output formats when needed ("as a map image", "in JSON format").
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies a missing but crucial piece of information (origin location) for geospatial queries, and adding it to the prompt will improve the agent's ability to gather necessary context.

Medium
Refine prompt to prevent unwanted quotes
Suggestion Impact:The commit updated the pre-configured responses section to use clean, consistent quoting and explicit Q→A mappings, reducing ambiguity. While it didn't use the exact "User asks/Your response" phrasing, it implemented the core intent by formatting exact prompts and responses with quotes and arrows.

code diff:

+**Pre-configured Responses:**
+- "What is a planet computer?" → "A planet computer is a proprietary environment aware system that interoperates Climate forecasting, mapping and scheduling using cutting edge multi-agents to streamline automation and exploration on a planet"
+- "What is QCX-Terra" → "QCX-Terra is a model garden of pixel level precision geospatial foundational models for efficient land prediction from satellite images"
+`

Refactor the pre-configured responses section of the prompt to use a clear "User
asks"/"Your response" format, removing inconsistent and ambiguous quotes to
ensure clean output.

lib/agents/researcher.tsx [57-60]

 **Pre-configured Responses (for efficiency):**
- When asked the following, respond accordingly:
- - 'What is a planet computer?' answer with the following: '"A planet computer is a proprietary environment aware system that interoperates Climate forecasting, mapping and scheduling using cutting edge multi-agents to streamline automation and exploration on a planet'
- - ‘What is QCX-Terra’ Respond with ‘QCX-Terra is a model garden of pixel level precision geospatial foundational models for efficient land prediction from satellite images’
+When asked one of the following, provide the exact response shown:
+- **User asks:** "What is a planet computer?"
+  **Your response:** "A planet computer is a proprietary environment aware system that interoperates Climate forecasting, mapping and scheduling using cutting edge multi-agents to streamline automation and exploration on a planet."
+- **User asks:** "What is QCX-Terra?"
+  **Your response:** "QCX-Terra is a model garden of pixel level precision geospatial foundational models for efficient land prediction from satellite images."

[Suggestion processed]

Suggestion importance[1-10]: 6

__

Why: The suggestion correctly identifies inconsistent quoting in the prompt that could lead to malformed LLM responses, and the proposed change improves the prompt's clarity and robustness.

Low
  • Update

Copy link
Copy Markdown

@charliecreates charliecreates Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, the new prompts are structurally clearer and better aligned with the stated goal of Exploration Efficiency, but there are a few issues worth addressing. In researcher.tsx, the pre-configured responses contain inconsistent/curly quotes and unclear string delimitation that could introduce ambiguity. In task-manager.tsx, the shift to efficiency-focused guidance omits the previous accuracy and uncertainty principles, which may unintentionally relax correctness guarantees. There is also a minor UX trade-off in how aggressively the task manager is instructed to "inquire" for broad queries, which may warrant slight tuning depending on product goals.

Additional notes (3)
  • Maintainability | lib/agents/researcher.tsx:32-41
    The new prompt uses Markdown-style bolding (**...**) and list formatting. Depending on how system is consumed by the model, this formatting might or might not be interpreted as intended. If the previous system prompts were plain text and the model configuration isn't explicitly optimized for Markdown instructions, there’s a small risk that the extra formatting noise slightly dilutes the actual behavioral instructions.

Given this is a core behavioral prompt for the researcher agent, it’s worth double‑checking that this style is consistent with other agent prompts and with how this model is usually steered in your system.

  • Maintainability | lib/agents/researcher.tsx:57-60
    The pre‑configured responses are now grouped under an efficiency section, but the actual wording appears unchanged, including some grammatical/quoting oddities and the description of "planet computer" as a "proprietary" system. If these responses are user‑visible marketing or product language, locking in this exact phrasing in a system prompt can make later copy changes harder and propagates any typos into all runs.

From a maintainability standpoint, this might be better centralized or referenced, rather than hard‑coded here, especially if other agents or surfaces need to answer these branded questions consistently.

  • Readability | lib/agents/task-manager.tsx:24-42
    The new Exploration Efficiency Principles and examples are clear, but there is an implicit bias toward choosing "inquire" for broad queries like "Tell me about the new AI model." This is likely desired for token efficiency, but it may degrade UX for users who expect a reasonable, generic overview without being interrogated.

If the product requirement is to minimize back-and-forth while still avoiding obviously wasteful searches, you might want to tune this example or the language to clarify that "inquire" is preferred only when the breadth would make the subsequent exploration substantially inefficient, not merely because the topic is broad.

Summary of changes

Summary of Changes

  • Updated the researcher agent's default system prompt to emphasize Exploration Efficiency, including directives for tool usage, geospatial priority, search specificity, concise responses, and citations.
  • Simplified and restructured the geospatial tool usage documentation into a more compact "Tool Usage Guide" with example query categories.
  • Added a Pre-configured Responses section for specific branded questions ("planet computer" and "QCX-Terra").
  • Rewrote the taskManager agent's system prompt to focus it as an efficient Task Manager, introducing Exploration Efficiency Principles, explicit guidance for choosing between proceed and inquire, and more concrete examples, especially for geospatial clarification.
  • Removed previous, more verbose data-accuracy/value principles from the taskManager prompt in favor of efficiency-oriented guidance.

Comment thread lib/agents/researcher.tsx Outdated
Comment on lines +57 to +60
**Pre-configured Responses (for efficiency):**
When asked the following, respond accordingly:
- 'What is a planet computer?' answer with the following: '"A planet computer is a proprietary environment aware system that interoperates Climate forecasting, mapping and scheduling using cutting edge multi-agents to streamline automation and exploration on a planet'
- ‘What is QCX-Terra’ Respond with ‘QCX-Terra is a model garden of pixel level precision geospatial foundational models for efficient land prediction from satellite images’
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new system prompt is significantly clearer and more structured, but there are a couple of minor issues that could affect robustness:

  1. Inconsistent quoting / smart quotes: The second pre-configured response uses a curly opening quote instead of a standard ASCII '. Depending on how prompts are serialized or post-processed, this can introduce subtle bugs or inconsistencies in matching literal user utterances.
  2. Unbalanced quotation in the first response: The answer string for "What is a planet computer?" starts with a double quote but does not clearly close it. That may confuse the model about where the quoted definition ends versus normal instruction text.

These are small, but cleaning them up will reduce ambiguity in the system message and make exact matching / prompt inspection easier.

Suggestion

Consider normalizing the quotes to standard ASCII and ensuring the definition strings are clearly delimited. For example:

When asked the following, respond accordingly:

  • What is a planet computer?"A planet computer is a proprietary environment-aware system that interoperates climate forecasting, mapping, and scheduling using cutting-edge multi-agents to streamline automation and exploration on a planet."
  • What is QCX-Terra?"QCX-Terra is a model garden of pixel-level precision geospatial foundational models for efficient land prediction from satellite images."

Reply with "@CharlieHelps yes please" if you'd like me to add a commit that normalizes the quotes and clearly delimits these canned responses.

Comment thread lib/agents/researcher.tsx Outdated
Comment on lines +49 to +53
**Examples of queries for 'geospatialQueryTool':**
Location Discovery: "Find coffee shops within walking distance of the Empire State Building"
Navigation & Travel: "Get driving directions from LAX to Hollywood with current traffic"
Visualization & Maps: "Create a map image showing the route from Golden Gate Bridge to Fisherman's Wharf"
Analysis & Planning: "Show me areas reachable within 30 minutes of downtown Portland by car"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The geospatial examples were significantly reduced compared to the original prompt (which covered discovery, navigation, visualization, analysis, and some more nuanced cases like travel time matrices and optimal routes). While the new list is more concise—which is good for efficiency—it may also remove useful priming for complex geospatial tasks the system is expected to handle.

If your user base frequently requests richer geospatial operations (e.g., multi‑point routing, travel time matrices, POI searches with constraints), the reduced examples might weaken the model’s tendency to use geospatialQueryTool for those patterns.

Suggestion

Consider re‑introducing one or two additional representative examples from the original prompt (e.g., a travel time matrix and an optimal route with multiple stops) while keeping the list concise. This preserves Exploration Efficiency but still gives the model good pattern coverage. Reply with "@CharlieHelps yes please" if you'd like me to add a commit that restores a couple of the higher‑value geospatial examples in a condensed form.

Comment on lines +20 to +45
system: `As a planet computer, your primary objective is to act as an efficient **Task Manager** for the user's query. Your goal is to minimize unnecessary steps and maximize the efficiency of the subsequent exploration phase (researcher agent).

You must first analyze the user's input and determine the optimal course of action. You have two options at your disposal:

**Exploration Efficiency Principles:**
- **Principle 1: Clarity First (Inquire):** If the query is ambiguous, lacks critical context (especially for geospatial tasks), or could be significantly narrowed down with a simple question, you MUST choose **"inquire"**. This prevents the researcher from wasting tokens and time on broad, inefficient searches.
- **Principle 2: Proceed When Sufficient:** If the query is clear, specific, and ready for immediate research, choose **"proceed"**.

**Options:**
1. **"proceed"**: Choose this if the query is specific enough for the researcher to start a focused exploration immediately.
2. **"inquire"**: Choose this if the query is too vague, broad, or requires essential missing parameters (like location, time, or specific metrics) to ensure an efficient and high-quality response.

**Inquiry Guidance (If "inquire" is chosen):**
- **Geospatial Queries:** If the query involves a location, you MUST clarify the following details to ensure the most efficient use of the 'geospatialQueryTool':
- **Location Specificity:** Ask for full addresses, landmark names, or precise coordinates.
- **Context:** Ask for time constraints ("during rush hour", "at 3 PM") or specific travel methods (driving, walking).
- **Output Format:** Ask for specific output formats when needed ("as a map image", "in JSON format").

**Examples for Efficiency:**
- **User:** "What are the latest news about the floods in India?" -> **Action:** "proceed" (Clear, ready for web search).
- **User:** "What's the warmest temperature in my area?" -> **Action:** "inquire" (Missing location and preferred metric).
- **User:** "Show me the nearest park." -> **Action:** "inquire" (Missing current location).
- **User:** "Tell me about the new AI model." -> **Action:** "inquire" (Too broad; ask for the model name or specific aspect).

Make your choice wisely to ensure that you fulfill your mission as an efficient Task Manager and deliver the most valuable assistance to the user.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new task manager prompt is much more focused on exploration efficiency and provides concrete guidance and examples, which is good. However, you removed all references to the previous accuracy, data-driven operations, and uncertainty transparency principles.

Given this agent decides whether to gather more info or proceed, dropping those principles entirely could implicitly relax standards around avoiding speculation and handling uncertainty, which may have been an intentional design constraint before.

If accuracy and non-speculation remain important system-level requirements, consider reincorporating a concise version of those principles, so the task manager does not favor efficiency at the expense of correctness.

Suggestion

You could append a short "Accuracy & Uncertainty" section to this prompt, preserving the spirit of the previous guidance without the verbosity, for example:

Accuracy & Uncertainty (Non-Negotiable):

  • Base decisions on verifiable information when available.
  • Avoid speculative assumptions; if critical information is missing, prefer "inquire".
  • When uncertainty is high, prioritize gathering clarifying details over proceeding with a guess.

Reply with "@CharlieHelps yes please" if you'd like me to add a commit that reintroduces a compact accuracy/uncertainty block into this system prompt.

@charliecreates charliecreates Bot removed the request for review from CharlieHelps November 21, 2025 07:14
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
lib/agents/task-manager.tsx (1)

8-16: Consider the implications of bypassing task manager for image inputs.

The logic automatically proceeds when an image is present, skipping any potential need for clarification. This could be problematic if the user's query accompanying the image is still vague or ambiguous (e.g., "What's in this image?" without specifying what aspect they're interested in, or geospatial queries with images that lack location context).

Consider whether certain image-based queries might still benefit from the inquiry flow, or at minimum, document this design decision and its trade-offs.

lib/agents/researcher.tsx (1)

70-75: Fix inconsistent indentation.

The indentation in this block is inconsistent, mixing different levels that don't align with the surrounding code structure. Lines 71-74 appear to be incorrectly indented relative to line 70.

Apply this diff to fix the indentation:

     tools: getTools({
-      uiStream,
-      fullResponse,
-      // mcp // mcp parameter is no longer passed to getTools
-    })
+       uiStream,
+       fullResponse,
+       // mcp // mcp parameter is no longer passed to getTools
+     })
   })
📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8718e4c and 6476bb8.

📒 Files selected for processing (2)
  • lib/agents/researcher.tsx (1 hunks)
  • lib/agents/task-manager.tsx (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
lib/agents/task-manager.tsx (1)
app/actions.tsx (1)
  • processEvents (287-419)
lib/agents/researcher.tsx (6)
lib/agents/writer.tsx (1)
  • writer (7-51)
lib/agents/tools/geospatial.tsx (2)
  • mcpClient (247-260)
  • params (220-336)
components/settings/components/settings.tsx (2)
  • fetchPrompt (81-86)
  • fetchPrompt (80-88)
lib/actions/chat.ts (1)
  • getSystemPrompt (239-254)
lib/agents/tools/index.tsx (1)
  • ToolProps (7-11)
components/settings/components/system-prompt-form.tsx (1)
  • SystemPromptForm (9-36)
🔇 Additional comments (2)
lib/agents/researcher.tsx (2)

32-61: Well-structured exploration efficiency directives.

The new system prompt provides clear, actionable guidance on tool usage with explicit prioritization of the geospatial tool for location-based queries. The pre-configured responses and examples improve efficiency and consistency.


14-21: Breaking API change successfully implemented across all call sites.

Verification confirms that the function signature change has been properly handled. The single call site at app/actions.tsx:327 passes all parameters in the correct order: currentSystemPrompt (mapped to the new dynamicSystemPrompt parameter), uiStream, streamText, messages, and useSpecificAPI. The mcp parameter has been correctly removed from the call.

Comment on lines +20 to +45
system: `As a planet computer, your primary objective is to act as an efficient **Task Manager** for the user's query. Your goal is to minimize unnecessary steps and maximize the efficiency of the subsequent exploration phase (researcher agent).

You must first analyze the user's input and determine the optimal course of action. You have two options at your disposal:

**Exploration Efficiency Principles:**
- **Principle 1: Clarity First (Inquire):** If the query is ambiguous, lacks critical context (especially for geospatial tasks), or could be significantly narrowed down with a simple question, you MUST choose **"inquire"**. This prevents the researcher from wasting tokens and time on broad, inefficient searches.
- **Principle 2: Proceed When Sufficient:** If the query is clear, specific, and ready for immediate research, choose **"proceed"**.

**Options:**
1. **"proceed"**: Choose this if the query is specific enough for the researcher to start a focused exploration immediately.
2. **"inquire"**: Choose this if the query is too vague, broad, or requires essential missing parameters (like location, time, or specific metrics) to ensure an efficient and high-quality response.

**Inquiry Guidance (If "inquire" is chosen):**
- **Geospatial Queries:** If the query involves a location, you MUST clarify the following details to ensure the most efficient use of the 'geospatialQueryTool':
- **Location Specificity:** Ask for full addresses, landmark names, or precise coordinates.
- **Context:** Ask for time constraints ("during rush hour", "at 3 PM") or specific travel methods (driving, walking).
- **Output Format:** Ask for specific output formats when needed ("as a map image", "in JSON format").

**Examples for Efficiency:**
- **User:** "What are the latest news about the floods in India?" -> **Action:** "proceed" (Clear, ready for web search).
- **User:** "What's the warmest temperature in my area?" -> **Action:** "inquire" (Missing location and preferred metric).
- **User:** "Show me the nearest park." -> **Action:** "inquire" (Missing current location).
- **User:** "Tell me about the new AI model." -> **Action:** "inquire" (Too broad; ask for the model name or specific aspect).

Make your choice wisely to ensure that you fulfill your mission as an efficient Task Manager and deliver the most valuable assistance to the user.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix inconsistent indentation: mixed tabs and spaces.

The system prompt uses inconsistent indentation with tabs starting at line 22 (and continuing through the block), while line 20 uses spaces. This can cause issues with code formatting tools and reduces readability.

Apply this diff to standardize indentation (using spaces):

-      system: `As a planet computer, your primary objective is to act as an efficient **Task Manager** for the user's query. Your goal is to minimize unnecessary steps and maximize the efficiency of the subsequent exploration phase (researcher agent).
-
-	    You must first analyze the user's input and determine the optimal course of action. You have two options at your disposal:
-
-	    **Exploration Efficiency Principles:**
-	    - **Principle 1: Clarity First (Inquire):** If the query is ambiguous, lacks critical context (especially for geospatial tasks), or could be significantly narrowed down with a simple question, you MUST choose **"inquire"**. This prevents the researcher from wasting tokens and time on broad, inefficient searches.
-	    - **Principle 2: Proceed When Sufficient:** If the query is clear, specific, and ready for immediate research, choose **"proceed"**.
-
-	    **Options:**
-	    1. **"proceed"**: Choose this if the query is specific enough for the researcher to start a focused exploration immediately.
-	    2. **"inquire"**: Choose this if the query is too vague, broad, or requires essential missing parameters (like location, time, or specific metrics) to ensure an efficient and high-quality response.
-
-	    **Inquiry Guidance (If "inquire" is chosen):**
-	    - **Geospatial Queries:** If the query involves a location, you MUST clarify the following details to ensure the most efficient use of the 'geospatialQueryTool':
-	        - **Location Specificity:** Ask for full addresses, landmark names, or precise coordinates.
-	        - **Context:** Ask for time constraints ("during rush hour", "at 3 PM") or specific travel methods (driving, walking).
-	        - **Output Format:** Ask for specific output formats when needed ("as a map image", "in JSON format").
-
-	    **Examples for Efficiency:**
-	    - **User:** "What are the latest news about the floods in India?" -> **Action:** "proceed" (Clear, ready for web search).
-	    - **User:** "What's the warmest temperature in my area?" -> **Action:** "inquire" (Missing location and preferred metric).
-	    - **User:** "Show me the nearest park." -> **Action:** "inquire" (Missing current location).
-	    - **User:** "Tell me about the new AI model." -> **Action:** "inquire" (Too broad; ask for the model name or specific aspect).
-
-	    Make your choice wisely to ensure that you fulfill your mission as an efficient Task Manager and deliver the most valuable assistance to the user.
-
+      system: `As a planet computer, your primary objective is to act as an efficient **Task Manager** for the user's query. Your goal is to minimize unnecessary steps and maximize the efficiency of the subsequent exploration phase (researcher agent).
+
+      You must first analyze the user's input and determine the optimal course of action. You have two options at your disposal:
+
+      **Exploration Efficiency Principles:**
+      - **Principle 1: Clarity First (Inquire):** If the query is ambiguous, lacks critical context (especially for geospatial tasks), or could be significantly narrowed down with a simple question, you MUST choose **"inquire"**. This prevents the researcher from wasting tokens and time on broad, inefficient searches.
+      - **Principle 2: Proceed When Sufficient:** If the query is clear, specific, and ready for immediate research, choose **"proceed"**.
+
+      **Options:**
+      1. **"proceed"**: Choose this if the query is specific enough for the researcher to start a focused exploration immediately.
+      2. **"inquire"**: Choose this if the query is too vague, broad, or requires essential missing parameters (like location, time, or specific metrics) to ensure an efficient and high-quality response.
+
+      **Inquiry Guidance (If "inquire" is chosen):**
+      - **Geospatial Queries:** If the query involves a location, you MUST clarify the following details to ensure the most efficient use of the 'geospatialQueryTool':
+          - **Location Specificity:** Ask for full addresses, landmark names, or precise coordinates.
+          - **Context:** Ask for time constraints ("during rush hour", "at 3 PM") or specific travel methods (driving, walking).
+          - **Output Format:** Ask for specific output formats when needed ("as a map image", "in JSON format").
+
+      **Examples for Efficiency:**
+      - **User:** "What are the latest news about the floods in India?" -> **Action:** "proceed" (Clear, ready for web search).
+      - **User:** "What's the warmest temperature in my area?" -> **Action:** "inquire" (Missing location and preferred metric).
+      - **User:** "Show me the nearest park." -> **Action:** "inquire" (Missing current location).
+      - **User:** "Tell me about the new AI model." -> **Action:** "inquire" (Too broad; ask for the model name or specific aspect).
+
+      Make your choice wisely to ensure that you fulfill your mission as an efficient Task Manager and deliver the most valuable assistance to the user.
+
     `,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
system: `As a planet computer, your primary objective is to act as an efficient **Task Manager** for the user's query. Your goal is to minimize unnecessary steps and maximize the efficiency of the subsequent exploration phase (researcher agent).
You must first analyze the user's input and determine the optimal course of action. You have two options at your disposal:
**Exploration Efficiency Principles:**
- **Principle 1: Clarity First (Inquire):** If the query is ambiguous, lacks critical context (especially for geospatial tasks), or could be significantly narrowed down with a simple question, you MUST choose **"inquire"**. This prevents the researcher from wasting tokens and time on broad, inefficient searches.
- **Principle 2: Proceed When Sufficient:** If the query is clear, specific, and ready for immediate research, choose **"proceed"**.
**Options:**
1. **"proceed"**: Choose this if the query is specific enough for the researcher to start a focused exploration immediately.
2. **"inquire"**: Choose this if the query is too vague, broad, or requires essential missing parameters (like location, time, or specific metrics) to ensure an efficient and high-quality response.
**Inquiry Guidance (If "inquire" is chosen):**
- **Geospatial Queries:** If the query involves a location, you MUST clarify the following details to ensure the most efficient use of the 'geospatialQueryTool':
- **Location Specificity:** Ask for full addresses, landmark names, or precise coordinates.
- **Context:** Ask for time constraints ("during rush hour", "at 3 PM") or specific travel methods (driving, walking).
- **Output Format:** Ask for specific output formats when needed ("as a map image", "in JSON format").
**Examples for Efficiency:**
- **User:** "What are the latest news about the floods in India?" -> **Action:** "proceed" (Clear, ready for web search).
- **User:** "What's the warmest temperature in my area?" -> **Action:** "inquire" (Missing location and preferred metric).
- **User:** "Show me the nearest park." -> **Action:** "inquire" (Missing current location).
- **User:** "Tell me about the new AI model." -> **Action:** "inquire" (Too broad; ask for the model name or specific aspect).
Make your choice wisely to ensure that you fulfill your mission as an efficient Task Manager and deliver the most valuable assistance to the user.
system: `As a planet computer, your primary objective is to act as an efficient **Task Manager** for the user's query. Your goal is to minimize unnecessary steps and maximize the efficiency of the subsequent exploration phase (researcher agent).
You must first analyze the user's input and determine the optimal course of action. You have two options at your disposal:
**Exploration Efficiency Principles:**
- **Principle 1: Clarity First (Inquire):** If the query is ambiguous, lacks critical context (especially for geospatial tasks), or could be significantly narrowed down with a simple question, you MUST choose **"inquire"**. This prevents the researcher from wasting tokens and time on broad, inefficient searches.
- **Principle 2: Proceed When Sufficient:** If the query is clear, specific, and ready for immediate research, choose **"proceed"**.
**Options:**
1. **"proceed"**: Choose this if the query is specific enough for the researcher to start a focused exploration immediately.
2. **"inquire"**: Choose this if the query is too vague, broad, or requires essential missing parameters (like location, time, or specific metrics) to ensure an efficient and high-quality response.
**Inquiry Guidance (If "inquire" is chosen):**
- **Geospatial Queries:** If the query involves a location, you MUST clarify the following details to ensure the most efficient use of the 'geospatialQueryTool':
- **Location Specificity:** Ask for full addresses, landmark names, or precise coordinates.
- **Context:** Ask for time constraints ("during rush hour", "at 3 PM") or specific travel methods (driving, walking).
- **Output Format:** Ask for specific output formats when needed ("as a map image", "in JSON format").
**Examples for Efficiency:**
- **User:** "What are the latest news about the floods in India?" -> **Action:** "proceed" (Clear, ready for web search).
- **User:** "What's the warmest temperature in my area?" -> **Action:** "inquire" (Missing location and preferred metric).
- **User:** "Show me the nearest park." -> **Action:** "inquire" (Missing current location).
- **User:** "Tell me about the new AI model." -> **Action:** "inquire" (Too broad; ask for the model name or specific aspect).
Make your choice wisely to ensure that you fulfill your mission as an efficient Task Manager and deliver the most valuable assistance to the user.
`,
🤖 Prompt for AI Agents
lib/agents/task-manager.tsx lines 20-45: the system prompt block mixes tabs and
spaces (tabs start at line ~22) causing inconsistent indentation; normalize the
block to use spaces only (convert all leading tabs within the prompt to spaces,
match existing indentation width used on line 20, and ensure aligned
bullet/paragraph indentation) so formatting tools and editors see a consistent
indentation style.

Refactor researcher function to improve system prompt handling and update tool usage guidelines.
@ngoiyaeric
Copy link
Copy Markdown
Collaborator Author

@coderabbitai the system is not returning real time information from the current news and date

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Nov 21, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Read the researcher.tsx file to see the new system prompt
cat lib/agents/researcher.tsx

Length of output: 5676


🏁 Script executed:

#!/bin/bash
# Read the task-manager.tsx file to see the new system prompt
cat lib/agents/task-manager.tsx

Length of output: 3438


🏁 Script executed:

#!/bin/bash
# Search for date/time related tools or functions in the codebase
rg -n "getTime|getDate|currentDate|getCurrentTime" --type ts --type tsx -g '!node_modules/**' -C 2

Length of output: 27


🏁 Script executed:

#!/bin/bash
# Look for news or real-time data fetching tools
rg -n "news|realtime|real-time|current.*information" --type ts --type tsx -g '!node_modules/**' -g '**/tools/**' -C 2

Length of output: 27


🏁 Script executed:

#!/bin/bash
# Find the tools file to understand available tools
fd -e ts -e tsx "tools" lib/agents/ --exec cat {}

Length of output: 0


🏁 Script executed:

#!/bin/bash
# Search for date/time related code without type filtering
rg -n "getTime|getDate|currentDate|getCurrentTime|new Date" lib/agents/ -C 2

Length of output: 1383


🏁 Script executed:

#!/bin/bash
# Look for search tool implementation
rg -n "search.*tool|tavily|serper" lib/ -C 2

Length of output: 5380


🏁 Script executed:

#!/bin/bash
# Check for any tool definitions
fd -e ts -e tsx . lib/agents/ --exec basename {}

Length of output: 172


🏁 Script executed:

#!/bin/bash
# Read the tools index file to see how tools are exported
cat lib/agents/tools/index.tsx

Length of output: 1025


🏁 Script executed:

#!/bin/bash
# Check the search tool implementation for any issues
cat lib/agents/tools/search.tsx

Length of output: 2545


🏁 Script executed:

#!/bin/bash
# Look for environment variables configuration
fd -e env -e example . --max-depth 2 --exec cat {}

Length of output: 0


🏁 Script executed:

#!/bin/bash
# Check if there's a config file or documentation about API keys
rg -n "TAVILY.*KEY|API.*KEY" --type md --type txt -C 2

Length of output: 346


@ngoiyaeric I've analyzed the code and identified the likely issue. The system does have access to the current date and the search tool for real-time information, but the new prompt may not be enforcing tool usage strongly enough for news and current events.

The Issue

Looking at the new researcher.tsx prompt, I can see:

  1. ✅ Current date IS provided: Current date and time: ${date}
  2. ✅ Search tool IS mentioned for "current events, news"
  3. BUT unlike geospatial queries which have strong enforcement ("MUST use", "mandatory", "no exceptions"), news/current events only have weak guidance ("When to use")
  4. ❌ Directive Chat: Move all the chat UI to The Left Side of The Webpage #4 says: "When tools are not needed, provide direct, helpful answers based on your knowledge" - This might cause the LLM to answer from its training data instead of searching

Compare:

  • Geospatial: "MUST be used (no exceptions)"
  • News/Current Events: Just listed under "When to use"

Recommended Fix

Update the researcher.tsx prompt to add mandatory enforcement for real-time queries:

const getDefaultSystemPrompt = (date: string) => raw`
As a comprehensive AI assistant, your primary directive is **Exploration Efficiency**. You must use the provided tools judiciously to gather information and formulate a response.

Current date and time: ${date}.

**Exploration Efficiency Directives:**
1. **Tool First:** Always check if a tool can directly or partially answer the user's query. Use the most specific tool available.
2. **Geospatial Priority:** For any query involving locations, places, addresses, geographical features, finding businesses, distances, or directions → you **MUST** use the 'geospatialQueryTool'.
3. **Real-Time Data Priority:** For any query about current events, news, recent developments, today's date, weather, or time-sensitive information → you **MUST** use the 'search' tool. Never rely on training data for current information.
4. **Search Specificity:** When using the 'search' tool, formulate queries that are as specific as possible.
5. **Concise Response:** When tools are not needed AND the query doesn't require real-time data, provide direct, helpful answers based on your knowledge. Match the user's language.
6. **Citations:** Always cite source URLs when using information from tools.

### **Tool Usage Guidelines (Mandatory)**

#### **1. General Web Search (MANDATORY for Real-Time Data)**
- **Tool**: \`search\`
- **MUST use for**:  
  • Current events, breaking news, recent developments
  • Today's date, current time, weather conditions
  • Latest statistics, prices, versions, or trending topics
  • Any information that changes frequently (stock prices, sports scores, etc.)
- **When to use**:  
  Any query requiring up-to-date factual information or general knowledge.
- **Do NOT use** \`retrieve\` for URLs discovered via search results.

**Examples that REQUIRE \`search\`:**
- "What's the latest news about AI?"
- "Current weather in London"
- "What happened today in sports?"
- "Latest version of React"
- "Recent floods in India"

Additional Check

Can you verify that TAVILY_API_KEY is properly set in your environment? Run:

Would you like me to help you update the prompt with these changes, or would you prefer to test the API key first?


🏁 Script executed:

#!/bin/bash
# Check if TAVILY_API_KEY is configured (without revealing the key)
if [ -z "$TAVILY_API_KEY" ]; then
  echo "❌ TAVILY_API_KEY is NOT set"
else
  echo "✅ TAVILY_API_KEY is configured"
  echo "Key length: ${#TAVILY_API_KEY} characters"
fi

Length of output: 27


@ngoiyaeric Found the root cause! 🎯

❌ Missing API Key

The TAVILY_API_KEY is not configured in your environment. This is why the system cannot retrieve real-time news and current information. The search tool requires this API key to function.

How to Fix

Step 1: Get a Tavily API Key

  1. Go to https://app.tavily.com/home
  2. Sign up for a free account
  3. Copy your API key

Step 2: Configure the Environment Variable

Add the key to your .env.local file (or equivalent):

# Tavily API Key retrieved here: https://app.tavily.com/home
TAVILY_API_KEY=your_actual_key_here

Step 3: Restart Your Application

After adding the key, restart your development server or deployment for the changes to take effect.

Additional Recommendation

Even with the API key configured, I'd still recommend strengthening the prompt to enforce tool usage for real-time queries (as I suggested above). The current prompt doesn't mandate using the search tool for news/current events the same way it mandates using the geospatial tool for location queries.

Would you like me to help you create an updated version of the researcher.tsx file with both:

  1. Stronger enforcement for real-time data queries
  2. Better examples showing when the search tool must be used?

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c6e4886 and d5351b0.

📒 Files selected for processing (1)
  • lib/agents/researcher.tsx (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
lib/agents/researcher.tsx (2)
lib/utils/index.ts (1)
  • getModel (19-62)
lib/agents/tools/index.tsx (1)
  • getTools (14-39)
🔇 Additional comments (5)
lib/agents/researcher.tsx (5)

8-8: Clear alias for stable streamText API

Aliasing streamText to nonexperimental_streamText makes the migration away from the experimental API explicit at the call site; no issues here.


15-75: Default system prompt cleanly encodes Exploration Efficiency behavior

The new getDefaultSystemPrompt is well-structured, clearly prioritizes tool usage (especially geospatialQueryTool), and the pre-configured responses now have balanced, ASCII quotes. From a code and prompt-structure standpoint, this looks solid.


99-105: Confirm maxTokens: 4096 is safe for all possible models returned by getModel()

Since getModel() may resolve to different backends (xAI Grok, Bedrock, or OpenAI), a hard-coded maxTokens: 4096 could exceed some providers’ maximum output token limits or recommended caps. Please double-check this value against the actual models you use, or consider driving it from configuration per provider to avoid runtime errors or silent truncation.


112-133: Streaming and answer-section timing improvements look good

Showing the answerSection on the first non-empty text-delta, and on the first tool-result when not using a specific model, should improve perceived latency while avoiding an empty response shell. The accumulation of toolCalls/toolResponses in parallel also keeps the streaming loop straightforward.


143-150: Conversation state updates correctly preserve tool context

Pushing an assistant message that includes the accumulated text plus toolCalls, and then a separate tool message containing toolResponses when present, aligns well with a tools-first chat loop and should keep subsequent turns correctly grounded in prior tool usage.

Comment thread lib/agents/researcher.tsx
Comment thread lib/agents/researcher.tsx
Comment on lines 136 to 139
case 'error':
hasError = true
fullResponse += `\nError occurred while executing the tool`
fullResponse += `\n\nError: Tool execution failed.`
break
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Error message is not propagated to the streamed UI

In the 'error' case you append Error: Tool execution failed. to fullResponse but never call streamText.update(fullResponse), so the user-visible BotMessage will not reflect the error text even though hasError is set.

Recommend updating streamText here as well:

      case 'error':
        hasError = true
-        fullResponse += `\n\nError: Tool execution failed.`
+        fullResponse += `\n\nError: Tool execution failed.`
+        streamText.update(fullResponse)
        break

This keeps the UI and the accumulated response string in sync when tools fail.

🤖 Prompt for AI Agents
In lib/agents/researcher.tsx around lines 136-139, the 'error' branch appends
"Error: Tool execution failed." to fullResponse and sets hasError but never
updates the streamed UI; call streamText.update(fullResponse) after appending
the error (before the break) so the BotMessage receives the updated error text
and the streamed UI stays in sync with the accumulated response.

Changed dynamicSystemPrompt from optional to required.
@ngoiyaeric ngoiyaeric merged commit 13b890e into main Nov 21, 2025
3 checks passed
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (2)
lib/agents/researcher.tsx (2)

128-139: Surface tool errors in the streamed answer text, not only via hasError

You now set hasError in two places:

  • When a tool-result arrives without delta.result.
  • When an 'error' delta is emitted, appending Error: Tool execution failed. to fullResponse.

But in neither case is the updated fullResponse pushed to the user-visible stream. As a result, the BotMessage will typically never show the error text; only the returned hasError flag is set, which is easy for the UI to ignore.

This is essentially the same issue previously flagged on the 'error' branch, and it now also applies to the new !delta.result path.

Consider updating streamText whenever you append error text so the user actually sees it:

      case 'tool-result':
-        if (!useSpecificModel && toolResponses.length === 0 && delta.result) {
-          uiStream.append(answerSection)
-        }
-        if (!delta.result) hasError = true
+        if (!useSpecificModel && toolResponses.length === 0 && delta.result) {
+          uiStream.append(answerSection)
+        }
+        if (!delta.result) {
+          hasError = true
+          fullResponse += `\n\nError: Tool returned no result.`
+          streamText.update(fullResponse)
+        }
        toolResponses.push(delta)
        break

      case 'error':
        hasError = true
-        fullResponse += `\n\nError: Tool execution failed.`
+        fullResponse += `\n\nError: Tool execution failed.`
+        streamText.update(fullResponse)
        break

This keeps the streamed UI, fullResponse, and hasError aligned so tool failures are visible to end users.


71-74: Normalize pre‑configured questions for clearer matching

The pre‑configured responses now use plain ASCII quotes, which is good. One small polish item:

  • The second question string omits the trailing ? and both questions could be formatted consistently as literal prompts.

To make matching more robust and easier to inspect, consider:

-**Pre-configured Responses:**
-- "What is a planet computer?" → "A planet computer is a proprietary environment aware system that interoperates Climate forecasting, mapping and scheduling using cutting edge multi-agents to streamline automation and exploration on a planet"
-- "What is QCX-Terra" → "QCX-Terra is a model garden of pixel level precision geospatial foundational models for efficient land prediction from satellite images"
+**Pre-configured Responses:**
+- `What is a planet computer?` → "A planet computer is a proprietary environment aware system that interoperates climate forecasting, mapping, and scheduling using cutting-edge multi-agents to streamline automation and exploration on a planet."
+- `What is QCX-Terra?` → "QCX-Terra is a model garden of pixel-level-precision geospatial foundational models for efficient land prediction from satellite images."

(You can keep or drop the grammar tweaks as you prefer; the key part is consistent, clearly delimited question strings.)

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d5351b0 and aa301fc.

📒 Files selected for processing (1)
  • lib/agents/researcher.tsx (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
lib/agents/researcher.tsx (3)
components/message.tsx (1)
  • BotMessage (11-31)
lib/utils/index.ts (1)
  • getModel (19-62)
lib/agents/tools/index.tsx (2)
  • getTools (14-39)
  • ToolProps (7-11)
🔇 Additional comments (2)
lib/agents/researcher.tsx (2)

8-9: Alias import avoids name clash with streamText param

Renaming the imported streamText to nonexperimental_streamText cleanly avoids shadowing the streamText function parameter and keeps call sites unambiguous. No issues here.


76-105: Dynamic system prompt handling and stream setup look solid

Making dynamicSystemPrompt optional and falling back to getDefaultSystemPrompt(currentDate) only when it’s missing or all‑whitespace aligns the type with runtime behavior and simplifies callers. The nonexperimental_streamText invocation with getModel() as the LanguageModel, the increased maxTokens: 4096, and the wiring of tools: getTools({ uiStream, fullResponse }) also look consistent with the surrounding code and the updated tools API.

Comment thread lib/agents/researcher.tsx
Comment on lines +18 to +70
const getDefaultSystemPrompt = (date: string) => raw`
As a comprehensive AI assistant, your primary directive is **Exploration Efficiency**. You must use the provided tools judiciously to gather information and formulate a response.

Current date and time: ${date}.

**Exploration Efficiency Directives:**
1. **Tool First:** Always check if a tool can directly or partially answer the user's query. Use the most specific tool available.
2. **Geospatial Priority:** For any query involving locations, places, addresses, geographical features, finding businesses, distances, or directions → you **MUST** use the 'geospatialQueryTool'.
3. **Search Specificity:** When using the 'search' tool, formulate queries that are as specific as possible.
4. **Concise Response:** When tools are not needed, provide direct, helpful answers based on your knowledge. Match the user's language.
5. **Citations:** Always cite source URLs when using information from tools.

### **Tool Usage Guidelines (Mandatory)**

#### **1. General Web Search**
- **Tool**: \`search\`
- **When to use**:
Any query requiring up-to-date factual information, current events, statistics, product details, news, or general knowledge.
- **Do NOT use** \`retrieve\` for URLs discovered via search results.

#### **2. Fetching Specific Web Pages**
- **Tool**: \`retrieve\`
- **When to use**:
ONLY when the user explicitly provides one or more URLs and asks you to read, summarize, or extract content from them.
- **Never use** this tool proactively.

#### **3. Location, Geography, Navigation, and Mapping Queries**
- **Tool**: \`geospatialQueryTool\` → **MUST be used (no exceptions)** for:
• Finding places, businesses, "near me", distances, directions
• Travel times, routes, traffic, map generation
• Isochrones, travel-time matrices, multi-stop optimization

**Examples that trigger \`geospatialQueryTool\`:**
- “Coffee shops within 500 m of the Eiffel Tower”
- “Driving directions from LAX to Hollywood with current traffic”
- “Show me a map of museums in Paris”
- “How long to walk from Central Park to Times Square?”
- “Areas reachable in 30 minutes from downtown Portland”

**Behavior when using \`geospatialQueryTool\`:**
- Issue the tool call immediately
- In your final response: provide concise text only
- → NEVER say “the map will update” or “markers are being added”
- → Trust the system handles map rendering automatically

#### **Summary of Decision Flow**
1. User gave explicit URLs? → \`retrieve\`
2. Location/distance/direction/maps? → \`geospatialQueryTool\` (mandatory)
3. Everything else needing external data? → \`search\`
4. Otherwise → answer from knowledge

These rules override all previous instructions.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Tighten search vs. knowledge rules to reliably handle real‑time queries

The new default system prompt is much clearer and enforces geospatial tool usage well. However, the combination of:

  • Directive 4 (“When tools are not needed, provide direct, helpful answers based on your knowledge”), and
  • The “General Web Search” section that doesn’t explicitly require search for current events/news,

still leaves room for the model to answer time‑sensitive questions from training data instead of calling search. That means the original “no real‑time info” symptom can still appear even once TAVILY_API_KEY is configured.

I’d recommend explicitly making search mandatory for time‑sensitive topics and narrowing when “tools are not needed,” for example:

-4. **Concise Response:** When tools are not needed, provide direct, helpful answers based on your knowledge. Match the user's language.
+4. **Concise Response:** Only answer directly from your knowledge when the question is clearly time-insensitive and does not require external or up-to-date data (e.g., math, stable scientific facts, definitions). Match the user's language.

-#### **1. General Web Search**
- - **Tool**: `search`
- - **When to use**:  
-   Any query requiring up-to-date factual information, current events, statistics, product details, news, or general knowledge.
+#### **1. General Web Search**
+- **Tool**: `search`
+- **When to use**:  
+  For any query involving current events, news, changing prices/schedules, or other information that may have changed recently, you **MUST** call `search` at least once before answering.  
+  For other queries, prefer `search` when the user explicitly asks you to look things up on the web (e.g., “search online”, “check the latest”, “look this up for me”).

This keeps Exploration Efficiency while ensuring real‑time questions reliably hit the web instead of stale training data.

🤖 Prompt for AI Agents
In lib/agents/researcher.tsx around lines 18 to 70, tighten the system prompt so
time‑sensitive queries always trigger the search tool: change Directive 4 to
restrict “When tools are not needed” to only non‑time‑sensitive, general
knowledge (e.g., definitions, static facts) and add an explicit mandatory rule
in the General Web Search section that any time‑sensitive topics (current
events, news, launch dates, real‑time statistics, market prices, weather,
traffic, etc.) must use `search`; also update the decision flow to check “Is
this time‑sensitive?” → `search` before falling back to knowledge, and ensure
the geospatial mandatory rule remains unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant