Skip to content

fix: replace hardcoded anthropic provider in instructions with dynamic values#2

Open
lllyys wants to merge 1 commit intoAlaeddineMessadi:mainfrom
lllyys:fix/dynamic-provider-instructions
Open

fix: replace hardcoded anthropic provider in instructions with dynamic values#2
lllyys wants to merge 1 commit intoAlaeddineMessadi:mainfrom
lllyys:fix/dynamic-provider-instructions

Conversation

@lllyys
Copy link

@lllyys lllyys commented Mar 20, 2026

Summary

  • MCP server instructions and best-practices prompt hardcoded anthropic / claude-sonnet-4-5 in all example code blocks, causing LLM clients to always default to Anthropic even when users have different providers configured
  • Instruction examples now use OPENCODE_DEFAULT_PROVIDER / OPENCODE_DEFAULT_MODEL env vars when set, falling back to generic <your-provider> / <your-model> placeholders
  • "Getting Started" section now directs LLMs to call opencode_setup first to discover available providers instead of assuming any specific one

Fixes #1

Changes

src/index.ts

  • Added exProvider / exModel variables derived from env vars or generic placeholders
  • Replaced all 5 hardcoded anthropic / claude-sonnet-4-5 / claude-opus-4-6 references in instruction examples
  • Updated "Getting Started" to guide LLMs to discover providers via opencode_setup
  • Updated "Important Notes" to emphasize using discovered providers

src/prompts.ts

  • Replaced hardcoded anthropic references in the best-practices prompt with generic guidance

Summary by CodeRabbit

  • Documentation
    • Updated setup guidance to recommend discovering available providers and models through the setup process instead of hardcoding specific providers.
    • Enhanced best practices examples with generic provider and model placeholders for greater flexibility across different configurations.

…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
@coderabbitai
Copy link

coderabbitai bot commented Mar 20, 2026

📝 Walkthrough

Walkthrough

The changes update MCP server instructions and best practices prompts to dynamically reference providers instead of hardcoding anthropic. They introduce exProvider and exModel constants derived from environment variables, with generic placeholders as fallback, and retrain clients to discover providers via opencode_setup before making requests.

Changes

Cohort / File(s) Summary
Provider Configuration & Instructions
src/index.ts
Added dynamic exProvider and exModel constants derived from OPENCODE_DEFAULT_PROVIDER/OPENCODE_DEFAULT_MODEL env vars (falling back to "<your-provider>" and "<your-model>"). Interpolated these constants into instruction strings and examples. Removed hardcoded anthropic references and updated "Getting Started" to instruct using opencode_setup to discover providers before calling opencode_provider_models.
Best Practices Prompts
src/prompts.ts
Replaced hardcoded providerId: "anthropic" examples with instructions to select providers from the Ready to use list. Updated opencode_ask "Good" example to use "<your-provider>" and "<your-model>" placeholders. Extended "CRITICAL" guidance to emphasize using discovered providers instead of hardcoded values.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 No more anthropic locked in stone,
Our providers now can truly own
The stage—dynamic, free, and bright,
Each setup finds the perfect fit just right!
With placeholders guiding the way,
The right provider wins the day.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change: replacing hardcoded anthropic provider references with dynamic values derived from environment variables or placeholders.
Linked Issues check ✅ Passed The PR successfully addresses all objectives from issue #1: removes hardcoded anthropic/model references, uses env var defaults with generic placeholder fallbacks, and updates Getting Started guidance to use opencode_setup for provider discovery.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the stated objectives: updating instruction/prompt text and adding environment variable-based constants in src/index.ts and src/prompts.ts. No unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Tip

You can disable the changed files summary in the walkthrough.

Disable the reviews.changed_files_summary setting to disable the changed files summary in the walkthrough.

Copy link

@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.

🧹 Nitpick comments (1)
src/prompts.ts (1)

161-167: Inconsistent placeholder handling between files.

This file always uses hardcoded "<your-provider>" / "<your-model>" placeholders, while src/index.ts dynamically derives exProvider/exModel from environment variables with placeholders as fallback. When OPENCODE_DEFAULT_PROVIDER and OPENCODE_DEFAULT_MODEL are set, the instructions in src/index.ts will 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.ts to 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

📥 Commits

Reviewing files that changed from the base of the PR and between afa70c4 and a38c5ed.

📒 Files selected for processing (2)
  • src/index.ts
  • src/prompts.ts

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP instructions hardcode anthropic as example provider, causing LLMs to default to it

1 participant