mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-21 17:00:45 +00:00
fix(coding-agent): remember last selected model when using scoped models (#736)
This commit is contained in:
parent
39ee5fee92
commit
2c10cc6da9
2 changed files with 22 additions and 7 deletions
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
### Fixed
|
### 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))
|
- 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))
|
- `/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))
|
- Use configurable `expandTools` keybinding instead of hardcoded Ctrl+O ([#717](https://github.com/badlogic/pi-mono/pull/717) by [@dannote](https://github.com/dannote))
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
* createAgentSession() options. The SDK does the heavy lifting.
|
* 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 chalk from "chalk";
|
||||||
import { existsSync } from "fs";
|
import { existsSync } from "fs";
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
|
|
@ -164,16 +164,30 @@ function buildSessionOptions(
|
||||||
}
|
}
|
||||||
options.model = model;
|
options.model = model;
|
||||||
} else if (scopedModels.length > 0 && !parsed.continue && !parsed.resume) {
|
} 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
|
// Thinking level from CLI (takes precedence over scoped model thinking levels set above)
|
||||||
// Only use scoped model's thinking level if it was explicitly specified (e.g., "model:high")
|
|
||||||
// Otherwise, let the SDK use defaultThinkingLevel from settings
|
|
||||||
if (parsed.thinking) {
|
if (parsed.thinking) {
|
||||||
options.thinkingLevel = 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
|
// Scoped models for Ctrl+P cycling - fill in default thinking level for models without explicit level
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue