fix(effort): stop clamping Grok xhigh effort to high

Two stacked issues kept grok-4.6 requests at high effort even when the
UI selected xhigh: the effort capability table had no Grok entries, so
resolveAppliedEffort clamped xhigh to high; and an explicit --effort
flag never overrode CLAUDE_CODE_EFFORT_LEVEL env for main-loop queries.
Resolve Grok capabilities from the bundled Grok catalog and wire
effortValueOverridesEnv through the REPL for explicit CLI effort.
This commit is contained in:
程序员阿江(Relakkes)
2026-08-13 04:44:17 +08:00
parent 59408abaae
commit 456300749c
4 changed files with 47 additions and 1 deletions
+3
View File
@@ -3156,6 +3156,9 @@ async function run(): Promise<CommanderCommand> {
appendSystemPrompt,
taskListId,
thinkingConfig,
// An explicit --effort flag is authoritative over CLAUDE_CODE_EFFORT_LEVEL
// env (resolveAppliedEffort), matching the effectiveEffort precedence.
effortValueOverridesEnv: options.effort !== undefined,
...(uploaderReady && {
onTurnComplete: (messages: MessageType[]) => {
void uploaderReady.then(uploader => uploader?.(messages));
+5 -1
View File
@@ -568,6 +568,8 @@ export type Props = {
sshSession?: SSHSession;
// Thinking configuration to use when thinking is enabled
thinkingConfig: ThinkingConfig;
// When true, an explicit CLI --effort is authoritative over session env.
effortValueOverridesEnv?: boolean;
};
export type Screen = 'prompt' | 'transcript';
export function REPL({
@@ -595,7 +597,8 @@ export function REPL({
remoteSessionConfig,
directConnectConfig,
sshSession,
thinkingConfig
thinkingConfig,
effortValueOverridesEnv
}: Props): React.ReactNode {
const isRemoteSession = !!remoteSessionConfig;
@@ -2434,6 +2437,7 @@ export function REPL({
} : s.agentDefinitions,
customSystemPrompt,
appendSystemPrompt,
effortValueOverridesEnv,
refreshTools: computeTools
},
getAppState: () => store.getState(),
+21
View File
@@ -61,6 +61,27 @@ describe('agent effort values', () => {
}
})
test('resolves Grok effort from the bundled Grok catalog', () => {
const originalOverride = process.env.CLAUDE_CODE_EFFORT_LEVEL
delete process.env.CLAUDE_CODE_EFFORT_LEVEL
try {
expect(modelSupportsEffort('grok-4.6')).toBe(true)
expect(modelSupportsXHighEffort('grok-4.6')).toBe(true)
expect(resolveAppliedEffort('grok-4.6', 'xhigh')).toBe('xhigh')
expect(resolveAppliedEffort('grok-4.6', 'max')).toBe('high')
expect(modelSupportsXHighEffort('grok-4.5')).toBe(false)
expect(resolveAppliedEffort('grok-4.5', 'xhigh')).toBe('high')
expect(modelSupportsEffort('grok-composer-2.5-fast')).toBe(false)
expect(resolveAppliedEffort('grok-composer-2.5-fast', 'xhigh')).toBe('high')
} finally {
if (originalOverride === undefined) {
delete process.env.CLAUDE_CODE_EFFORT_LEVEL
} else {
process.env.CLAUDE_CODE_EFFORT_LEVEL = originalOverride
}
}
})
test('lets request-scoped Agent effort override session env only when marked', () => {
const originalOverride = process.env.CLAUDE_CODE_EFFORT_LEVEL
try {
+18
View File
@@ -15,6 +15,7 @@ import {
getOpenAIModelCatalogEntry,
isOpenAIResponsesModel,
} from 'src/services/openaiAuth/models.js'
import { GROK_MODEL_CATALOG } from 'src/services/grokAuth/models.js'
export type EffortLevel = RuntimeEffortLevel | 'xhigh'
@@ -39,6 +40,11 @@ function shouldTrustBuiltInClaudeCapabilityList(): boolean {
)
}
function getGrokCatalogEntry(model: string): (typeof GROK_MODEL_CATALOG)[number] | undefined {
const normalized = model.trim().toLowerCase()
return GROK_MODEL_CATALOG.find((entry) => entry.value === normalized)
}
// @[MODEL LAUNCH]: Add the new model to the allowlist if it supports the effort parameter.
export function modelSupportsEffort(model: string): boolean {
const m = model.toLowerCase()
@@ -52,6 +58,10 @@ export function modelSupportsEffort(model: string): boolean {
if (isOpenAIResponsesModel(model)) {
return true
}
const grokEntry = getGrokCatalogEntry(model)
if (grokEntry) {
return grokEntry.supportsReasoningEffort !== false
}
// Supported by a subset of Claude 4 models
if (shouldTrustBuiltInClaudeCapabilityList() && (
m.includes('opus-4-6') ||
@@ -94,6 +104,10 @@ export function modelSupportsXHighEffort(model: string): boolean {
const entry = getOpenAIModelCatalogEntry(model)
return entry?.supportedReasoningEfforts.includes('xhigh') ?? true
}
const grokEntry = getGrokCatalogEntry(model)
if (grokEntry) {
return grokEntry.reasoningEfforts?.includes('xhigh') ?? false
}
const m = model.toLowerCase()
return shouldTrustBuiltInClaudeCapabilityList() && (
m.includes('opus-4-7') ||
@@ -114,6 +128,10 @@ export function modelSupportsMaxEffort(model: string): boolean {
const entry = getOpenAIModelCatalogEntry(model)
return entry?.supportedReasoningEfforts.includes('max') ?? true
}
const grokEntry = getGrokCatalogEntry(model)
if (grokEntry) {
return grokEntry.reasoningEfforts?.includes('max') ?? false
}
const m = model.toLowerCase()
if (shouldTrustBuiltInClaudeCapabilityList() && (
m.includes('opus-4-6') ||