-
Notifications
You must be signed in to change notification settings - Fork 1
chore: upt output instructions details | Refactor setOutputInstructionPrompt system prompt with no API change #548
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: develop
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Reviewer's GuideThis PR refactors the system prompt for output instructions by replacing a concise bullet list with a comprehensive, structured set of guidelines covering markdown headings, list formatting, attachment analysis, language handling, tables, search tool usage, scope/referrals, and misc. developer requirements. Class diagram for updated output instruction prompt structureclassDiagram
class setOutputInstructionPrompt {
+Message setOutputInstructionPrompt(userContent: string)
}
class OutputInstructions {
+Headings
+ListsAndLabels
+AttachmentsAnalysis
+PlaceholderAndLanguageHandling
+Tables
+UseOfSearchTools
+ScopeAndReferrals
+Miscellaneous
}
setOutputInstructionPrompt --> OutputInstructions
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
WalkthroughRewrote the system prompt for setOutputInstructionPrompt into structured sections covering headings, lists, attachment analysis, placeholders/language handling, tables, search tool usage, scope/referrals, and miscellaneous output rules. Function signature unchanged; only internal prompt content updated. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Possibly related PRs
Suggested labels
Suggested reviewers
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. ✨ 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 (
|
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.
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
🧹 Nitpick comments (3)
apps/masterbots.ai/lib/constants/prompts.ts (3)
221-222
: Make search-tool guidance tool-agnosticReferencing a specific tool name (“web_search_preview”) can drift from actual availability/configuration. Keep this guideline generic to reduce maintenance and mismatches with runtime tools.
Apply this diff:
- - If the user requests recent information beyond the assistant's knowledge cutoff and the web_search_preview tool is available, use it. Otherwise, state the knowledge cutoff and offer to fetch updates if tools are available. + - If the user requests recent information beyond the assistant's knowledge cutoff and a web search tool is available, use it. Otherwise, state the knowledge cutoff and offer to fetch updates if tools are available.
209-209
: Clarify heading syntax to avoid literal “H1/H2” outputsAlthough you warn not to write “H1/H2” literally, models sometimes still do. Specifying Markdown tokens (#, ##, ###, ####) minimizes ambiguity.
- - Use Markdown headings hierarchically: H1 for the main title, H2 for major sections, H3 for subsections, H4 for detail-level notes/examples. Only include as many levels as needed; do not literally write "H1/H2" in the heading text. + - Use Markdown heading syntax hierarchically (# for the main title, ## for major sections, ### for subsections, #### for detail notes/examples). Only include as many levels as needed; do not include the literal words "H1/H2/H3/H4" in headings.
226-226
: Ambiguous directive: “unique lesser-known insight requested by the developer”The instruction assumes an external developer-provided signal that may not exist in context. This can confuse the model or force it to fabricate an “insight.”
- If such a signal exists elsewhere, reference it explicitly (e.g., a flag in the system prompt or config).
- Otherwise, reword to make it conditional and self-contained:
- - Always include the unique lesser-known insight requested by the developer. + - When appropriate, include one unique, lesser-known insight that is accurate and relevant. Omit if none apply.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/masterbots.ai/lib/constants/prompts.ts
(1 hunks)
🔇 Additional comments (1)
apps/masterbots.ai/lib/constants/prompts.ts (1)
227-227
: LGTM: avoiding “Questions/Answers” labels in final outputThis aligns with the rest of the prompt set (e.g., examplesPrompt) and helps keep answers clean.
- Placeholder and language handling: | ||
- Replace ${userContent} with the detected primary language/content the user provided. If it is empty, ask the user to clarify. Use language detection to determine translation needs. | ||
- Translate the final output to the user's primary language when the user's prompt or attachments are in a language other than English, unless the user requests otherwise. |
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.
Fix template interpolation: userContent is injected into the system prompt (prompt-injection risk) and likely unintended
The template string interpolates ${userContent} directly into the system instructions, which:
- Leaks raw user input into the system prompt, enabling prompt injection into system-level rules.
- Makes the sentence nonsensical (it reads as “Replace [actual user content]...” rather than referencing a literal placeholder).
Escape the placeholder so it remains literal, or generalize the instruction to avoid referencing a specific placeholder.
Apply one of the following diffs (preferred: Option A).
Option A — keep placeholder literal and clarify intent:
- - Replace ${userContent} with the detected primary language/content the user provided. If it is empty, ask the user to clarify. Use language detection to determine translation needs.
+ - Replace \${userContent} (if present as a literal placeholder) with the user's provided content and maintain the user's primary language. If it is empty, ask the user to clarify. Use language detection to determine translation needs.
Option B — generalize and remove placeholder reference:
- - Placeholder and language handling:
- - Replace ${userContent} with the detected primary language/content the user provided. If it is empty, ask the user to clarify. Use language detection to determine translation needs.
- - Translate the final output to the user's primary language when the user's prompt or attachments are in a language other than English, unless the user requests otherwise.
+ - Placeholder and language handling:
+ - Preserve and use the user's primary language. If no user content is provided, ask for clarification. Use language detection to determine translation needs.
+ - Translate the final output to the user's primary language when the user's prompt or attachments are not in English, unless the user requests otherwise. If detection is uncertain, ask a brief clarification.
📝 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.
- Placeholder and language handling: | |
- Replace ${userContent} with the detected primary language/content the user provided. If it is empty, ask the user to clarify. Use language detection to determine translation needs. | |
- Translate the final output to the user's primary language when the user's prompt or attachments are in a language other than English, unless the user requests otherwise. | |
- Placeholder and language handling: | |
- Replace \${userContent} (if present as a literal placeholder) with the user's provided content and maintain the user's primary language. If it is empty, ask the user to clarify. Use language detection to determine translation needs. | |
- Translate the final output to the user's primary language when the user's prompt or attachments are in a language other than English, unless the user requests otherwise. |
🤖 Prompt for AI Agents
In apps/masterbots.ai/lib/constants/prompts.ts around lines 216 to 218, the
system prompt currently interpolates ${userContent} directly which both risks
prompt-injection and renders the instruction nonsensical; update the template so
the placeholder remains literal or remove the specific placeholder reference.
Fix by either escaping the dollar/curly sequence so the text contains the
literal "${userContent}" (no runtime interpolation) and clarify it refers to a
placeholder for detected user language/content, or rewrite the sentence to a
generalized instruction such as "Replace the detected primary language/content
the user provided; if empty, ask the user to clarify. Use language detection..."
ensuring no runtime string interpolation occurs.
Summary by Sourcery
Refine output instruction prompt to provide clearer guidelines for heading structure, list formatting, content analysis, language handling, table usage, search tool invocation, expertise scope, and miscellaneous formatting rules.
Enhancements:
Summary by CodeRabbit
New Features
Improvements