feat: Add allow-custom-agent-models patch#593
Conversation
Claude Code validates the `model` field in custom agent frontmatter (~/.claude/agents/*.md) against a hardcoded list of aliases (sonnet, opus, haiku, etc.). This prevents using arbitrary model names like "gemini-2.5-flash" or "oai@gemini-3-pro-preview". This patch removes that restriction so that arbitrary model names pass through to the API. On its own this would cause API errors against the real Anthropic API, but it enables a useful workflow: running a local proxy (e.g. Claudish) that intercepts requests and routes non-Claude model names to appropriate backends with format translation. Two locations are patched: 1. The Zod schema in UDD that validates against enum(<list variable>) is relaxed to accept any string. 2. The validation flag that gates whether the model field is included in the returned agent definition is changed to accept any non-empty string rather than only specific aliases. The search for this validation uses the captured list variable name from the Zod schema for robustness (the variable name has already changed across the few CC versions I tested). Verified against real binaries: 2.1.58, 2.1.62, 2.1.69, 2.1.70. The patch is opt-in (Features group, default: false). Enable with allowCustomAgentModels: true in tweakcc config. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughAdds a feature flag Changes
Sequence DiagramsequenceDiagram
participant User
participant UI as MiscView (UI)
participant Config as Settings Config
participant PatchSys as Patch System
participant PatchFn as writeAllowCustomAgentModels
User->>UI: Toggle allowCustomAgentModels
UI->>Config: Update misc.allowCustomAgentModels
Config->>PatchSys: Settings read during patch run
Note over PatchSys: Evaluate enabled patches
alt allowCustomAgentModels enabled
PatchSys->>PatchFn: Run on matching files
PatchFn->>PatchFn: Locate Zod enum model validation
PatchFn->>PatchFn: Replace with string().optional() model validation
PatchFn->>PatchFn: Replace restrictive includes/flag logic with permissive check
PatchFn-->>PatchSys: Return transformed file content
PatchSys-->>Config: Persist patch result / emit diff
else disabled
PatchSys-->>Config: Skip patch
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|
Great feature; thank you! |
Claude Code validates the
modelfield in custom agent frontmatter (~/.claude/agents/*.md) against a hardcoded list of aliases (sonnet, opus, haiku, etc.). This prevents using arbitrary model names like "gemini-2.5-flash" or "oai@gemini-3-pro-preview".This patch removes that restriction so that arbitrary model names pass through to the API. On its own this would cause API errors against the real Anthropic API, but it enables a useful workflow: running a local proxy (e.g. Claudish) that intercepts requests and routes non-Claude model names to appropriate backends with format translation.
Two locations are patched:
Verified against real binaries: 2.1.58, 2.1.62, 2.1.69, 2.1.70.
The patch is opt-in (Features group, default: false). Enable with
allowCustomAgentModels: truein tweakcc config.Summary by CodeRabbit