fix(coding-agent): remember last selected model when using scoped models (#736)

This commit is contained in:
Can Celik 2026-01-15 15:10:15 +03:00 committed by GitHub
parent 39ee5fee92
commit 2c10cc6da9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 7 deletions

View file

@ -4,6 +4,7 @@
### Fixed
- Scoped models (`--models` or `enabledModels`) now remember the last selected model across sessions instead of always starting with the first model in the scope ([#736](https://github.com/badlogic/pi-mono/pull/736) by [@ogulcancelik](https://github.com/ogulcancelik))
- Show `bun install` instead of `npm install` in update notification when running under Bun ([#714](https://github.com/badlogic/pi-mono/pull/714) by [@dannote](https://github.com/dannote))
- `/skill` prompts now include the skill path ([#711](https://github.com/badlogic/pi-mono/pull/711) by [@jblwilliams](https://github.com/jblwilliams))
- Use configurable `expandTools` keybinding instead of hardcoded Ctrl+O ([#717](https://github.com/badlogic/pi-mono/pull/717) by [@dannote](https://github.com/dannote))

View file

@ -5,7 +5,7 @@
* createAgentSession() options. The SDK does the heavy lifting.
*/
import { type ImageContent, supportsXhigh } from "@mariozechner/pi-ai";
import { type ImageContent, modelsAreEqual, supportsXhigh } from "@mariozechner/pi-ai";
import chalk from "chalk";
import { existsSync } from "fs";
import { join } from "path";
@ -164,16 +164,30 @@ function buildSessionOptions(
}
options.model = model;
} else if (scopedModels.length > 0 && !parsed.continue && !parsed.resume) {
options.model = scopedModels[0].model;
// Check if saved default is in scoped models - use it if so, otherwise first scoped model
const savedProvider = settingsManager.getDefaultProvider();
const savedModelId = settingsManager.getDefaultModel();
const savedModel = savedProvider && savedModelId ? modelRegistry.find(savedProvider, savedModelId) : undefined;
const savedInScope = savedModel ? scopedModels.find((sm) => modelsAreEqual(sm.model, savedModel)) : undefined;
if (savedInScope) {
options.model = savedInScope.model;
// Use thinking level from scoped model config if explicitly set
if (!parsed.thinking && savedInScope.thinkingLevel) {
options.thinkingLevel = savedInScope.thinkingLevel;
}
} else {
options.model = scopedModels[0].model;
// Use thinking level from first scoped model if explicitly set
if (!parsed.thinking && scopedModels[0].thinkingLevel) {
options.thinkingLevel = scopedModels[0].thinkingLevel;
}
}
}
// Thinking level
// Only use scoped model's thinking level if it was explicitly specified (e.g., "model:high")
// Otherwise, let the SDK use defaultThinkingLevel from settings
// Thinking level from CLI (takes precedence over scoped model thinking levels set above)
if (parsed.thinking) {
options.thinkingLevel = parsed.thinking;
} else if (scopedModels.length > 0 && scopedModels[0].thinkingLevel && !parsed.continue && !parsed.resume) {
options.thinkingLevel = scopedModels[0].thinkingLevel;
}
// Scoped models for Ctrl+P cycling - fill in default thinking level for models without explicit level