mirror of
https://github.com/tiennm99/ccs.git
synced 2026-08-14 12:25:27 +00:00
fix(cliproxy): improve thinking flag validation and warnings
- U1: reject --thinking with no value (show usage hint) - U2: warn when provider doesn't support thinking budget
This commit is contained in:
@@ -337,14 +337,16 @@ export async function execClaudeWithCLIProxy(
|
|||||||
} else {
|
} else {
|
||||||
// Fall back to --thinking value format
|
// Fall back to --thinking value format
|
||||||
const thinkingIdx = argsWithoutProxy.indexOf('--thinking');
|
const thinkingIdx = argsWithoutProxy.indexOf('--thinking');
|
||||||
if (
|
if (thinkingIdx !== -1) {
|
||||||
thinkingIdx !== -1 &&
|
const nextArg = argsWithoutProxy[thinkingIdx + 1];
|
||||||
argsWithoutProxy[thinkingIdx + 1] &&
|
// U1: Check if --thinking has a value (not missing or another flag)
|
||||||
// W4: Intentionally block negative numbers (negative budgets don't make sense)
|
if (!nextArg || nextArg.startsWith('-')) {
|
||||||
// Values starting with '-' are treated as next flag, not a negative number
|
console.error(fail('--thinking requires a value'));
|
||||||
!argsWithoutProxy[thinkingIdx + 1].startsWith('-')
|
console.error(' Examples: --thinking low, --thinking 8192, --thinking off');
|
||||||
) {
|
console.error(' Levels: minimal, low, medium, high, xhigh, auto');
|
||||||
const val = argsWithoutProxy[thinkingIdx + 1];
|
process.exit(1);
|
||||||
|
}
|
||||||
|
const val = nextArg;
|
||||||
// Parse as number if numeric, otherwise keep as string (level name)
|
// Parse as number if numeric, otherwise keep as string (level name)
|
||||||
const numVal = parseInt(val, 10);
|
const numVal = parseInt(val, 10);
|
||||||
thinkingOverride = !isNaN(numVal) ? numVal : val;
|
thinkingOverride = !isNaN(numVal) ? numVal : val;
|
||||||
|
|||||||
@@ -110,7 +110,15 @@ export function applyThinkingConfig(
|
|||||||
// Get base model to check thinking support
|
// Get base model to check thinking support
|
||||||
const baseModel = result.ANTHROPIC_MODEL || '';
|
const baseModel = result.ANTHROPIC_MODEL || '';
|
||||||
if (!supportsThinking(provider, baseModel)) {
|
if (!supportsThinking(provider, baseModel)) {
|
||||||
return result; // Model doesn't support thinking
|
// U2: Warn user if they explicitly provided --thinking but model doesn't support it
|
||||||
|
if (thinkingOverride !== undefined && thinkingConfig.show_warnings !== false) {
|
||||||
|
console.warn(
|
||||||
|
warn(
|
||||||
|
`Model ${baseModel || 'unknown'} (provider: ${provider}) does not support thinking budget. --thinking flag ignored.`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine thinking value to use
|
// Determine thinking value to use
|
||||||
|
|||||||
Reference in New Issue
Block a user