fix(coding-agent): clamp thinking level to model capabilities
- setThinkingLevel() now clamps xhigh to high when model doesn't support it - Model changes automatically re-clamp the current thinking level - Fixed /model command to use session.setModel() instead of agent.setModel() - Footer and editor border color update after model/thinking changes Closes #253
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
import { Agent, type Attachment, ProviderTransport, type ThinkingLevel } from "@mariozechner/pi-agent-core";
|
||||
import { supportsXhigh } from "@mariozechner/pi-ai";
|
||||
import chalk from "chalk";
|
||||
import { type Args, parseArgs, printHelp } from "./cli/args.js";
|
||||
import { processFileArguments } from "./cli/file-processor.js";
|
||||
@@ -294,6 +295,15 @@ export async function main(args: string[]) {
|
||||
initialThinking = parsed.thinking;
|
||||
}
|
||||
|
||||
// Clamp thinking level to model capabilities
|
||||
if (initialModel) {
|
||||
if (!initialModel.reasoning) {
|
||||
initialThinking = "off";
|
||||
} else if (initialThinking === "xhigh" && !supportsXhigh(initialModel)) {
|
||||
initialThinking = "high";
|
||||
}
|
||||
}
|
||||
|
||||
// Determine which tools to use
|
||||
let selectedTools = parsed.tools ? parsed.tools.map((name) => allTools[name]) : codingTools;
|
||||
|
||||
@@ -378,11 +388,6 @@ export async function main(args: string[]) {
|
||||
}),
|
||||
});
|
||||
|
||||
// If initial thinking was requested but model doesn't support it, reset to off
|
||||
if (initialThinking !== "off" && initialModel && !initialModel.reasoning) {
|
||||
agent.setThinkingLevel("off");
|
||||
}
|
||||
|
||||
// Load previous messages if continuing, resuming, or using --session
|
||||
if (parsed.continue || parsed.resume || parsed.session) {
|
||||
const messages = sessionManager.loadMessages();
|
||||
|
||||
Reference in New Issue
Block a user