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:
roboomp
2026-06-30 20:15:04 +00:00
parent b6c9747d45
commit e4561d64fa
3 changed files with 39 additions and 3 deletions
+4
View File
@@ -2,6 +2,10 @@
## [Unreleased]
### Fixed
- Fixed subagent frontmatter `thinkingLevel` being overridden by `modelRoles.task` model suffixes. ([#3915](https://github.com/can1357/oh-my-pi/issues/3915))
## [16.2.9] - 2026-06-30
### Breaking Changes
+1 -3
View File
@@ -2053,9 +2053,7 @@ export async function runSubprocess(options: ExecutorOptions): Promise<SingleRes
? formatModelSelectorValue(formatModelStringWithRouting(model), resolvedThinkingLevel)
: formatModelStringWithRouting(model);
}
const effectiveThinkingLevel = explicitThinkingLevel
? resolvedThinkingLevel
: (thinkingLevel ?? resolvedThinkingLevel);
const effectiveThinkingLevel = thinkingLevel ?? resolvedThinkingLevel;
resolvedAt = performance.now();
const effectiveCwd = worktree ?? cwd;
@@ -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);
});
});