feat: add --reasoning CLI flag (#314)
This PR adds a new CLI flag: `--reasoning`, which allows users to customize the reasoning effort level (`low`, `medium`, or `high`) used by OpenAI's `o` models. By introducing the `--reasoning` flag, users gain more flexibility when working with the models. It enables optimization for either speed or depth of reasoning, depending on specific use cases. This PR resolves #107 - **Flag**: `--reasoning` - **Accepted Values**: `low`, `medium`, `high` - **Default Behavior**: If not specified, the model uses the default reasoning level. ## Example Usage ```bash codex --reasoning=low "Write a simple function to calculate factorial" --------- Co-authored-by: Fouad Matin <169186268+fouad-openai@users.noreply.github.com> Co-authored-by: yashrwealthy <yash.rastogi@wealthy.in> Co-authored-by: Thibault Sottiaux <tibo@openai.com>
This commit is contained in:
@@ -676,7 +676,7 @@ export class AgentLoop {
|
||||
try {
|
||||
let reasoning: Reasoning | undefined;
|
||||
if (this.model.startsWith("o")) {
|
||||
reasoning = { effort: "high" };
|
||||
reasoning = { effort: this.config.reasoningEffort ?? "high" };
|
||||
if (this.model === "o3" || this.model === "o4-mini") {
|
||||
reasoning.summary = "auto";
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
// compiled `dist/` output used by the published CLI.
|
||||
|
||||
import type { FullAutoErrorMode } from "./auto-approval-mode.js";
|
||||
import type { ReasoningEffort } from "openai/resources.mjs";
|
||||
|
||||
import { AutoApprovalMode } from "./auto-approval-mode.js";
|
||||
import { log } from "./logger/log.js";
|
||||
@@ -62,6 +63,8 @@ export const OPENAI_TIMEOUT_MS =
|
||||
parseInt(process.env["OPENAI_TIMEOUT_MS"] || "0", 10) || undefined;
|
||||
export const OPENAI_BASE_URL = process.env["OPENAI_BASE_URL"] || "";
|
||||
export let OPENAI_API_KEY = process.env["OPENAI_API_KEY"] || "";
|
||||
|
||||
export const DEFAULT_REASONING_EFFORT = "high";
|
||||
export const OPENAI_ORGANIZATION = process.env["OPENAI_ORGANIZATION"] || "";
|
||||
export const OPENAI_PROJECT = process.env["OPENAI_PROJECT"] || "";
|
||||
|
||||
@@ -142,6 +145,9 @@ export type StoredConfig = {
|
||||
saveHistory?: boolean;
|
||||
sensitivePatterns?: Array<string>;
|
||||
};
|
||||
/** User-defined safe commands */
|
||||
safeCommands?: Array<string>;
|
||||
reasoningEffort?: ReasoningEffort;
|
||||
};
|
||||
|
||||
// Minimal config written on first run. An *empty* model string ensures that
|
||||
@@ -165,6 +171,7 @@ export type AppConfig = {
|
||||
approvalMode?: AutoApprovalMode;
|
||||
fullAutoErrorMode?: FullAutoErrorMode;
|
||||
memory?: MemoryConfig;
|
||||
reasoningEffort?: ReasoningEffort;
|
||||
/** Whether to enable desktop notifications for responses */
|
||||
notify?: boolean;
|
||||
|
||||
@@ -366,6 +373,7 @@ export const loadConfig = (
|
||||
notify: storedConfig.notify === true,
|
||||
approvalMode: storedConfig.approvalMode,
|
||||
disableResponseStorage: storedConfig.disableResponseStorage ?? false,
|
||||
reasoningEffort: storedConfig.reasoningEffort,
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
@@ -480,6 +488,7 @@ export const saveConfig = (
|
||||
provider: config.provider,
|
||||
providers: config.providers,
|
||||
approvalMode: config.approvalMode,
|
||||
reasoningEffort: config.reasoningEffort,
|
||||
};
|
||||
|
||||
// Add history settings if they exist
|
||||
|
||||
Reference in New Issue
Block a user