mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
fix(codex): apply reasoning effort correctly
This commit is contained in:
@@ -92,4 +92,25 @@ describe('codexLocal', () => {
|
||||
expect(hookArg).toContain('{ hooks = [{ type = "command", command = "');
|
||||
expect(args).toContain("mcp_servers.hapi.args=['mcp','--url','http://127.0.0.1:63995/']");
|
||||
});
|
||||
|
||||
it('passes reasoning effort through Codex config instead of an unsupported CLI flag', async () => {
|
||||
const controller = new AbortController();
|
||||
|
||||
await codexLocal({
|
||||
abort: controller.signal,
|
||||
sessionId: 'codex-session-1',
|
||||
path: '/workspace/project',
|
||||
modelReasoningEffort: 'high',
|
||||
onSessionFound: vi.fn()
|
||||
});
|
||||
|
||||
expect(spawnWithTerminalGuardMock).toHaveBeenCalledOnce();
|
||||
const spawnOptions = spawnWithTerminalGuardMock.mock.calls[0][0] as {
|
||||
args: string[];
|
||||
};
|
||||
|
||||
expect(spawnOptions.args).toContain('-c');
|
||||
expect(spawnOptions.args).toContain('model_reasoning_effort="high"');
|
||||
expect(spawnOptions.args).not.toContain('--model-reasoning-effort');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,7 +3,8 @@ import { spawnWithTerminalGuard } from '@/utils/spawnWithTerminalGuard';
|
||||
import {
|
||||
buildMcpServerConfigArgs,
|
||||
buildDeveloperInstructionsArg,
|
||||
buildSessionStartHookConfigArgs
|
||||
buildSessionStartHookConfigArgs,
|
||||
buildModelReasoningEffortConfigArgs
|
||||
} from './utils/codexMcpConfig';
|
||||
import { codexSystemPrompt } from './utils/systemPrompt';
|
||||
import type { ReasoningEffort } from './appServerTypes';
|
||||
@@ -54,7 +55,7 @@ export async function codexLocal(opts: {
|
||||
}
|
||||
|
||||
if (opts.modelReasoningEffort) {
|
||||
args.push('--model-reasoning-effort', opts.modelReasoningEffort);
|
||||
args.push(...buildModelReasoningEffortConfigArgs(opts.modelReasoningEffort));
|
||||
}
|
||||
|
||||
if (opts.sandbox) {
|
||||
|
||||
@@ -130,6 +130,7 @@ describe('appServerConfig', () => {
|
||||
mode: 'default',
|
||||
settings: {
|
||||
model: 'o3',
|
||||
reasoning_effort: 'high',
|
||||
developer_instructions: withCollaborationInstructions(codexSystemPrompt)
|
||||
}
|
||||
});
|
||||
@@ -155,6 +156,7 @@ describe('appServerConfig', () => {
|
||||
mode: 'default',
|
||||
settings: {
|
||||
model: 'gpt-5.3-codex-spark',
|
||||
reasoning_effort: 'high',
|
||||
developer_instructions: withCollaborationInstructions(codexSystemPrompt)
|
||||
}
|
||||
});
|
||||
@@ -236,6 +238,7 @@ describe('appServerConfig', () => {
|
||||
mode: 'plan',
|
||||
settings: {
|
||||
model: 'o3',
|
||||
reasoning_effort: 'high',
|
||||
developer_instructions: withCollaborationInstructions(codexSystemPrompt)
|
||||
}
|
||||
});
|
||||
@@ -255,6 +258,7 @@ describe('appServerConfig', () => {
|
||||
mode: 'plan',
|
||||
settings: {
|
||||
model: 'o3',
|
||||
reasoning_effort: null,
|
||||
developer_instructions: withCollaborationInstructions(`${codexSystemPrompt}\n\nOnly respond in Chinese.`)
|
||||
}
|
||||
});
|
||||
@@ -299,6 +303,7 @@ describe('appServerConfig', () => {
|
||||
mode: 'default',
|
||||
settings: {
|
||||
model: 'o3',
|
||||
reasoning_effort: null,
|
||||
developer_instructions: withCollaborationInstructions(codexSystemPrompt)
|
||||
}
|
||||
});
|
||||
@@ -319,6 +324,7 @@ describe('appServerConfig', () => {
|
||||
mode: 'default',
|
||||
settings: {
|
||||
model: 'o3',
|
||||
reasoning_effort: null,
|
||||
developer_instructions: withCollaborationInstructions(codexSystemPrompt)
|
||||
}
|
||||
});
|
||||
@@ -338,6 +344,7 @@ describe('appServerConfig', () => {
|
||||
mode: 'default',
|
||||
settings: {
|
||||
model: 'gpt-5',
|
||||
reasoning_effort: null,
|
||||
developer_instructions: withCollaborationInstructions(codexSystemPrompt)
|
||||
}
|
||||
});
|
||||
|
||||
@@ -168,9 +168,10 @@ export function buildTurnStartParams(args: {
|
||||
? undefined
|
||||
: args.mode?.collaborationMode;
|
||||
const model = args.overrides?.model ?? args.mode?.model;
|
||||
const modelReasoningEffort = args.mode?.modelReasoningEffort;
|
||||
|
||||
if (args.mode?.modelReasoningEffort) {
|
||||
params.effort = args.mode.modelReasoningEffort;
|
||||
if (modelReasoningEffort) {
|
||||
params.effort = modelReasoningEffort;
|
||||
if (!collaborationMode && supportsReasoningSummary(model)) {
|
||||
params.summary = 'detailed';
|
||||
}
|
||||
@@ -185,6 +186,7 @@ export function buildTurnStartParams(args: {
|
||||
mode: collaborationMode,
|
||||
settings: {
|
||||
model,
|
||||
reasoning_effort: modelReasoningEffort ?? null,
|
||||
developer_instructions: appendCollaborationInstructions(developerInstructions)
|
||||
}
|
||||
};
|
||||
|
||||
@@ -151,3 +151,7 @@ export function buildDeveloperInstructionsArg(instructions: string): string[] {
|
||||
const escaped = escapeTomlString(instructions);
|
||||
return ['-c', `developer_instructions="${escaped}"`];
|
||||
}
|
||||
|
||||
export function buildModelReasoningEffortConfigArgs(effort: string): string[] {
|
||||
return ['-c', `model_reasoning_effort="${escapeTomlString(effort)}"`];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user