Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions codex-cli/src/utils/agent/agent-loop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -679,13 +679,18 @@ export class AgentLoop {
const MAX_RETRIES = 8;
for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {
try {
let reasoning: Reasoning | undefined;
if (this.model.startsWith("o")) {
reasoning = { effort: this.config.reasoningEffort ?? "high" };
if (this.model === "o3" || this.model === "o4-mini") {
reasoning.summary = "auto";
}
// only set reasoning when using an "o*" (Codex) model
const isCodex = this.model.startsWith("o");
const reasoningParam = isCodex
? {
reasoning: {
effort: this.config.reasoningEffort ?? "high",
...(this.model === "o3" || this.model === "o4-mini"
? { summary: "auto" }
: {}),
},
}
: {};
const mergedInstructions = [prefix, this.instructions]
.filter(Boolean)
.join("\n");
Expand All @@ -705,14 +710,14 @@ export class AgentLoop {
);

// eslint-disable-next-line no-await-in-loop
stream = await responseCall({
model: this.model,
instructions: mergedInstructions,
input: turnInput,
stream: true,
parallel_tool_calls: false,
reasoning,
...(this.config.flexMode ? { service_tier: "flex" } : {}),
stream = await responseCall({
model: this.model,
instructions: mergedInstructions,
input: turnInput,
stream: true,
parallel_tool_calls: false,
...reasoningParam,
...(this.config.flexMode ? { service_tier: "flex" } : {}),
...(this.disableResponseStorage
? { store: false }
: {
Expand Down
15 changes: 11 additions & 4 deletions codex-rs/core/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,17 +175,24 @@ impl ModelClient {
return stream_from_fixture(path).await;
}

// only include reasoning on "o*" (Codex) models
let reasoning_field = if self.model.starts_with('o') {
Some(Reasoning {
effort: "high",
generate_summary: None,
})
} else {
None
};

let payload = Payload {
model: &self.model,
instructions: prompt.instructions.as_ref(),
input: &prompt.input,
tools: &TOOLS,
tool_choice: "auto",
parallel_tool_calls: false,
reasoning: Some(Reasoning {
effort: "high",
generate_summary: None,
}),
reasoning: reasoning_field,
previous_response_id: prompt.prev_id.clone(),
store: prompt.store,
stream: true,
Expand Down
Loading