mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-08 01:43:07 +00:00
fix(codex): preserve reasoning effort across mode switches
This commit is contained in:
+16
-10
@@ -88,7 +88,9 @@ export async function runCodex(opts: {
|
||||
?? (persistedPermissionMode && isPermissionModeAllowedForFlavor(persistedPermissionMode, 'codex') ? persistedPermissionMode as PermissionMode : undefined)
|
||||
?? 'default';
|
||||
let currentModel = opts.model;
|
||||
let currentModelReasoningEffort: ReasoningEffort | undefined = opts.modelReasoningEffort;
|
||||
// Three states matter here: `undefined` inherits Codex configuration,
|
||||
// `null` explicitly clears a HAPI override, and a string explicitly sets it.
|
||||
let currentModelReasoningEffort: ReasoningEffort | null | undefined = opts.modelReasoningEffort;
|
||||
let currentCollaborationMode: EnhancedMode['collaborationMode'] = opts.collaborationMode ?? 'default';
|
||||
let currentProactiveMultiAgent: boolean | undefined;
|
||||
// Service tier (Fast mode), stored representation: `'fast'` and
|
||||
@@ -118,7 +120,11 @@ export async function runCodex(opts: {
|
||||
if (options?.syncModel !== false) {
|
||||
sessionInstance.setModel(currentModel ?? null);
|
||||
}
|
||||
sessionInstance.setModelReasoningEffort(currentModelReasoningEffort ?? null);
|
||||
// Do not collapse inherited Codex config into an explicit default.
|
||||
// Explicit clears remain `null` and must still be synchronized.
|
||||
if (currentModelReasoningEffort !== undefined) {
|
||||
sessionInstance.setModelReasoningEffort(currentModelReasoningEffort);
|
||||
}
|
||||
// Preserve the third state: only sync when the user/persisted session
|
||||
// has an explicit tier. `undefined` means "omit" so the keepalive does
|
||||
// not overwrite the account-default or persisted Fast tier with null.
|
||||
@@ -149,7 +155,7 @@ export async function runCodex(opts: {
|
||||
currentModel = updates.model ?? undefined;
|
||||
}
|
||||
if (updates.modelReasoningEffort !== undefined) {
|
||||
currentModelReasoningEffort = updates.modelReasoningEffort ?? undefined;
|
||||
currentModelReasoningEffort = updates.modelReasoningEffort;
|
||||
}
|
||||
if (updates.collaborationMode !== undefined) {
|
||||
currentCollaborationMode = updates.collaborationMode;
|
||||
@@ -174,7 +180,7 @@ export async function runCodex(opts: {
|
||||
}
|
||||
const sessionModelReasoningEffort = sessionWrapperRef.current?.getModelReasoningEffort();
|
||||
if (sessionModelReasoningEffort !== undefined) {
|
||||
currentModelReasoningEffort = (sessionModelReasoningEffort ?? undefined) as ReasoningEffort | undefined;
|
||||
currentModelReasoningEffort = sessionModelReasoningEffort as ReasoningEffort | null;
|
||||
}
|
||||
const sessionCollaborationMode = sessionWrapperRef.current?.getCollaborationMode();
|
||||
if (sessionCollaborationMode) {
|
||||
@@ -199,7 +205,7 @@ export async function runCodex(opts: {
|
||||
permissionMode: currentPermissionMode,
|
||||
collaborationMode: currentCollaborationMode,
|
||||
model: currentModel,
|
||||
modelReasoningEffort: currentModelReasoningEffort,
|
||||
modelReasoningEffort: currentModelReasoningEffort ?? undefined,
|
||||
serviceTier: currentServiceTier,
|
||||
proactiveMultiAgent: currentProactiveMultiAgent
|
||||
});
|
||||
@@ -219,7 +225,7 @@ export async function runCodex(opts: {
|
||||
messageQueue.pushIsolateAndClear(goalCommand, {
|
||||
permissionMode: currentPermissionMode ?? 'default',
|
||||
model: currentModel,
|
||||
modelReasoningEffort: currentModelReasoningEffort,
|
||||
modelReasoningEffort: currentModelReasoningEffort ?? undefined,
|
||||
collaborationMode: currentCollaborationMode,
|
||||
serviceTier: currentServiceTier
|
||||
}, localId);
|
||||
@@ -258,7 +264,7 @@ export async function runCodex(opts: {
|
||||
const enhancedMode: EnhancedMode = {
|
||||
permissionMode: messagePermissionMode ?? 'default',
|
||||
model: currentModel,
|
||||
modelReasoningEffort: currentModelReasoningEffort,
|
||||
modelReasoningEffort: currentModelReasoningEffort ?? undefined,
|
||||
collaborationMode: currentCollaborationMode,
|
||||
proactiveMultiAgent: currentProactiveMultiAgent,
|
||||
serviceTier: currentServiceTier
|
||||
@@ -273,7 +279,7 @@ export async function runCodex(opts: {
|
||||
const enhancedMode: EnhancedMode = {
|
||||
permissionMode: currentPermissionMode ?? 'default',
|
||||
model: currentModel,
|
||||
modelReasoningEffort: currentModelReasoningEffort,
|
||||
modelReasoningEffort: currentModelReasoningEffort ?? undefined,
|
||||
collaborationMode: currentCollaborationMode,
|
||||
proactiveMultiAgent: currentProactiveMultiAgent,
|
||||
serviceTier: currentServiceTier
|
||||
@@ -367,7 +373,7 @@ export async function runCodex(opts: {
|
||||
}
|
||||
|
||||
if (config.modelReasoningEffort !== undefined) {
|
||||
currentModelReasoningEffort = parseReasoningEffortValue(config.modelReasoningEffort);
|
||||
currentModelReasoningEffort = parseReasoningEffortValue(config.modelReasoningEffort) ?? null;
|
||||
}
|
||||
|
||||
if (config.collaborationMode !== undefined) {
|
||||
@@ -413,7 +419,7 @@ export async function runCodex(opts: {
|
||||
startedBy,
|
||||
permissionMode: currentPermissionMode,
|
||||
model: currentModel,
|
||||
modelReasoningEffort: currentModelReasoningEffort,
|
||||
modelReasoningEffort: currentModelReasoningEffort ?? undefined,
|
||||
collaborationMode: currentCollaborationMode,
|
||||
resumeSessionId: opts.resumeSessionId,
|
||||
sourceSessionId: codexSourceSessionId,
|
||||
|
||||
Reference in New Issue
Block a user