Expose reasoning effort for custom Claude models #4194
ClosedIsraelAraujo70(GitHub profile, opens in a new tab)wants to merge 5 commits into
main fromrefs/pull/4194/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
- apps/server/src/provider/Layers/ClaudeProvider.ts line 54OutdatedResolvedby IsraelAraujo70(GitHub profile, opens in a new tab)@@ -39,7 +39,16 @@3939 import { resolveClaudeSdkExecutablePath } from "../Drivers/ClaudeExecutable.ts";4040 import { makeClaudeEnvironment } from "../Drivers/ClaudeHome.ts";414142-const DEFAULT_CLAUDE_MODEL_CAPABILITIES: ModelCapabilities = createModelCapabilities({42+const EMPTY_CLAUDE_MODEL_CAPABILITIES: ModelCapabilities = createModelCapabilities({4343 optionDescriptors: [],4444 });454546+const DEFAULT_CLAUDE_MODEL_CAPABILITIES: ModelCapabilities = createModelCapabilities({47+ optionDescriptors: [48+ buildSelectOptionDescriptor({49+ id: "effort",50+ label: "Reasoning",51+ options: [52+ { value: "low", label: "Low" },53+ { value: "medium", label: "Medium" },54+ { value: "high", label: "High", isDefault: true },
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:S
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/server/src/provider/Layers/ClaudeProvider.ts lines 732 to 734OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -629,0 +714,21 @@714+ return q.initializationResult();715+ };716+ const customModels = [717+ ...new Set(claudeSettings.customModels.map((model) => model.trim())),718+ ].filter((model) => model.length > 0);719+ const results = await Promise.allSettled(720+ (customModels.length > 0 ? customModels : [undefined]).map((model) => initialize(model)),721+ );722+ const initializations = results.flatMap((result) =>723+ result.status === "fulfilled" ? [result.value] : [],724+ );725+ if (initializations.length === 0 && customModels.length > 0) {726+ initializations.push(await initialize());727+ }728+ const init = initializations[0]!;729+ const modelsByValue = new Map<string, ClaudeModelInfo>();730+ for (const initialization of initializations) {731+ for (const model of initialization.models) {732+ modelsByValue.set(model.value, model);733+ }734+ }
- apps/server/src/provider/Layers/ClaudeProvider.ts line 394OutdatedResolvedby IsraelAraujo70(GitHub profile, opens in a new tab)@@ -312,6 +386,9 @@312386313387 export function getClaudeModelCapabilities(model: string | null | undefined): ModelCapabilities {314388 const slug = model?.trim();389+ if (!slug) {390+ return EMPTY_CLAUDE_MODEL_CAPABILITIES;391+ }315392 return (316393 BUILT_IN_MODELS.find((candidate) => candidate.slug === slug)?.capabilities ??317- DEFAULT_CLAUDE_MODEL_CAPABILITIES394+ CUSTOM_CLAUDE_MODEL_CAPABILITIES
- apps/server/src/provider/Layers/ClaudeProvider.ts line 734OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -629,0 +714,21 @@714+ prompt: (async function* (): AsyncGenerator<SDKUserMessage> {715+ await waitForAbortSignal(abort.signal);716+ })(),717+ options: {718+ persistSession: false,719+ pathToClaudeCodeExecutable: executablePath,720+ abortController: abort,721+ settingSources: ["user", "project", "local"],722+ allowedTools: [],723+ env: claudeEnvironment,724+ ...(model ? { model } : {}),725+ ...(cwd ? { cwd } : {}),726+ stderr: () => {},727+ },728+ });729+ return q.initializationResult();730+ };731+ const customModels = [732+ ...new Set(claudeSettings.customModels.map((model) => model.trim())),733+ ].filter((model) => model.length > 0);734+ const results = await Promise.allSettled(
- apps/server/src/provider/Layers/ClaudeProvider.ts line 722OutdatedResolvedby IsraelAraujo70(GitHub profile, opens in a new tab)@@ -629,0 +702,21 @@702+ await waitForAbortSignal(abort.signal);703+ })(),704+ options: {705+ persistSession: false,706+ pathToClaudeCodeExecutable: executablePath,707+ abortController: abort,708+ settingSources: ["user", "project", "local"],709+ allowedTools: [],710+ env: claudeEnvironment,711+ ...(model ? { model } : {}),712+ ...(cwd ? { cwd } : {}),713+ stderr: () => {},714+ },715+ });716+ return q.initializationResult();717+ };718+ const customModels = [719+ ...new Set(claudeSettings.customModels.map((model) => model.trim())),720+ ].filter((model) => model.length > 0);721+ const initializations = [];722+ for (const model of customModels.length > 0 ? customModels : [undefined]) {
- apps/server/src/provider/Layers/ClaudeProvider.ts line 728OutdatedResolvedby IsraelAraujo70(GitHub profile, opens in a new tab)@@ -629,0 +708,21 @@708+ settingSources: ["user", "project", "local"],709+ allowedTools: [],710+ env: claudeEnvironment,711+ ...(model ? { model } : {}),712+ ...(cwd ? { cwd } : {}),713+ stderr: () => {},714+ },715+ });716+ return q.initializationResult();717+ };718+ const customModels = [719+ ...new Set(claudeSettings.customModels.map((model) => model.trim())),720+ ].filter((model) => model.length > 0);721+ const initializations = [];722+ for (const model of customModels.length > 0 ? customModels : [undefined]) {723+ try {724+ initializations.push(await initialize(model));725+ } catch {726+ // One invalid custom model must not prevent the remaining probes.727+ }728+ }
juliusmarminge closed this
Sign in to join this conversation.




Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID:
a9dd7cfb-3beb-4c06-9bfc-1a0d377b94caYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
✨ 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.
❤️ Share