Scope reasoning effort defaults and options by provider
- Replace global reasoning constants with provider-scoped effort options/defaults - Update ChatView to use Codex-specific reasoning effort types and default lookup - Expand model contract tests for provider-specific reasoning effort behavior
This commit is contained in:
1 parent
7c0ccb54ff
commit
e80564813e
3 files changed
+63
-26
No files matched your search
@@ -2,17 +2,18 @@ import {
|
||||
type ApprovalRequestId,
|
||||
CURSOR_REASONING_OPTIONS,
|
||||
DEFAULT_MODEL,
|
||||
DEFAULT_REASONING,
|
||||
EDITORS,
|
||||
type EditorId,
|
||||
type KeybindingCommand,
|
||||
type CodexReasoningEffort,
|
||||
type CursorReasoningOption,
|
||||
type MessageId,
|
||||
getDefaultModel,
|
||||
getDefaultReasoningEffort,
|
||||
getCursorModelCapabilities,
|
||||
getCursorModelFamilyOptions,
|
||||
getModelOptions,
|
||||
getReasoningOptions,
|
||||
getReasoningEffortOptions,
|
||||
type ProjectId,
|
||||
type ProjectEntry,
|
||||
type ProjectScript,
|
||||
@@ -20,7 +21,6 @@ import {
|
||||
parseCursorModelSelection,
|
||||
PROVIDER_SEND_TURN_MAX_ATTACHMENTS,
|
||||
PROVIDER_SEND_TURN_MAX_IMAGE_BYTES,
|
||||
type ReasoningEffort,
|
||||
type ResolvedKeybindingsConfig,
|
||||
type ProviderApprovalDecision,
|
||||
type ServerProviderStatus,
|
||||
@@ -683,8 +683,8 @@ export default function ChatView({ threadId }: ChatViewProps) {
|
||||
DEFAULT_MODEL,
|
||||
);
|
||||
const selectedModel = resolveModelSlugForProvider(selectedProvider, composerDraft.model ?? baseThreadModel);
|
||||
const selectedEffort = composerDraft.effort ?? DEFAULT_REASONING;
|
||||
const reasoningOptions = getReasoningOptions(selectedProvider);
|
||||
const selectedEffort = composerDraft.effort ?? getDefaultReasoningEffort(selectedProvider);
|
||||
const reasoningOptions = getReasoningEffortOptions(selectedProvider);
|
||||
const supportsReasoningEffort = reasoningOptions.length > 0;
|
||||
const selectedCursorModel = useMemo(
|
||||
() => (selectedProvider === "cursor" ? parseCursorModelSelection(selectedModel) : null),
|
||||
@@ -2386,8 +2386,8 @@ export default function ChatView({ threadId }: ChatViewProps) {
|
||||
[onProviderModelSelect, selectedModel, selectedProvider],
|
||||
);
|
||||
const onEffortSelect = useCallback(
|
||||
(effort: ReasoningEffort) => {
|
||||
setComposerDraftEffort(threadId, effort);
|
||||
(effort: CodexReasoningEffort) => {
|
||||
setSelectedEffort(effort);
|
||||
scheduleComposerFocus();
|
||||
},
|
||||
[scheduleComposerFocus, setComposerDraftEffort, threadId],
|
||||
@@ -4132,10 +4132,12 @@ const ProviderModelPicker = memo(function ProviderModelPicker(props: {
|
||||
});
|
||||
|
||||
const ReasoningEffortPicker = memo(function ReasoningEffortPicker(props: {
|
||||
effort: ReasoningEffort;
|
||||
options: ReadonlyArray<ReasoningEffort>;
|
||||
onEffortChange: (effort: ReasoningEffort) => void;
|
||||
effort: CodexReasoningEffort;
|
||||
options: ReadonlyArray<CodexReasoningEffort>;
|
||||
onEffortChange: (effort: CodexReasoningEffort) => void;
|
||||
}) {
|
||||
const defaultReasoningEffort = getDefaultReasoningEffort("codex");
|
||||
|
||||
return (
|
||||
<Select
|
||||
value={props.effort}
|
||||
@@ -4148,7 +4150,7 @@ const ReasoningEffortPicker = memo(function ReasoningEffortPicker(props: {
|
||||
{props.options.map((effort) => (
|
||||
<SelectItem key={effort} value={effort}>
|
||||
{effort}
|
||||
{effort === DEFAULT_REASONING ? " (default)" : ""}
|
||||
{effort === defaultReasoningEffort ? " (default)" : ""}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectPopup>
|
||||
|
||||
@@ -7,12 +7,14 @@ import {
|
||||
DEFAULT_MODEL_BY_PROVIDER,
|
||||
MODEL_OPTIONS,
|
||||
MODEL_OPTIONS_BY_PROVIDER,
|
||||
REASONING_EFFORT_OPTIONS_BY_PROVIDER,
|
||||
DEFAULT_REASONING_EFFORT_BY_PROVIDER,
|
||||
getDefaultModel,
|
||||
getDefaultReasoningEffort,
|
||||
getCursorModelFamilyOptions,
|
||||
getModelOptions,
|
||||
getReasoningOptions,
|
||||
getReasoningEffortOptions,
|
||||
normalizeModelSlug,
|
||||
REASONING_OPTIONS,
|
||||
parseCursorModelSelection,
|
||||
resolveCursorModelFromSelection,
|
||||
resolveModelSlug,
|
||||
@@ -148,12 +150,32 @@ describe("cursor model selection", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("getReasoningOptions", () => {
|
||||
describe("getReasoningEffortOptions", () => {
|
||||
it("returns codex reasoning options for codex", () => {
|
||||
expect(getReasoningOptions("codex")).toEqual(REASONING_OPTIONS);
|
||||
expect(getReasoningEffortOptions("codex")).toEqual(
|
||||
REASONING_EFFORT_OPTIONS_BY_PROVIDER.codex,
|
||||
);
|
||||
});
|
||||
|
||||
it("returns no reasoning options for claudeCode", () => {
|
||||
expect(getReasoningOptions("claudeCode")).toEqual([]);
|
||||
expect(getReasoningEffortOptions("claudeCode")).toEqual([]);
|
||||
});
|
||||
|
||||
it("returns no reasoning options for cursor", () => {
|
||||
expect(getReasoningEffortOptions("cursor")).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getDefaultReasoningEffort", () => {
|
||||
it("returns provider-scoped defaults", () => {
|
||||
expect(getDefaultReasoningEffort("codex")).toBe(
|
||||
DEFAULT_REASONING_EFFORT_BY_PROVIDER.codex,
|
||||
);
|
||||
expect(getDefaultReasoningEffort("claudeCode")).toBe(
|
||||
DEFAULT_REASONING_EFFORT_BY_PROVIDER.claudeCode,
|
||||
);
|
||||
expect(getDefaultReasoningEffort("cursor")).toBe(
|
||||
DEFAULT_REASONING_EFFORT_BY_PROVIDER.cursor,
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -491,18 +491,31 @@ export function resolveModelSlugForProvider(
|
||||
return resolveModelSlug(model, provider);
|
||||
}
|
||||
|
||||
export const REASONING_OPTIONS_BY_PROVIDER = {
|
||||
codex: ["xhigh", "high", "medium", "low"],
|
||||
const CODEX_REASONING_EFFORT_OPTIONS = ["xhigh", "high", "medium", "low"] as const;
|
||||
export type CodexReasoningEffort = (typeof CODEX_REASONING_EFFORT_OPTIONS)[number];
|
||||
|
||||
export const REASONING_EFFORT_OPTIONS_BY_PROVIDER = {
|
||||
codex: CODEX_REASONING_EFFORT_OPTIONS,
|
||||
claudeCode: [],
|
||||
} as const satisfies Record<ProviderKind, readonly string[]>;
|
||||
cursor: [],
|
||||
} as const satisfies Record<ProviderKind, readonly CodexReasoningEffort[]>;
|
||||
|
||||
// Backward compatibility for existing Codex-only call sites.
|
||||
export const REASONING_OPTIONS = REASONING_OPTIONS_BY_PROVIDER.codex;
|
||||
export type ReasoningEffort = (typeof REASONING_OPTIONS_BY_PROVIDER.codex)[number];
|
||||
export const DEFAULT_REASONING: ReasoningEffort = "high";
|
||||
export const DEFAULT_REASONING_EFFORT_BY_PROVIDER = {
|
||||
codex: "high",
|
||||
claudeCode: null,
|
||||
cursor: null,
|
||||
} as const satisfies Record<ProviderKind, CodexReasoningEffort | null>;
|
||||
|
||||
export function getReasoningOptions(
|
||||
export function getReasoningEffortOptions(
|
||||
provider: ProviderKind = "codex",
|
||||
): ReadonlyArray<ReasoningEffort> {
|
||||
return REASONING_OPTIONS_BY_PROVIDER[provider] as ReadonlyArray<ReasoningEffort>;
|
||||
): ReadonlyArray<CodexReasoningEffort> {
|
||||
return REASONING_EFFORT_OPTIONS_BY_PROVIDER[provider];
|
||||
}
|
||||
|
||||
export function getDefaultReasoningEffort(provider: "codex"): CodexReasoningEffort;
|
||||
export function getDefaultReasoningEffort(provider: ProviderKind): CodexReasoningEffort | null;
|
||||
export function getDefaultReasoningEffort(
|
||||
provider: ProviderKind = "codex",
|
||||
): CodexReasoningEffort | null {
|
||||
return DEFAULT_REASONING_EFFORT_BY_PROVIDER[provider];
|
||||
}
|
||||
Reference in new issue
Block a user