Skip to content

fix: map claude model ids to active provider model in proxy#11

Open
GlamgarOnDiscord wants to merge 3 commits intoLeonxlnx:mainfrom
GlamgarOnDiscord:fix/claude-model-passthrough-non-anthropic
Open

fix: map claude model ids to active provider model in proxy#11
GlamgarOnDiscord wants to merge 3 commits intoLeonxlnx:mainfrom
GlamgarOnDiscord:fix/claude-model-passthrough-non-anthropic

Conversation

@GlamgarOnDiscord
Copy link
Copy Markdown

@GlamgarOnDiscord GlamgarOnDiscord commented Apr 1, 2026

Fixes #9

Problem

When the bundled client sends a Claude model id (e.g. claude-sonnet-4-20250514) to a non-Anthropic provider, the proxy was passing it through unchanged. Gemini, Groq, OpenAI and others don't recognise Claude model names, causing a 404 NOT_FOUND error.

Root cause

resolveRequestModel had a fast-return for providers like gemini and openai that allowed any unknown model id through — including Claude ids sent by the bundled client.

Fix

Detect when the requested model starts with claude- or is a plain alias (sonnet, opus, haiku) and remap to ACTIVE_MODEL before forwarding. Provider-native ids (gemini-2.5-flash, gpt-4.1, etc.) still pass through unchanged.

Tested

  • Sending claude-sonnet-4-20250514 to Gemini proxy now returns a valid response instead of 404
  • Sending gemini-2.5-flash directly still works
  • 21/21 existing unit tests pass

Summary by Sourcery

Map Claude model identifiers to the active provider model in the Anthropic-compatible proxy and add local Claude/RTK tooling and documentation for contributors.

New Features:

  • Remap Claude model IDs and aliases in requests to the active provider model to avoid unknown model errors with non-Anthropic providers.

Enhancements:

  • Add an RTK-based Claude hook script to rewrite shell commands for reduced token usage in development workflows.

Documentation:

  • Add CLAUDE.md with provider configuration, recommended CLI tools, and common development commands.
  • Add AGENTS.md documenting agent tool preferences and quick-reference commands for working in this repository.

Chores:

  • Add Claude settings and hook configuration files for local development tooling integration.

Summary by cubic

Remaps Claude model ids to the active provider model in the proxy to prevent 404s on non-Anthropic providers. Adds a Claude Code hook and dev docs to streamline local tooling.

  • Bug Fixes

    • Detects Claude ids (claude-*, sonnet, opus, haiku) and rewrites them to ACTIVE_MODEL before forwarding; provider-native ids (e.g., gemini-2.5-flash, gpt-4.1) still pass through. Refactor: split detection into isClaude and isClaudeAlias for clarity.
  • New Features

    • Adds a Claude Code PreToolUse hook (.claude/settings.json, .claude/hooks/rtk-rewrite.sh) that rewrites Bash commands via rtk to cut token usage, plus developer guides (CLAUDE.md, AGENTS.md).

Written for commit 86c3310. Summary will update on new commits.

Summary by CodeRabbit

  • New Features

    • Added a Bash pre-tool-use hook with command rewrite and permission-handling behaviors.
    • Added settings to enable the pre-tool-use hook.
  • Bug Fixes

    • Improved model detection to correctly recognize Claude model identifiers.
  • Documentation

    • Added developer-facing guides: agent rules, recommended tools/workflows, and setup/run instructions.

Leonxlnx added 2 commits April 1, 2026 12:34
Adds CLAUDE.md with tool preferences for working on this codebase,
AGENTS.md with quick-reference rules for AI agents, and a Claude Code
PreToolUse hook that routes bash commands through rtk for 60–90% token
reduction on common operations.

CLAUDE.md covers all supported providers, recommended CLI tools (fd,
rg, ast-grep, jq, sd, tokei), and usage patterns that reduce context
noise. AGENTS.md is the short-form version for agent consumption.

The .claude/settings.json hook is opt-in and only fires on Bash tool
calls. No source files are modified.
When the bundled client sends a Claude model id (e.g.
claude-sonnet-4-20250514) to a non-Anthropic provider, the proxy
was passing it through unchanged. Gemini, Groq, OpenAI and others
do not recognise Claude model names, causing a 404 NOT_FOUND error.

Detect requests where the model starts with 'claude-' or is a
plain alias (sonnet, opus, haiku) and remap them to ACTIVE_MODEL
before forwarding. Provider-native model ids (gemini-2.5-flash,
gpt-4.1, etc.) are still passed through unchanged.

Fixes Leonxlnx#9
Copilot AI review requested due to automatic review settings April 1, 2026 10:42
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Apr 1, 2026

Reviewer's Guide

Maps Claude model IDs and aliases to the active provider model in the Anthropic compatibility proxy so non-Anthropic providers don't receive unknown model names, and adds Claude/agent tooling docs plus an rtk command-rewrite hook for local Claude Code usage.

Sequence diagram for model id remapping in Anthropic compatibility proxy

sequenceDiagram
  actor Developer
  participant Client
  participant AnthropicCompatProxy
  participant resolveRequestModel
  participant ProviderAPI

  Developer->>Client: Send chat request
  Client->>AnthropicCompatProxy: POST /messages (model=claude-sonnet-4-20250514)
  AnthropicCompatProxy->>resolveRequestModel: resolveRequestModel(body)
  resolveRequestModel->>resolveRequestModel: Read requested model
  resolveRequestModel->>resolveRequestModel: Detect claude-* or alias (sonnet/opus/haiku)
  resolveRequestModel-->>AnthropicCompatProxy: ACTIVE_MODEL
  AnthropicCompatProxy->>ProviderAPI: Forward request (model=ACTIVE_MODEL)
  ProviderAPI-->>AnthropicCompatProxy: 200 OK
  AnthropicCompatProxy-->>Client: Response

  rect rgb(230,230,230)
    Note over Developer,ProviderAPI: Provider native id path
  end
  Developer->>Client: Send chat request
  Client->>AnthropicCompatProxy: POST /messages (model=gemini-2.5-flash)
  AnthropicCompatProxy->>resolveRequestModel: resolveRequestModel(body)
  resolveRequestModel->>resolveRequestModel: Model is not claude-* or alias
  resolveRequestModel-->>AnthropicCompatProxy: gemini-2.5-flash
  AnthropicCompatProxy->>ProviderAPI: Forward request (model=gemini-2.5-flash)
  ProviderAPI-->>AnthropicCompatProxy: 200 OK
  AnthropicCompatProxy-->>Client: Response
Loading

Sequence diagram for rtk rewrite Claude hook behavior

sequenceDiagram
  participant ClaudeCode
  participant RTKRewriteHook
  participant jq
  participant rtk

  ClaudeCode->>RTKRewriteHook: PreToolUse event with tool_input
  RTKRewriteHook->>jq: Parse tool_input.command
  jq-->>RTKRewriteHook: Extracted command
  RTKRewriteHook->>rtk: rtk rewrite command
  rtk-->>RTKRewriteHook: Rewritten command
  rtk-->>RTKRewriteHook: Exit code 0 or 3

  alt Exit code 0 and command changed
    RTKRewriteHook->>jq: Update tool_input.command
    jq-->>RTKRewriteHook: Updated input JSON
    RTKRewriteHook-->>ClaudeCode: hookSpecificOutput with<br/>hookEventName PreToolUse<br/>permissionDecision allow<br/>permissionDecisionReason RTK auto-rewrite<br/>updatedInput
  else Exit code 3
    RTKRewriteHook->>jq: Update tool_input.command
    jq-->>RTKRewriteHook: Updated input JSON
    RTKRewriteHook-->>ClaudeCode: hookSpecificOutput with<br/>hookEventName PreToolUse<br/>updatedInput
  else Exit code 1,2,other or no command
    RTKRewriteHook-->>ClaudeCode: No changes
  end
Loading

Flow diagram for resolveRequestModel Claude id handling

flowchart TD
  A[Start resolveRequestModel] --> B[Read requested model]
  B --> C{Requested model is in default catalog?}
  C -- Yes --> D[Return catalog model]
  C -- No --> E{Provider is anthopic or provider-specific fast-return?}
  E -- Yes --> F[Return requested model]
  E -- No --> G{Is Claude id or alias?
  startsWith claude-
  or sonnet/opus/haiku}
  G -- Yes --> H[Return ACTIVE_MODEL]
  G -- No --> I{Provider allows custom model ids?}
  I -- Yes --> J[Return requested model]
  I -- No --> K[Return ACTIVE_MODEL or fallback]
  D --> L[End]
  F --> L
  H --> L
  J --> L
  K --> L
Loading

File-Level Changes

Change Details Files
Normalize Claude model ids and aliases to the active provider model when proxying to non-Anthropic providers.
  • Extend model resolution logic to detect Claude-style ids (claude-*) and plain aliases (sonnet, opus, haiku).
  • Return ACTIVE_MODEL whenever a Claude id/alias is detected so provider-native model ids still pass through unchanged.
  • Keep the existing early-return path for exact catalog matches and custom models for user-managed providers.
src/anthropicCompatProxy.ts
Add an rtk-based rewrite hook for Claude Code tool invocations.
  • Introduce a .claude/hooks/rtk-rewrite.sh script that intercepts PreToolUse events and rewrites shell commands via rtk rewrite.
  • Implement version and dependency checks for jq and rtk, warning but exiting cleanly when unavailable or outdated.
  • Implement exit-code-based behavior to either leave commands unchanged, rewrite and auto-allow, or rewrite while requiring explicit user confirmation.
.claude/hooks/rtk-rewrite.sh
Document provider configuration and preferred developer tooling / agent conventions for the project.
  • Add CLAUDE.md describing supported providers, default models, recommended CLI tools, and basic usage patterns for navigation, search, and refactors.
  • Add AGENTS.md specifying preferred tools and commands for agents (and humans) to understand how to explore, search, and modify the codebase.
  • Introduce a .claude/settings.json stub or configuration file for Claude-related project settings (exact contents not shown in diff).
CLAUDE.md
AGENTS.md
.claude/settings.json

Assessment against linked issues

Issue Objective Addressed Explanation
#9 Ensure that when using non-Anthropic providers (e.g., Gemini), any Claude model IDs sent by the bundled client (such as claude-sonnet-4-20250514 or aliases like sonnet, opus, haiku) are mapped to a valid provider model so that requests no longer fail with 404 NOT_FOUND.
#9 Preserve support for provider-native model IDs (e.g., gemini-2.5-flash) so they continue to pass through unchanged and work correctly with the Gemini API.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 1, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 048dc769-9cb4-4b63-a87a-2682ed34ef7c

📥 Commits

Reviewing files that changed from the base of the PR and between 1b8ac88 and 86c3310.

📒 Files selected for processing (1)
  • src/anthropicCompatProxy.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/anthropicCompatProxy.ts

📝 Walkthrough

Walkthrough

Adds a Claude Code PreToolUse hook that rewrites/permits Bash tool requests via rtk rewrite, Claude settings to register that hook, developer docs, and a model-resolution change that maps Claude model identifiers to the active Anthropic model to avoid passing Claude IDs to incompatible providers.

Changes

Cohort / File(s) Summary
Claude PreToolUse Hook
​.claude/hooks/rtk-rewrite.sh, ​.claude/settings.json
New Bash hook registered for PreToolUse that extracts .tool_input.command, checks jq/rtk availability and rtk version (>=0.23.0), runs rtk rewrite, and emits JSON containing updatedInput plus conditional permissionDecision (allow) or omission to trigger user prompt based on rtk exit codes (0 = auto-allow if changed, 3 = rewrite + prompt, others = pass-through).
Docs / Developer Guides
CLAUDE.md, AGENTS.md
Adds developer documentation and agent rules with supported provider env vars, recommended CLI tooling, example commands for codebase overview, search, JSON querying, structural search, safe replacements, and test invocation.
Anthropic Model Handling
src/anthropicCompatProxy.ts
resolveRequestModel extended to detect Claude model identifiers (strings prefixed with claude- and aliases sonnet, opus, haiku) and return ACTIVE_MODEL instead of forwarding those IDs to downstream providers.

Sequence Diagram(s)

sequenceDiagram
  participant ClaudeCode as Claude Code
  participant Hook as rtk-rewrite.sh
  participant RTK as rtk rewrite
  participant jq as jq (json)
  participant User as User

  ClaudeCode->>Hook: Invoke PreToolUse (tool_input.command)
  Hook->>jq: validate/format hook output (if present)
  Hook->>RTK: run `rtk rewrite --json` with command
  RTK-->>Hook: exit code + rewritten command / metadata
  alt exit code 0 and changed
    Hook->>jq: emit JSON with updatedInput + permissionDecision:"allow"
    Hook-->>ClaudeCode: auto-allow & updatedInput
  else exit code 3
    Hook->>jq: emit JSON with updatedInput (no permissionDecision)
    Hook-->>ClaudeCode: trigger user prompt flow
    ClaudeCode->>User: request permission
    User-->>ClaudeCode: grant/deny
  else other exit codes
    Hook-->>ClaudeCode: pass-through unchanged input
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Hopping through hooks with a curious twitch,

I nudge commands gently, tidy each stitch.
Rewrites and prompts in a neat little row,
Models aligned so the errors don't show.
A tiny rabbit, making devs' workflows glow. ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR includes out-of-scope documentation and development tooling files (.claude/hooks/rtk-rewrite.sh, .claude/settings.json, AGENTS.md, CLAUDE.md) that are not required to fix issue #9 but appear to be supplementary developer resources. Isolate the core fix (src/anthropicCompatProxy.ts changes) into a focused PR, and move documentation/tooling files (CLAUDE.md, AGENTS.md, .claude/) to a separate PR for clearer scope and review.
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 (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: map claude model ids to active provider model in proxy' directly and specifically describes the main change in src/anthropicCompatProxy.ts, which adds Claude model ID detection and remapping logic.
Linked Issues check ✅ Passed The code changes in src/anthropicCompatProxy.ts directly address issue #9 by detecting Claude model identifiers and remapping them to ACTIVE_MODEL before forwarding to non-Anthropic providers, preventing 404 errors.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with 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.

❤️ Share

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

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The Claude model detection in resolveRequestModel is hardcoded to three aliases; consider centralizing these identifiers (and potential future ones) into a shared constant or configuration to avoid scattering provider-specific model names in logic.
  • In the rtk-rewrite.sh hook, it may be safer to handle non-zero exit codes from rtk --version and rtk rewrite more explicitly (e.g., logging a brief warning to stderr for unexpected failures) so that silent misconfigurations are easier to debug.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The Claude model detection in `resolveRequestModel` is hardcoded to three aliases; consider centralizing these identifiers (and potential future ones) into a shared constant or configuration to avoid scattering provider-specific model names in logic.
- In the `rtk-rewrite.sh` hook, it may be safer to handle non-zero exit codes from `rtk --version` and `rtk rewrite` more explicitly (e.g., logging a brief warning to stderr for unexpected failures) so that silent misconfigurations are easier to debug.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes an Anthropic-compat proxy edge case where Claude model IDs (and common Claude family aliases) were being forwarded unchanged to non-Anthropic providers, causing “model not found” errors (e.g., Gemini 404).

Changes:

  • Remap Claude model IDs / aliases (claude-*, sonnet, opus, haiku) to the configured ACTIVE_MODEL before forwarding to non-Anthropic providers.
  • Add developer/agent documentation and a Claude Code hook configuration under .claude/.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/anthropicCompatProxy.ts Maps Claude model identifiers to the active provider model to avoid downstream 404s.
CLAUDE.md Adds a developer guide (providers, tools, test command).
AGENTS.md Documents tool preferences/shortcuts for agents working in the repo.
.claude/settings.json Adds a Claude Code PreToolUse hook configuration.
.claude/hooks/rtk-rewrite.sh Hook script that delegates command rewriting/permission decisions to rtk rewrite.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


| Tool | Install | Replaces | Gain |
|------|---------|----------|------|
| **rtk** | `curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh \| sh` | — | -60/90% tokens on bash output |
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

The install command shows a literal \| inside inline code. In a shell, \| escapes the pipe and will not pipe to sh, so copy/paste will fail. Use an unescaped | (or move the command into a fenced code block) so the command works as written.

Suggested change
| **rtk** | `curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh \| sh` || -60/90% tokens on bash output |
| **rtk** | `curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh` || -60/90% tokens on bash output |

Copilot uses AI. Check for mistakes.
| Find files | `fd -e ts src/` | `find src -name "*.ts"` |
| Search content | `rg 'pattern' src/ -t ts` | `grep -r` |
| Structural search | `ast-grep run --lang ts --pattern '...' src/` | complex regex |
| Query JSON | `jq '.key' file.json` | `cat file.json \| grep` |
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

The “Not” example uses \| inside inline code (e.g., cat file.json \| grep). In a shell this escapes the pipe, so the example is not equivalent to cat file.json | grep. Use an unescaped | (or describe the pipe in prose) to avoid misleading copy/paste.

Suggested change
| Query JSON | `jq '.key' file.json` | `cat file.json \| grep` |
| Query JSON | `jq '.key' file.json` | `cat file.json | grep` |

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +12
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": ".claude/hooks/rtk-rewrite.sh"
}
]
}
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

PR description focuses on model-id remapping in the proxy, but this PR also adds Claude Code/agent docs and hook configuration under .claude/ plus new guide files. If these additions are intentional, please mention them in the PR description; otherwise consider moving them to a separate PR to keep the fix scoped and easier to review/revert.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

@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

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

315-325: Normalize Claude-ID checks to be case-insensitive.

Line 318–321 currently only match lowercase values. Inputs like Claude-Sonnet-... or SONNET will bypass remapping and can still hit provider-side model-not-found errors.

Proposed patch
-  const isClaudeModel =
-    requested.startsWith("claude-") ||
-    requested === "sonnet" ||
-    requested === "opus" ||
-    requested === "haiku";
+  const normalizedRequested = requested.toLowerCase();
+  const isClaudeModel =
+    normalizedRequested.startsWith("claude-") ||
+    normalizedRequested === "sonnet" ||
+    normalizedRequested === "opus" ||
+    normalizedRequested === "haiku";
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/anthropicCompatProxy.ts` around lines 315 - 325, The Claude model
detection in the block using the variable requested and the isClaudeModel check
is case-sensitive and misses variants like "Claude-Sonnet" or "SONNET"; update
the logic to compare a normalized form (e.g., lowercased) of requested before
doing startsWith("claude-") or the equality checks for "sonnet", "opus", "haiku"
so that requested.toLowerCase() (or an equivalent normalized string) is used in
the isClaudeModel condition and the existing return of ACTIVE_MODEL remains
unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.claude/hooks/rtk-rewrite.sh:
- Around line 60-63: When the script hits the deny branch (the case labelled
"2)" where EXIT_CODE=2) it's currently exiting with 0 and no output, so the RTK
deny decision is ignored; change that branch to write the required JSON response
(e.g., {"permissionDecision":"deny","reason":"RTK denied"} or similar) to stdout
so Claude Code sees the deny, and then exit appropriately (keep the script’s
expected exit behavior but ensure the JSON is emitted). Update the "2)" case to
print the JSON object with permissionDecision:"deny" (using the same
variable/branch names EXIT_CODE and the case "2)") and then exit.

In `@CLAUDE.md`:
- Around line 3-13: The CLAUDE.md provider table is out of sync with runtime
validation (runtime currently only recognizes Anthropic and Gemini via the
provider whitelist in src/config.ts and src/providers.ts), so either update the
doc to list only Anthropic and Gemini with their correct env keys/defaults or
extend the runtime to accept the other providers; specifically, fix the
CLAUDE.md table rows (remove or correct OpenAI/Groq/Copilot/z.ai/Ollama entries)
to match the actual provider constants/allowedProviders in src/config.ts and the
provider resolution logic in src/providers.ts, or alternatively add the missing
provider entries and corresponding env key handling in the provider constants
and resolution functions so docs and runtime match.

---

Nitpick comments:
In `@src/anthropicCompatProxy.ts`:
- Around line 315-325: The Claude model detection in the block using the
variable requested and the isClaudeModel check is case-sensitive and misses
variants like "Claude-Sonnet" or "SONNET"; update the logic to compare a
normalized form (e.g., lowercased) of requested before doing
startsWith("claude-") or the equality checks for "sonnet", "opus", "haiku" so
that requested.toLowerCase() (or an equivalent normalized string) is used in the
isClaudeModel condition and the existing return of ACTIVE_MODEL remains
unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 04789345-f3c4-45af-aa64-cfc2e32358ed

📥 Commits

Reviewing files that changed from the base of the PR and between bf9b138 and 1b8ac88.

📒 Files selected for processing (5)
  • .claude/hooks/rtk-rewrite.sh
  • .claude/settings.json
  • AGENTS.md
  • CLAUDE.md
  • src/anthropicCompatProxy.ts

Comment on lines +60 to +63
2)
# Deny rule matched — let Claude Code's native deny rule handle it.
exit 0
;;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

For Claude Code PreToolUse hooks, is omitting permissionDecisiontreated as allow/pass-through, and is returningpermissionDecision: "deny" the correct way to enforce a deny decision from a hook?

💡 Result:

Yes, omitting permissionDecision (i.e., no JSON output from the PreToolUse hook, just exit 0) is treated as allow/pass-through to the native permission system. Returning permissionDecision: "deny" (in the correct format: {"hookSpecificOutput": {"hookEventName": "PreToolUse", "permissionDecision": "deny", "permissionDecisionReason": "..."} } with exit code 0) is the correct way to enforce a deny decision from a hook.

Citations:


RTK deny decision is not enforced in the deny branch.

On Line 60-63, when EXIT_CODE=2, the script exits with 0 and no output. This is treated as allow/pass-through by Claude Code's permission system. The RTK deny decision is effectively ignored.

To enforce the deny, output the correct JSON structure with permissionDecision: "deny":

🔒 Fix to enforce deny outcome
   2)
-    # Deny rule matched — let Claude Code's native deny rule handle it.
-    exit 0
+    # Deny rule matched — explicitly deny in hook output.
+    jq -n \
+      '{
+        "hookSpecificOutput": {
+          "hookEventName": "PreToolUse",
+          "permissionDecision": "deny",
+          "permissionDecisionReason": "Blocked by RTK deny rule"
+        }
+      }'
+    exit 0
     ;;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.claude/hooks/rtk-rewrite.sh around lines 60 - 63, When the script hits the
deny branch (the case labelled "2)" where EXIT_CODE=2) it's currently exiting
with 0 and no output, so the RTK deny decision is ignored; change that branch to
write the required JSON response (e.g.,
{"permissionDecision":"deny","reason":"RTK denied"} or similar) to stdout so
Claude Code sees the deny, and then exit appropriately (keep the script’s
expected exit behavior but ensure the JSON is emitted). Update the "2)" case to
print the JSON object with permissionDecision:"deny" (using the same
variable/branch names EXIT_CODE and the case "2)") and then exit.

Comment on lines +3 to +13
## Supported Providers

| Provider | Env Key | Default Model |
|----------|---------|---------------|
| Anthropic | `ANTHROPIC_API_KEY` | `claude-sonnet-4-20250514` |
| OpenAI | `OPENAI_API_KEY` | `gpt-4.1-mini` |
| Gemini | `GEMINI_API_KEY` | `gemini-2.5-flash` |
| Groq | `GROQ_API_KEY` | `openai/gpt-oss-20b` |
| GitHub Copilot | `COPILOT_TOKEN` | `openai/gpt-4.1-mini` |
| z.ai | `ZAI_API_KEY` | `glm-5` |
| Ollama | local | `qwen3` |
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Provider support table is out of sync with actual runtime support.

On Line 5-Line 13, the guide documents OpenAI/Groq/Copilot/z.ai/Ollama as supported, but runtime currently only accepts anthropic and gemini (src/config.ts Line 7-Line 15, Line 23-Line 52; src/providers.ts Line 11). This will lead users to invalid .env setups and startup failures.

🛠️ Proposed doc correction
 | Provider | Env Key | Default Model |
 |----------|---------|---------------|
 | Anthropic | `ANTHROPIC_API_KEY` | `claude-sonnet-4-20250514` |
-| OpenAI | `OPENAI_API_KEY` | `gpt-4.1-mini` |
 | Gemini | `GEMINI_API_KEY` | `gemini-2.5-flash` |
-| Groq | `GROQ_API_KEY` | `openai/gpt-oss-20b` |
-| GitHub Copilot | `COPILOT_TOKEN` | `openai/gpt-4.1-mini` |
-| z.ai | `ZAI_API_KEY` | `glm-5` |
-| Ollama | local | `qwen3` |
📝 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
## Supported Providers
| Provider | Env Key | Default Model |
|----------|---------|---------------|
| Anthropic | `ANTHROPIC_API_KEY` | `claude-sonnet-4-20250514` |
| OpenAI | `OPENAI_API_KEY` | `gpt-4.1-mini` |
| Gemini | `GEMINI_API_KEY` | `gemini-2.5-flash` |
| Groq | `GROQ_API_KEY` | `openai/gpt-oss-20b` |
| GitHub Copilot | `COPILOT_TOKEN` | `openai/gpt-4.1-mini` |
| z.ai | `ZAI_API_KEY` | `glm-5` |
| Ollama | local | `qwen3` |
## Supported Providers
| Provider | Env Key | Default Model |
|----------|---------|---------------|
| Anthropic | `ANTHROPIC_API_KEY` | `claude-sonnet-4-20250514` |
| Gemini | `GEMINI_API_KEY` | `gemini-2.5-flash` |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@CLAUDE.md` around lines 3 - 13, The CLAUDE.md provider table is out of sync
with runtime validation (runtime currently only recognizes Anthropic and Gemini
via the provider whitelist in src/config.ts and src/providers.ts), so either
update the doc to list only Anthropic and Gemini with their correct env
keys/defaults or extend the runtime to accept the other providers; specifically,
fix the CLAUDE.md table rows (remove or correct OpenAI/Groq/Copilot/z.ai/Ollama
entries) to match the actual provider constants/allowedProviders in
src/config.ts and the provider resolution logic in src/providers.ts, or
alternatively add the missing provider entries and corresponding env key
handling in the provider constants and resolution functions so docs and runtime
match.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 5 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="CLAUDE.md">

<violation number="1" location="CLAUDE.md:29">
P2: Contributor docs recommend `curl | sh` from a mutable branch URL, creating avoidable remote code-execution/supply-chain risk.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.


| Tool | Install | Replaces | Gain |
|------|---------|----------|------|
| **rtk** | `curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh \| sh` | — | -60/90% tokens on bash output |
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Apr 1, 2026

Choose a reason for hiding this comment

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

P2: Contributor docs recommend curl | sh from a mutable branch URL, creating avoidable remote code-execution/supply-chain risk.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At CLAUDE.md, line 29:

<comment>Contributor docs recommend `curl | sh` from a mutable branch URL, creating avoidable remote code-execution/supply-chain risk.</comment>

<file context>
@@ -0,0 +1,78 @@
+
+| Tool | Install | Replaces | Gain |
+|------|---------|----------|------|
+| **rtk** | `curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh \| sh` | — | -60/90% tokens on bash output |
+| **rg** | `apt install ripgrep` / `brew install ripgrep` | grep | Fastest content search |
+| **fd** | `apt install fd-find` / `brew install fd` | find | -99% output on targeted search |
</file context>
Fix with Cubic

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.

Model not found using Gemini api

3 participants