fix(coding-agent): accepted max thinking alias

Mapped the user-facing max thinking selector to the canonical xhigh effort so DeepSeek V4 Pro selectors and --thinking can request provider maximum reasoning.\n\nFixes #2727
This commit is contained in:
roboomp
2026-06-16 01:09:37 +00:00
parent e24f789de4
commit 83a5260957
3 changed files with 38 additions and 5 deletions
+4
View File
@@ -2,6 +2,10 @@
## [Unreleased]
### Fixed
- Accepted `max` as an alias for the top thinking level (`xhigh`) in selectors and `--thinking`, so DeepSeek V4 Pro can be selected with its provider-facing maximum effort ([#2727](https://github.com/can1357/oh-my-pi/issues/2727)).
## [16.0.1] - 2026-06-15
### Breaking Changes
+21 -5
View File
@@ -32,26 +32,42 @@ const THINKING_LEVEL_METADATA: Record<ThinkingLevel, ThinkingLevelMetadata> = {
[ThinkingLevel.High]: { value: ThinkingLevel.High, label: "high", description: "Deep reasoning (~16k tokens)" },
[ThinkingLevel.XHigh]: {
value: ThinkingLevel.XHigh,
label: "xhigh",
label: "max",
description: "Maximum reasoning (~32k tokens)",
},
};
const THINKING_LEVELS = new Set<string>([ThinkingLevel.Inherit, ThinkingLevel.Off, ...THINKING_EFFORTS]);
const EFFORT_LEVELS = new Set<string>(THINKING_EFFORTS);
const EFFORT_BY_SELECTOR: Readonly<Record<string, Effort>> = {
[Effort.Minimal]: Effort.Minimal,
[Effort.Low]: Effort.Low,
[Effort.Medium]: Effort.Medium,
[Effort.High]: Effort.High,
[Effort.XHigh]: Effort.XHigh,
max: Effort.XHigh,
};
const THINKING_LEVEL_BY_SELECTOR: Readonly<Record<string, ThinkingLevel>> = {
[ThinkingLevel.Inherit]: ThinkingLevel.Inherit,
[ThinkingLevel.Off]: ThinkingLevel.Off,
[ThinkingLevel.Minimal]: ThinkingLevel.Minimal,
[ThinkingLevel.Low]: ThinkingLevel.Low,
[ThinkingLevel.Medium]: ThinkingLevel.Medium,
[ThinkingLevel.High]: ThinkingLevel.High,
[ThinkingLevel.XHigh]: ThinkingLevel.XHigh,
max: ThinkingLevel.XHigh,
};
/**
* Parses a provider-facing effort value.
*/
export function parseEffort(value: string | null | undefined): Effort | undefined {
return value !== undefined && value !== null && EFFORT_LEVELS.has(value) ? (value as Effort) : undefined;
return value === undefined || value === null ? undefined : EFFORT_BY_SELECTOR[value];
}
/**
* Parses an agent-local thinking selector.
*/
export function parseThinkingLevel(value: string | null | undefined): ThinkingLevel | undefined {
return value !== undefined && value !== null && THINKING_LEVELS.has(value) ? (value as ThinkingLevel) : undefined;
return value === undefined || value === null ? undefined : THINKING_LEVEL_BY_SELECTOR[value];
}
/**
@@ -3,10 +3,12 @@ import { ThinkingLevel } from "@oh-my-pi/pi-agent-core";
import { Effort } from "@oh-my-pi/pi-ai";
import { getBundledModel } from "@oh-my-pi/pi-catalog/models";
import { parseDifficultyBucket, parseDifficultyLevel } from "@oh-my-pi/pi-coding-agent/auto-thinking/classifier";
import { parseModelString } from "@oh-my-pi/pi-coding-agent/config/model-resolver";
import {
AUTO_THINKING,
clampAutoThinkingEffort,
parseConfiguredThinkingLevel,
parseEffort,
parseThinkingLevel,
} from "@oh-my-pi/pi-coding-agent/thinking";
@@ -41,4 +43,15 @@ describe("auto thinking classifier helpers", () => {
expect(clampAutoThinkingEffort(model, Effort.XHigh)).toBe(Effort.High);
expect(clampAutoThinkingEffort(model, Effort.Minimal)).toBe(Effort.Low);
});
it("accepts max as the top thinking selector alias", () => {
expect(parseEffort("max")).toBe(Effort.XHigh);
expect(parseThinkingLevel("max")).toBe(ThinkingLevel.XHigh);
expect(parseConfiguredThinkingLevel("max")).toBe(ThinkingLevel.XHigh);
expect(parseModelString("deepseek/deepseek-v4-pro:max")).toEqual({
provider: "deepseek",
id: "deepseek-v4-pro",
thinkingLevel: ThinkingLevel.XHigh,
});
});
});