mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-16 04:18:05 +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 {
|
||||
// Fall back to --thinking value format
|
||||
const thinkingIdx = argsWithoutProxy.indexOf('--thinking');
|
||||
if (
|
||||
thinkingIdx !== -1 &&
|
||||
argsWithoutProxy[thinkingIdx + 1] &&
|
||||
// W4: Intentionally block negative numbers (negative budgets don't make sense)
|
||||
// Values starting with '-' are treated as next flag, not a negative number
|
||||
!argsWithoutProxy[thinkingIdx + 1].startsWith('-')
|
||||
) {
|
||||
const val = argsWithoutProxy[thinkingIdx + 1];
|
||||
if (thinkingIdx !== -1) {
|
||||
const nextArg = argsWithoutProxy[thinkingIdx + 1];
|
||||
// U1: Check if --thinking has a value (not missing or another flag)
|
||||
if (!nextArg || nextArg.startsWith('-')) {
|
||||
console.error(fail('--thinking requires a value'));
|
||||
console.error(' Examples: --thinking low, --thinking 8192, --thinking off');
|
||||
console.error(' Levels: minimal, low, medium, high, xhigh, auto');
|
||||
process.exit(1);
|
||||
}
|
||||
const val = nextArg;
|
||||
// Parse as number if numeric, otherwise keep as string (level name)
|
||||
const numVal = parseInt(val, 10);
|
||||
thinkingOverride = !isNaN(numVal) ? numVal : val;
|
||||
|
||||
@@ -110,7 +110,15 @@ export function applyThinkingConfig(
|
||||
// Get base model to check thinking support
|
||||
const baseModel = result.ANTHROPIC_MODEL || '';
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user