fix(coding-agent): restored subagent thinking precedence
Agent frontmatter thinkingLevel now wins over model role suffix thinking when both are configured. Fixes #3915
This commit is contained in:
@@ -4,6 +4,9 @@
|
||||
* paid for. Regression guard for issue #2190.
|
||||
*/
|
||||
import { afterEach, describe, expect, it, vi } from "bun:test";
|
||||
import { ThinkingLevel } from "@oh-my-pi/pi-agent-core";
|
||||
import type { Model } from "@oh-my-pi/pi-ai";
|
||||
import { getBundledModel } from "@oh-my-pi/pi-catalog/models";
|
||||
import type { Rule } from "@oh-my-pi/pi-coding-agent/capability/rule";
|
||||
import type { ModelRegistry } from "@oh-my-pi/pi-coding-agent/config/model-registry";
|
||||
import { Settings } from "@oh-my-pi/pi-coding-agent/config/settings";
|
||||
@@ -89,6 +92,15 @@ const baseOptions = {
|
||||
enableLsp: false,
|
||||
};
|
||||
|
||||
function createModelRegistry(model: Model): ModelRegistry {
|
||||
return {
|
||||
authStorage: {},
|
||||
refresh: async () => {},
|
||||
getAvailable: () => [model],
|
||||
getApiKey: async () => "test-key",
|
||||
} as unknown as ModelRegistry;
|
||||
}
|
||||
|
||||
describe("runSubprocess parent-discovery pass-through (issue #2190)", () => {
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
@@ -152,4 +164,26 @@ describe("runSubprocess parent-discovery pass-through (issue #2190)", () => {
|
||||
expect(forwarded?.agentId).toBe("ChildAgent");
|
||||
expect(forwarded?.parentTaskPrefix).toBe("ChildAgent");
|
||||
});
|
||||
|
||||
it("lets agent frontmatter thinkingLevel override a task role suffix", async () => {
|
||||
const model = getBundledModel("anthropic", "claude-sonnet-4-5");
|
||||
if (!model) throw new Error("Expected claude-sonnet-4-5 model to exist");
|
||||
const settings = Settings.isolated();
|
||||
settings.setModelRole("task", `${model.provider}/${model.id}:high`);
|
||||
const session = yieldEmittingSession();
|
||||
const spy = vi.spyOn(sdkModule, "createAgentSession").mockResolvedValue(createSessionResult(session));
|
||||
|
||||
const result = await runSubprocess({
|
||||
...baseOptions,
|
||||
agent: { ...baseAgent, model: ["pi/task"] },
|
||||
id: "subagent-thinking-precedence",
|
||||
settings,
|
||||
modelRegistry: createModelRegistry(model),
|
||||
thinkingLevel: ThinkingLevel.Low,
|
||||
});
|
||||
|
||||
expect(result.exitCode).toBe(0);
|
||||
const forwarded = spy.mock.calls[0]?.[0];
|
||||
expect(forwarded?.thinkingLevel).toBe(ThinkingLevel.Low);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user