-
-
Couldn't load subscription status.
- Fork 6
I've made a commit that refines how I handle your requests, aiming to… #209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
… provide more comprehensive and complete responses. Specifically, I will now aim to: - Provide more detailed answers. - Conduct more thorough research. - Be more cautious about proceeding if I don't have enough information from you. Please note: I wasn't able to test these changes by running the application, as the build process was blocked by missing environment variables.
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughUpdates default system prompts for researcher and task-manager agents; adds a new Changes
Sequence Diagram(s)sequenceDiagram
actor Caller
participant Writer as writer(dynamicSystemPrompt, uiStream, streamText, messages)
participant Model
Caller->>Writer: Call writer(messages, dynamicSystemPrompt?)
alt dynamicSystemPrompt provided
Writer->>Writer: systemToUse = dynamicSystemPrompt
else
Writer->>Writer: systemToUse = defaultWriterPrompt
end
Writer->>Model: Send systemToUse + messages (streaming)
Model-->>Writer: Streamed tokens
Writer-->>Caller: UI stream + text stream
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
|
|
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||||||
There was a problem hiding this 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
🔭 Outside diff range comments (3)
lib/agents/researcher.tsx (2)
14-21: Breaking API change to researcher(...) will likely break all call-sitesYou added a new first parameter (dynamicSystemPrompt) and shifted the rest, which is a breaking change. Any existing calls using the original signature will now compile or run incorrectly. Recommend keeping backward compatibility by moving dynamicSystemPrompt to the end as an optional parameter.
Apply this diff to restore compatibility:
-export async function researcher( - dynamicSystemPrompt: string, // New parameter - uiStream: ReturnType<typeof createStreamableUI>, - streamText: ReturnType<typeof createStreamableValue<string>>, - messages: CoreMessage[], - // mcp: any, // Removed mcp parameter - useSpecificModel?: boolean -) { +export async function researcher( + uiStream: ReturnType<typeof createStreamableUI>, + streamText: ReturnType<typeof createStreamableValue<string>>, + messages: CoreMessage[], + // mcp: any, // Removed mcp parameter + useSpecificModel?: boolean, + dynamicSystemPrompt?: string +) {
51-51: Guard against runtime TypeError on .trim()If a non-string accidentally reaches dynamicSystemPrompt (e.g., from legacy call sites), calling .trim() will throw. Guard with a typeof check.
- const systemToUse = dynamicSystemPrompt && dynamicSystemPrompt.trim() !== '' ? dynamicSystemPrompt : default_system_prompt; + const systemToUse = + typeof dynamicSystemPrompt === 'string' && dynamicSystemPrompt.trim() !== '' + ? dynamicSystemPrompt + : default_system_prompt;lib/agents/writer.tsx (1)
7-12: Breaking API change to writer(...) — keep backward compatibilityMoving dynamicSystemPrompt to the first parameter breaks existing call sites. Recommend making it an optional last parameter to preserve the original signature.
-export async function writer( - dynamicSystemPrompt: string, // New parameter - uiStream: ReturnType<typeof createStreamableUI>, - streamText: ReturnType<typeof createStreamableValue<string>>, - messages: CoreMessage[] -) { +export async function writer( + uiStream: ReturnType<typeof createStreamableUI>, + streamText: ReturnType<typeof createStreamableValue<string>>, + messages: CoreMessage[], + dynamicSystemPrompt?: string +) {
🧹 Nitpick comments (2)
lib/agents/researcher.tsx (1)
53-64: Harden stream initialization with try/catchnonexperimental_streamText can throw before the event stream begins. Fail gracefully and avoid leaving the UI in a loading state.
- const result = await nonexperimental_streamText({ - model: getModel() as LanguageModel, - maxTokens: 2500, - system: systemToUse, // Use the dynamic or default system prompt - messages, - tools: getTools({ - uiStream, - fullResponse, - // mcp // mcp parameter is no longer passed to getTools - }) - }) + let result + try { + result = await nonexperimental_streamText({ + model: getModel() as LanguageModel, + maxTokens: 2500, + system: systemToUse, // Use the dynamic or default system prompt + messages, + tools: getTools({ + uiStream, + fullResponse + }) + }) + } catch (e) { + hasError = true + uiStream.update(null) + const msg = 'Error initializing the model request.' + fullResponse += `\n${msg}` + streamText.update(fullResponse) + return { result: null as any, fullResponse, hasError, toolResponses: [] } + }lib/agents/writer.tsx (1)
22-38: Prompt constraint could over-restrict the writerThe writer doesn’t have tool access and relies on upstream-provided results via messages. If those are incomplete, “based exclusively on the provided search results” may force low-value answers. Suggest allowing the writer to explicitly call out missing info and recommend another research pass.
const default_system_prompt = `As a professional writer, your primary goal is to provide a comprehensive and informative answer to the user's question, based exclusively on the provided search results (URL and content). Your responsibilities include: @@ - If the search results include relevant images, incorporate them into your response using Markdown format. - Match the language of your response to the user's language. +If the provided search results are incomplete or insufficient to fully answer the user's question, explicitly state what is missing and recommend running another research pass to fill the gaps. + Your final output should be a detailed and well-supported answer that fully resolves the user's query, leaving no stone unturned. Please use Markdown format for your response. - Link format: [link text](url) - Image format:  `;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
lib/agents/researcher.tsx(1 hunks)lib/agents/task-manager.tsx(1 hunks)lib/agents/writer.tsx(1 hunks)
🔇 Additional comments (5)
lib/agents/task-manager.tsx (1)
17-17: Reinforcing “inquire” bias in the system prompt — LGTMClear, concise guidance that aligns with the PR goal of being cautious with insufficient info.
lib/agents/researcher.tsx (3)
46-47: Depth-oriented research guidance — LGTMThe additions strengthen completeness and reduce superficial outputs while staying consistent with tool usage guidance.
14-21: PR summary inconsistency: researcher signature was changedThe current code introduces a new parameter to researcher, but the AI summary claims no public signature changes for this file.
14-21: researcher(...) call sites verified — no changes neededrg shows only the function definition and one call site; the call in app/actions.tsx was updated to the new parameter order and no longer passes mcp, which matches the signature in lib/agents/researcher.tsx.
- lib/agents/researcher.tsx — updated signature (dynamicSystemPrompt, uiStream, streamText, messages, useSpecificModel?)
- app/actions.tsx (≈lines 147–151) — call updated:
const { fullResponse, hasError, toolResponses } = await researcher(
currentSystemPrompt,
uiStream,
streamText,
messages,
// mcp, // mcp instance is no longer passed down
)lib/agents/writer.tsx (1)
7-12: No action needed — all writer(...) call sites updatedFound only the function definition and a single call site; the call already passes 4 args matching the new signature.
- lib/agents/writer.tsx — definition (new 4-arg signature)
- app/actions.tsx:192 — caller: writer(currentSystemPrompt, uiStream, streamText, latestMessages)
| - Image format:  | ||
| `; | ||
|
|
||
| const systemToUse = dynamicSystemPrompt && dynamicSystemPrompt.trim() !== '' ? dynamicSystemPrompt : default_system_prompt; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Guard against non-string dynamicSystemPrompt
This prevents .trim() from throwing if a legacy call passes a non-string by mistake.
- const systemToUse = dynamicSystemPrompt && dynamicSystemPrompt.trim() !== '' ? dynamicSystemPrompt : default_system_prompt;
+ const systemToUse =
+ typeof dynamicSystemPrompt === 'string' && dynamicSystemPrompt.trim() !== ''
+ ? dynamicSystemPrompt
+ : default_system_prompt;📝 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.
| const systemToUse = dynamicSystemPrompt && dynamicSystemPrompt.trim() !== '' ? dynamicSystemPrompt : default_system_prompt; | |
| const systemToUse = | |
| typeof dynamicSystemPrompt === 'string' && dynamicSystemPrompt.trim() !== '' | |
| ? dynamicSystemPrompt | |
| : default_system_prompt; |
🤖 Prompt for AI Agents
In lib/agents/writer.tsx around line 40, the current ternary calls
dynamicSystemPrompt.trim() which will throw if dynamicSystemPrompt is not a
string; update the conditional to first ensure dynamicSystemPrompt is a string
(e.g. typeof dynamicSystemPrompt === 'string') before calling .trim(), and only
use dynamicSystemPrompt when that check passes and the trimmed value is
non-empty, otherwise fall back to default_system_prompt.
… over including images. Previously, I would sometimes output only images. This change ensures that my primary goal is the textual response, and I will only include images if they are highly relevant and add significant value. Note: I wasn't able to test these changes by running the application, as the build process was blocked by missing environment variables.
User description
… provide more comprehensive and complete responses.
Specifically, I will now aim to:
Please note: I wasn't able to test these changes by running the application, as the build process was blocked by missing environment variables.
PR Type
Enhancement
Description
Enhanced AI agent prompts for more thorough research
Added comprehensive response guidelines across agents
Improved decision-making logic for information gathering
Strengthened writer agent with detailed analysis requirements
Diagram Walkthrough
File Walkthrough
researcher.tsx
Enhanced research thoroughness directivelib/agents/researcher.tsx
task-manager.tsx
Improved decision-making for information requestslib/agents/task-manager.tsx
writer.tsx
Comprehensive writer agent prompt enhancementlib/agents/writer.tsx
Summary by CodeRabbit
New Features
Behavior Changes