mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
Fix Codex reasoning effort resume and updates
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
import { ApiClient, ApiSessionClient } from '@/lib';
|
||||
import { MessageQueue2 } from '@/utils/MessageQueue2';
|
||||
import type { Metadata, SessionCollaborationMode, SessionEffort, SessionModel, SessionPermissionMode } from '@/api/types';
|
||||
import type {
|
||||
Metadata,
|
||||
SessionCollaborationMode,
|
||||
SessionEffort,
|
||||
SessionModel,
|
||||
SessionModelReasoningEffort,
|
||||
SessionPermissionMode
|
||||
} from '@/api/types';
|
||||
import { logger } from '@/ui/logger';
|
||||
|
||||
export type AgentSessionBaseOptions<Mode> = {
|
||||
@@ -17,6 +24,7 @@ export type AgentSessionBaseOptions<Mode> = {
|
||||
applySessionIdToMetadata: (metadata: Metadata, sessionId: string) => Metadata;
|
||||
permissionMode?: SessionPermissionMode;
|
||||
model?: SessionModel;
|
||||
modelReasoningEffort?: SessionModelReasoningEffort;
|
||||
effort?: SessionEffort;
|
||||
collaborationMode?: SessionCollaborationMode;
|
||||
};
|
||||
@@ -40,6 +48,7 @@ export class AgentSessionBase<Mode> {
|
||||
private keepAliveInterval: NodeJS.Timeout | null = null;
|
||||
protected permissionMode?: SessionPermissionMode;
|
||||
protected model?: SessionModel;
|
||||
protected modelReasoningEffort?: SessionModelReasoningEffort;
|
||||
protected effort?: SessionEffort;
|
||||
protected collaborationMode?: SessionCollaborationMode;
|
||||
|
||||
@@ -57,6 +66,7 @@ export class AgentSessionBase<Mode> {
|
||||
this.mode = opts.mode ?? 'local';
|
||||
this.permissionMode = opts.permissionMode;
|
||||
this.model = opts.model;
|
||||
this.modelReasoningEffort = opts.modelReasoningEffort;
|
||||
this.effort = opts.effort;
|
||||
this.collaborationMode = opts.collaborationMode;
|
||||
|
||||
@@ -77,11 +87,12 @@ export class AgentSessionBase<Mode> {
|
||||
this.client.keepAlive(this.thinking, mode, this.getKeepAliveRuntime());
|
||||
const permissionLabel = this.permissionMode ?? 'unset';
|
||||
const modelLabel = this.model === undefined ? 'unset' : (this.model ?? 'auto');
|
||||
const modelReasoningEffortLabel = this.modelReasoningEffort === undefined ? 'unset' : (this.modelReasoningEffort ?? 'default');
|
||||
const effortLabel = this.effort === undefined ? 'unset' : (this.effort ?? 'auto');
|
||||
const collaborationLabel = this.collaborationMode ?? 'unset';
|
||||
logger.debug(
|
||||
`[${this.sessionLabel}] Mode switched to ${mode} ` +
|
||||
`(permissionMode=${permissionLabel}, model=${modelLabel}, effort=${effortLabel}, collaborationMode=${collaborationLabel})`
|
||||
`(permissionMode=${permissionLabel}, model=${modelLabel}, modelReasoningEffort=${modelReasoningEffortLabel}, effort=${effortLabel}, collaborationMode=${collaborationLabel})`
|
||||
);
|
||||
this._onModeChange(mode);
|
||||
};
|
||||
@@ -118,15 +129,23 @@ export class AgentSessionBase<Mode> {
|
||||
{
|
||||
permissionMode?: SessionPermissionMode
|
||||
model?: SessionModel
|
||||
modelReasoningEffort?: SessionModelReasoningEffort
|
||||
effort?: SessionEffort
|
||||
collaborationMode?: SessionCollaborationMode
|
||||
} | undefined {
|
||||
if (this.permissionMode === undefined && this.model === undefined && this.effort === undefined && this.collaborationMode === undefined) {
|
||||
if (
|
||||
this.permissionMode === undefined
|
||||
&& this.model === undefined
|
||||
&& this.modelReasoningEffort === undefined
|
||||
&& this.effort === undefined
|
||||
&& this.collaborationMode === undefined
|
||||
) {
|
||||
return undefined;
|
||||
}
|
||||
return {
|
||||
permissionMode: this.permissionMode,
|
||||
model: this.model,
|
||||
modelReasoningEffort: this.modelReasoningEffort,
|
||||
effort: this.effort,
|
||||
collaborationMode: this.collaborationMode
|
||||
};
|
||||
@@ -140,6 +159,10 @@ export class AgentSessionBase<Mode> {
|
||||
return this.model;
|
||||
}
|
||||
|
||||
getModelReasoningEffort(): SessionModelReasoningEffort | undefined {
|
||||
return this.modelReasoningEffort;
|
||||
}
|
||||
|
||||
getEffort(): SessionEffort | undefined {
|
||||
return this.effort;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ export type SessionBootstrapOptions = {
|
||||
tag?: string
|
||||
agentState?: AgentState | null
|
||||
model?: string
|
||||
modelReasoningEffort?: string
|
||||
effort?: string
|
||||
metadataOverrides?: Partial<Metadata>
|
||||
}
|
||||
@@ -133,6 +134,7 @@ export async function bootstrapSession(options: SessionBootstrapOptions): Promis
|
||||
metadata,
|
||||
state: agentState,
|
||||
model: options.model,
|
||||
modelReasoningEffort: options.modelReasoningEffort,
|
||||
effort: options.effort
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user