fix: replace hardcoded anthropic provider in instructions with dynamic values#2
fix: replace hardcoded anthropic provider in instructions with dynamic values#2lllyys wants to merge 1 commit intoAlaeddineMessadi:mainfrom
Conversation
…namic values The MCP server instructions and best-practices prompt hardcoded "anthropic" and "claude-sonnet-4-5" in all example code blocks. This caused LLM clients to always pass providerID: "anthropic" even when users had different providers configured (e.g. the built-in "opencode" provider). Now the instruction examples use OPENCODE_DEFAULT_PROVIDER / OPENCODE_DEFAULT_MODEL env vars when set, falling back to generic "<your-provider>" / "<your-model>" placeholders. The "Getting Started" section directs LLMs to call opencode_setup first to discover available providers instead of assuming anthropic. Fixes AlaeddineMessadi#1
📝 WalkthroughWalkthroughThe changes update MCP server instructions and best practices prompts to dynamically reference providers instead of hardcoding Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment Tip You can disable the changed files summary in the walkthrough.Disable the |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/prompts.ts (1)
161-167: Inconsistent placeholder handling between files.This file always uses hardcoded
"<your-provider>"/"<your-model>"placeholders, whilesrc/index.tsdynamically derivesexProvider/exModelfrom environment variables with placeholders as fallback. WhenOPENCODE_DEFAULT_PROVIDERandOPENCODE_DEFAULT_MODELare set, the instructions insrc/index.tswill show concrete values (e.g.,openrouter), but the best-practices prompt here will still show generic placeholders—potentially confusing users.Consider importing or replicating the same logic from
src/index.tsto keep examples consistent:♻️ Suggested approach
+const exProvider = process.env.OPENCODE_DEFAULT_PROVIDER || "<your-provider>"; +const exModel = process.env.OPENCODE_DEFAULT_MODEL || "<your-model>"; + // Then in the prompt text: -Good: \`opencode_ask({prompt: "...", providerID: "<your-provider>", modelID: "<your-model>"})\` +Good: \`opencode_ask({prompt: "...", providerID: "${exProvider}", modelID: "${exModel}"})\`🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/prompts.ts` around lines 161 - 167, The prompt text uses hardcoded placeholders "<your-provider>" and "<your-model>" which can conflict with the dynamic defaults computed in src/index.ts; replicate or import the same environment-derived logic (the exProvider/exModel fallback from OPENCODE_DEFAULT_PROVIDER and OPENCODE_DEFAULT_MODEL) and use those values in the prompt string so examples for opencode_ask, opencode_reply, opencode_message_send, and opencode_message_send_async show the actual default provider/model when set; update the prompt generation to substitute exProvider and exModel instead of the literal placeholders and ensure the wording still warns to not hardcode providers.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/prompts.ts`:
- Around line 161-167: The prompt text uses hardcoded placeholders
"<your-provider>" and "<your-model>" which can conflict with the dynamic
defaults computed in src/index.ts; replicate or import the same
environment-derived logic (the exProvider/exModel fallback from
OPENCODE_DEFAULT_PROVIDER and OPENCODE_DEFAULT_MODEL) and use those values in
the prompt string so examples for opencode_ask, opencode_reply,
opencode_message_send, and opencode_message_send_async show the actual default
provider/model when set; update the prompt generation to substitute exProvider
and exModel instead of the literal placeholders and ensure the wording still
warns to not hardcode providers.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9a8fae01-b35f-480e-85de-7ce07731b0cc
📒 Files selected for processing (2)
src/index.tssrc/prompts.ts
Summary
anthropic/claude-sonnet-4-5in all example code blocks, causing LLM clients to always default to Anthropic even when users have different providers configuredOPENCODE_DEFAULT_PROVIDER/OPENCODE_DEFAULT_MODELenv vars when set, falling back to generic<your-provider>/<your-model>placeholdersopencode_setupfirst to discover available providers instead of assuming any specific oneFixes #1
Changes
src/index.tsexProvider/exModelvariables derived from env vars or generic placeholdersanthropic/claude-sonnet-4-5/claude-opus-4-6references in instruction examplesopencode_setupsrc/prompts.tsanthropicreferences in the best-practices prompt with generic guidanceSummary by CodeRabbit