mirror of
https://github.com/tiennm99/ccs.git
synced 2026-09-03 12:21:20 +00:00
fix(config): add null guard and document nested paren limitation
- Add optional chaining for tier_defaults to prevent crash - Document nested parenthesis matching limitation
This commit is contained in:
@@ -54,9 +54,13 @@ export function detectTierFromModel(modelName: string): ModelTier {
|
|||||||
* @param model - Base model name
|
* @param model - Base model name
|
||||||
* @param thinkingValue - Level name (e.g., 'high') or numeric budget
|
* @param thinkingValue - Level name (e.g., 'high') or numeric budget
|
||||||
* @returns Model name with thinking suffix, e.g., "gemini-3-pro-preview(high)"
|
* @returns Model name with thinking suffix, e.g., "gemini-3-pro-preview(high)"
|
||||||
|
*
|
||||||
|
* @note Paren matching only handles one level. Nested parens like "model(foo)(8192)"
|
||||||
|
* will be treated as already having suffix and returned unchanged.
|
||||||
*/
|
*/
|
||||||
export function applyThinkingSuffix(model: string, thinkingValue: string | number): string {
|
export function applyThinkingSuffix(model: string, thinkingValue: string | number): string {
|
||||||
// Don't apply if already has suffix
|
// Don't apply if already has suffix
|
||||||
|
// NOTE: This only detects ANY paren pair, not proper nesting (e.g., "model(foo)(8192)" passes through)
|
||||||
if (model.includes('(') && model.includes(')')) {
|
if (model.includes('(') && model.includes(')')) {
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
@@ -77,8 +81,8 @@ export function getThinkingValueForTier(
|
|||||||
if (providerOverride) {
|
if (providerOverride) {
|
||||||
return providerOverride;
|
return providerOverride;
|
||||||
}
|
}
|
||||||
// Fall back to global tier default
|
// Fall back to global tier default (with null guard)
|
||||||
return thinkingConfig.tier_defaults[tier];
|
return thinkingConfig.tier_defaults?.[tier] ?? 'medium';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user