feat(claude): profile custom model effort #8964
Closedmimen(GitHub profile, opens in a new tab)wants to merge 1 commit into
main fromrefs/pull/8964/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:L
- apps/server/src/textGeneration/ClaudeTextGeneration.test.ts line 293OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -290,3 +290,4 @@290290 ),291291 );292292293+ it.effect("forwards a profiled custom model effort", () =>
- apps/server/src/provider/Layers/ClaudeAdapter.ts line 4568OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -4533,0 +4548,21 @@4548+ isCustomClaudeModel(modelSlug, claudeSettings) &&4549+ claudeSettings.customModelProfiles?.[modelSlug] !== undefined;4550+ const effectiveTurnEffort = customProfiled4551+ ? (getCustomClaudeAgentEffort(4552+ turnEffort === CUSTOM_MODEL_REASONING_DEFAULT ? null : turnEffort,4553+ ) ?? undefined)4554+ : (getEffectiveClaudeAgentEffort(turnEffort ?? null, modelSelection.model) ?? undefined);4555+ if (context.currentEffort !== effectiveTurnEffort) {4556+ yield* Effect.tryPromise({4557+ try: () =>4558+ // Claude Code accepts `max` through apply_flag_settings, but the SDK's4559+ // persisted Settings type currently stops at `xhigh`.4560+ (4561+ context.query.applyFlagSettings as (4562+ settings: ClaudeMutableFlagSettings,4563+ ) => Promise<void>4564+ )({ effortLevel: effectiveTurnEffort ?? null }),4565+ catch: (cause) => toRequestError(input.threadId, "turn/setEffort", cause),4566+ });4567+ }4568+ context.currentEffort = effectiveTurnEffort;
- apps/server/src/provider/Layers/ClaudeAdapter.ts line 4555OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -4524,10 +4538,18 @@45244538 ...context.session,45254539 model: modelSelection.model,45264540 };4527- const turnCaps = getClaudeModelCapabilities(modelSelection.model);4541+ const turnCaps = getClaudeModelCapabilities(modelSelection.model, claudeSettings);45284542 const turnEffort = resolveClaudeEffort(45294543 turnCaps,45304544 getModelSelectionStringOptionValue(modelSelection, "effort"),45314545 );4532- context.currentEffort =4533- getEffectiveClaudeAgentEffort(turnEffort ?? null, modelSelection.model) ?? undefined;4546+ const modelSlug = modelSelection.model.trim();4547+ const customProfiled =4548+ isCustomClaudeModel(modelSlug, claudeSettings) &&4549+ claudeSettings.customModelProfiles?.[modelSlug] !== undefined;4550+ const effectiveTurnEffort = customProfiled4551+ ? (getCustomClaudeAgentEffort(4552+ turnEffort === CUSTOM_MODEL_REASONING_DEFAULT ? null : turnEffort,4553+ ) ?? undefined)4554+ : (getEffectiveClaudeAgentEffort(turnEffort ?? null, modelSelection.model) ?? undefined);4555+ if (customProfiled && context.currentEffort !== effectiveTurnEffort) {
- apps/server/src/provider/Layers/ClaudeAdapter.ts line 4555OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -4524,10 +4538,18 @@45244538 ...context.session,45254539 model: modelSelection.model,45264540 };4527- const turnCaps = getClaudeModelCapabilities(modelSelection.model);4541+ const turnCaps = getClaudeModelCapabilities(modelSelection.model, claudeSettings);45284542 const turnEffort = resolveClaudeEffort(45294543 turnCaps,45304544 getModelSelectionStringOptionValue(modelSelection, "effort"),45314545 );4532- context.currentEffort =4533- getEffectiveClaudeAgentEffort(turnEffort ?? null, modelSelection.model) ?? undefined;4546+ const modelSlug = modelSelection.model.trim();4547+ const customProfiled =4548+ isCustomClaudeModel(modelSlug, claudeSettings) &&4549+ claudeSettings.customModelProfiles?.[modelSlug] !== undefined;4550+ const effectiveTurnEffort = customProfiled4551+ ? (getCustomClaudeAgentEffort(4552+ turnEffort === CUSTOM_MODEL_REASONING_DEFAULT ? null : turnEffort,4553+ ) ?? undefined)4554+ : (getEffectiveClaudeAgentEffort(turnEffort ?? null, modelSelection.model) ?? undefined);4555+ if (customProfiled && context.currentEffort !== effectiveTurnEffort) {
- apps/server/src/provider/Layers/ClaudeAdapter.ts line 4656OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -4601,0 +4636,21 @@4636+ : null;4637+ const effectiveTurnEffort = customProfiled4638+ ? (customTurnEffort ?? undefined)4639+ : (getEffectiveClaudeAgentEffort(modelCatalog, turnEffort ?? null, modelSelection.model) ??4640+ undefined);4641+ const effortChanged = context.currentEffort !== effectiveTurnEffort;4642+ const enterCustomProfile = customProfiled && !context.customEffortProfileActive;4643+ const leaveCustomProfile = !customProfiled && context.customEffortProfileActive;4644+ if ((customProfiled && (enterCustomProfile || effortChanged)) || leaveCustomProfile) {4645+ yield* Effect.tryPromise({4646+ try: () =>4647+ context.query.applyFlagSettings(4648+ customProfiled4649+ ? { effortLevel: customTurnEffort, ultracode: false }4650+ : { effortLevel: null, ultracode: context.baseUltracode },4651+ ),4652+ catch: (cause) => toRequestError(input.threadId, "turn/setEffort", cause),4653+ });4654+ context.customEffortProfileActive = customProfiled;4655+ }4656+ context.currentEffort = leaveCustomProfile ? context.baseEffort : effectiveTurnEffort;
- apps/server/src/provider/ClaudeModelCatalog.ts lines 137 to 137OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -91,2 +119,19 @@91- return {92- ...entry,119+ const customAliases = new Set(customSlugs.map((slug) => slug.toLowerCase()));120+ const builtInSlugs = new Set(catalog.models.map((entry) => entry.model.slug));121+ const seenCustom = new Set<string>();122+ const builtIns = catalog.models.map((entry) => {123+ if (!entry.model.aliases?.some((alias) => customAliases.has(alias.toLowerCase()))) {124+ return entry;125+ }126+ return {127+ ...entry,128+ model: {129+ ...entry.model,130+ aliases: entry.model.aliases.filter((alias) => !customAliases.has(alias.toLowerCase())),131+ },132+ };133+ });134+ const custom = customSlugs.flatMap((slug): ReadonlyArray<ClaudeCatalogModel> => {135+ if (builtInSlugs.has(slug) || seenCustom.has(slug)) return [];136+ seenCustom.add(slug);137+ const profile = customModelProfiles?.[slug];@@ -478,0 +485,21 @@485+ CUSTOM_MODEL_REASONING_LEVELS.some((candidate) => candidate === level) ||486+ `Unsupported custom model reasoning level ${JSON.stringify(level)}. Expected one of: ${CUSTOM_MODEL_REASONING_LEVELS.join(", ")}.`,487+ ),488+);489+490+export const CustomModelProfile = Schema.Struct({491+ capabilities: Schema.Struct({492+ reasoning: Schema.Struct({493+ levels: Schema.Array(CustomModelReasoningLevel)494+ .check(Schema.isNonEmpty())495+ .check(496+ Schema.makeFilter(497+ (levels) =>498+ new Set(levels).size === levels.length || "Reasoning levels must be unique.",499+ ),500+ ),501+ }),502+ }),503+});504+export type CustomModelProfile = typeof CustomModelProfile.Type;505+docs/user/custom-model-reasoning-profiles.md lines 48 to 48OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +28,21 @@28+ }29+ }30+ }31+ }32+}33+```34+35+The profile key must match a trimmed entry in `customModels` for the same Claude provider. Each profile chooses an ordered subset of `low`, `medium`, `high`, `xhigh`, and `max`.36+37+## Composer behavior38+39+T3 Code adds **Default** before the configured values and keeps their order. When the Claude runtime starts, Default omits `--effort` so Claude Code uses its configured default. Other choices are passed without built-in model compatibility remapping.40+41+Web, desktop, and mobile use the same provider capability metadata.42+43+## Validation44+45+An invalid profile marks only that named Claude provider instance unavailable. Other settings and providers remain active. Correct the profile to restore the instance.46+47+`levels` must contain at least one unique value.48+Each level must be `low`, `medium`, `high`, or `xhigh`.
- apps/server/src/provider/Layers/ClaudeProvider.ts line 487Resolvedby mimen(GitHub profile, opens in a new tab)@@ -492,7 +484,4 @@492484 });493485 }494486495- const models = providerModelsFromSettings(496- resolveClaudeModelsForVersion(modelCatalog, parsedVersion),497- claudeSettings.customModels,498- DEFAULT_CLAUDE_MODEL_CAPABILITIES,487+ const models = resolveClaudeModelsForVersion(scopedModelCatalog, parsedVersion);
mimen(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.


No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Team
Run ID:
02e65f8c-b941-4184-9658-1b65cb9cb68b📥 Commits
Reviewing files that changed from the base of the PR and between e2ed15637d1789f710b581a76aa075a9f686977b and 1d08ed003f453fa282f1dc50e1a9c38003247208.
📒 Files selected for processing (12)
apps/server/src/provider/Layers/ClaudeAdapter.test.tsapps/server/src/provider/Layers/ClaudeAdapter.tsapps/server/src/provider/Layers/ClaudeProvider.tsapps/server/src/provider/Layers/ProviderRegistry.test.tsapps/web/src/components/settings/ProviderInstanceCard.test.tsapps/web/src/components/settings/ProviderInstanceCard.tsxdocs/user/custom-model-reasoning-profiles.mdpackages/contracts/src/model.tspackages/contracts/src/settings.test.tspackages/contracts/src/settings.tspackages/shared/src/model.test.tspackages/shared/src/model.ts🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
Walkthrough#
Claude custom model profiles now define validated reasoning levels. Provider capabilities, server execution, web model selection, settings cleanup, and documentation support these profiles across the application.
Changes#
Claude custom reasoning profiles
packages/contracts/src/settings.ts,packages/contracts/src/settings.test.ts,packages/contracts/src/model.ts,packages/shared/src/model.ts,packages/shared/src/model.test.ts,docs/user/custom-model-reasoning-profiles.md,docs/README.mdapps/server/src/provider/Layers/ClaudeProvider.ts,apps/server/src/provider/Layers/ProviderRegistry.ts,apps/server/src/provider/Layers/ProviderRegistry.test.tsapps/server/src/provider/Layers/ClaudeAdapter.ts,apps/server/src/provider/Layers/ClaudeAdapter.test.ts,apps/server/src/textGeneration/ClaudeTextGeneration.ts,apps/server/src/textGeneration/ClaudeTextGeneration.test.tsultracodehandling.apps/web/src/components/chat/TraitsPicker.tsx,apps/web/src/components/settings/ProviderInstanceCard.tsx,apps/web/src/components/settings/ProviderInstanceCard.test.ts,apps/web/src/composerDraftStore.ts,apps/web/src/composerDraftStore.test.ts,apps/web/src/providerModels.ts,apps/web/src/modelSelection.test.tsEstimated code review effort: 4 (Complex) | ~45 minutes
Merge Risk: ⚪ Minimal · up to
1d08eThis change adds optional reasoning profiles for custom Claude models while preserving existing built-in model behavior; no actionable merge-blocking risk remains after normal checks and review.
Suggested reviewers:
juliusmarminge,t3dotggSequence Diagram(s)#
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (4 passed)
Full details: Docstring Coverage
Explanation
Docstring coverage is 15.79% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 19 files. (1 skipped: 1 unsupported.)
Full details: Description check
Explanation
The description is complete and focused. It explains what changed, why it changed, UI impact, verification, risk, rollback, and checklist status. It also documents the custom model effort-profile behavior and cleanup rules.
✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands.