- Replaced legacy `pi/` role alias prefix with canonical `@` syntax across model resolution, documentation, and tests. - Added support for bare `*` default alias and multiple alias prefix detection with custom role resolution in `resolveConfiguredRolePattern()`. - Enhanced thinking suffix parsing to accept unambiguous abbreviations (minimum 2 characters) for effort and level selectors. - Extended `resolveCliModel()` and `filterAvailableModelsByEnabledPatterns()` to accept settings parameter for role alias resolution from `--model` flag.
61 lines
2.5 KiB
TypeScript
61 lines
2.5 KiB
TypeScript
import { describe, expect, it } from "bun:test";
|
|
import { Effort } from "@oh-my-pi/pi-ai";
|
|
import { buildModel } from "@oh-my-pi/pi-catalog/build";
|
|
import { resolveAgentModelPatterns, resolveModelOverride } from "@oh-my-pi/pi-coding-agent/config/model-resolver";
|
|
import { Settings } from "@oh-my-pi/pi-coding-agent/config/settings";
|
|
import { getBundledAgent } from "@oh-my-pi/pi-coding-agent/task/agents";
|
|
import { AUTO_THINKING } from "@oh-my-pi/pi-coding-agent/thinking";
|
|
|
|
describe("bundled agent parsing", () => {
|
|
it("lets reviewer inherit thinking effort from its model role", () => {
|
|
const reviewer = getBundledAgent("reviewer");
|
|
|
|
expect(reviewer).toBeDefined();
|
|
expect(reviewer?.source).toBe("bundled");
|
|
expect(reviewer?.model).toEqual(["@slow"]);
|
|
expect(reviewer?.thinkingLevel).toBeUndefined();
|
|
});
|
|
|
|
it("defaults the task agent to the auto thinking selector", () => {
|
|
const task = getBundledAgent("task");
|
|
|
|
expect(task).toBeDefined();
|
|
expect(task?.model).toEqual(["@task"]);
|
|
expect(task?.thinkingLevel).toBe(AUTO_THINKING);
|
|
});
|
|
|
|
// Issue #4761: with `modelRoles.slow: ...:xhigh`, the role's explicit effort
|
|
// suffix must survive agent-pattern expansion and model resolution for the
|
|
// bundled agents routed at that role. The executor prefers an explicit
|
|
// resolved suffix over the agent-definition default (task/executor.ts), so
|
|
// the resolved level below is what the subagent runs at.
|
|
it("resolves the configured slow-role effort suffix for reviewer", () => {
|
|
const gpt55 = buildModel({
|
|
id: "gpt-5.5",
|
|
name: "GPT-5.5 Codex",
|
|
api: "openai-codex-responses",
|
|
provider: "openai-codex",
|
|
baseUrl: "https://chatgpt.com/backend-api/codex",
|
|
reasoning: true,
|
|
thinking: { mode: "effort", efforts: [Effort.Low, Effort.Medium, Effort.High, Effort.XHigh] },
|
|
input: ["text"],
|
|
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
contextWindow: 272000,
|
|
maxTokens: 128000,
|
|
});
|
|
const settings = Settings.isolated({
|
|
modelRoles: { slow: "openai-codex/gpt-5.5:xhigh" },
|
|
});
|
|
const registry = { getAvailable: () => [gpt55] } as Parameters<typeof resolveModelOverride>[1];
|
|
|
|
const agent = getBundledAgent("reviewer");
|
|
expect(agent?.thinkingLevel).toBeUndefined();
|
|
const patterns = resolveAgentModelPatterns({ agentModel: agent?.model, settings });
|
|
const resolved = resolveModelOverride(patterns, registry, settings);
|
|
expect(resolved.model?.provider).toBe("openai-codex");
|
|
expect(resolved.model?.id).toBe("gpt-5.5");
|
|
expect(resolved.thinkingLevel).toBe(Effort.XHigh);
|
|
expect(resolved.explicitThinkingLevel).toBe(true);
|
|
});
|
|
});
|