fix(task): reject effort above configured ceiling

This commit is contained in:
Wolfgang Schoenberger
2026-07-27 04:13:56 -07:00
parent bd1605e8f5
commit e12e575da3
3 changed files with 55 additions and 4 deletions
@@ -5,7 +5,7 @@
*/
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 { Effort, 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";
@@ -254,6 +254,35 @@ describe("runSubprocess parent-discovery pass-through (issue #2190)", () => {
expect(spy.mock.calls[0]?.[0]?.thinkingLevel).toBe(ThinkingLevel.Low);
});
it("rejects a spawn when task.maxEffort is below the model floor", async () => {
const baseModel = getBundledModel("openai-codex", "gpt-5.6-sol");
if (!baseModel) throw new Error("Expected gpt-5.6-sol model to exist");
const model = {
...baseModel,
id: "mock-high-only",
provider: "mock",
thinking: { mode: "effort", efforts: [Effort.High] },
} as Model;
const settings = Settings.isolated({ "task.maxEffort": "low" });
settings.setModelRole("task", `${model.provider}/${model.id}`);
const spy = vi.spyOn(sdkModule, "createAgentSession");
const result = await runSubprocess({
...baseOptions,
agent: { ...baseAgent, model: ["@task"] },
id: "subagent-effort-ceiling-below-floor",
effort: "hi",
settings,
modelRegistry: createModelRegistry(model),
});
expect(result.exitCode).toBe(1);
expect(result.stderr).toContain(
"mock/mock-high-only has no supported thinking effort at or below task.maxEffort=low",
);
expect(spy).not.toHaveBeenCalled();
});
it("preserves the model's full effort range by default", async () => {
const model = getBundledModel("openai-codex", "gpt-5.6-sol");
if (!model) throw new Error("Expected gpt-5.6-sol model to exist");