4226
4227
resolveSessionConfig(params: IAgentResolveSessionConfigParams): Promise<ResolveSessionConfigResult> {
4228
>
const values = codexSessionConfigSchema.validateOrDefault(params.config, codexSessionConfigDefaults);
codexAgent.ts
4229
>
const schema = codexVisibleSessionConfigSchema.toProtocol();
4230
>
// Preserve every value the caller previously persisted. This return
4231
>
// REPLACES the stored session config on restore (see
4232
>
// `AgentService._resolveCreatedSessionConfig`), so cherry-picking only
4233
>
// the visible keys here would reset all the others (reasoning effort,
4234
>
// personality, sandbox axes, …) back to their defaults on resume.
4235
>
const resolvedValues: Record<string, unknown> = {
4236
>
...params.config,
4237
>
[SessionConfigKey.Mode]: values[SessionConfigKey.Mode],
4238
>
};
4239
>
// Migrate the permission axes off the raw config. `validateOrDefault`
4240
>
// always materializes `permissionsPreset='default'`, but blindly storing
4241
>
// that would silently escalate a legacy session that persisted only the
4242
>
// individual `sandboxMode`/`approvalPolicy` axes (e.g. `read-only`) —
4243
>
// `resolveCodexPermissions` checks the preset first. Drop all three
4244
>
// permission keys, then re-apply only the ones the migration decides are
4245
>
// safe (an explicit or exactly-equivalent preset, else the raw axes).
4246
>
delete resolvedValues[CodexSessionConfigKey.PermissionsPreset];
4247
>
delete resolvedValues[CodexSessionConfigKey.ApprovalPolicy];
4248
>
delete resolvedValues[CodexSessionConfigKey.SandboxMode];
4249
>
Object.assign(resolvedValues, migrateCodexPermissionValues(params.config, {
4250
>
approvalPolicy: codexSessionConfigDefaults[CodexSessionConfigKey.ApprovalPolicy],
4251
>
sandboxMode: codexSessionConfigDefaults[CodexSessionConfigKey.SandboxMode],
4252
>
}));
4253
>
return Promise.resolve({ values: resolvedValues, schema });
4254
>
}
4255
4256
async sessionConfigCompletions(params: IAgentSessionConfigCompletionsParams): Promise<SessionConfigCompletionsResult> {