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
1 change: 1 addition & 0 deletions codex-cli/src/lib/text-buffer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint‑disable no-bitwise */

export type Direction =
| "left"
| "right"
Expand Down
23 changes: 11 additions & 12 deletions codex-cli/src/utils/agent/agent-loop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ type AgentLoopParams = {
onItem: (item: ResponseItem) => void;
onLoading: (loading: boolean) => void;

/**
* Used to reach out to the user only if the command is not auto-approved.
*/
/** Called when the command is not auto-approved to request explicit user review. */
getCommandConfirmation: (
command: Array<string>,
applyPatch: ApplyPatchCommand | undefined,
Expand All @@ -53,12 +51,12 @@ export class AgentLoop {
private instructions?: string;
private approvalPolicy: ApprovalPolicy;
private config: AppConfig;
// Using `InstanceType<typeof OpenAI>` sidesteps typing issues with the
// OpenAI package under the TS 5+ `moduleResolution=bundler` setup.
// OpenAI client instance. We keep the concrete type to avoid sprinkling
// `any` across the implementation while still allowing paths where the
// OpenAI SDK types may not perfectly match. The `typeof OpenAI` pattern
// captures the instance shape without resorting to `any`.

// Using `InstanceType<typeof OpenAI>` sidesteps typing issues with the OpenAI package under
// the TS 5+ `moduleResolution=bundler` setup. OpenAI client instance. We keep the concrete
// type to avoid sprinkling `any` across the implementation while still allowing paths where
// the OpenAI SDK types may not perfectly match. The `typeof OpenAI` pattern captures the
// instance shape without resorting to `any`.
private oai: OpenAI;

private onItem: (item: ResponseItem) => void;
Expand Down Expand Up @@ -688,7 +686,7 @@ export class AgentLoop {
// process and surface each item (no‑op until we can depend on streaming events)
if (event.type === "response.output_item.done") {
const item = event.item;
// if it's a reasoning item, annotate it
// 1) if it's a reasoning item, annotate it
type ReasoningItem = { type?: string; duration_ms?: number };
const maybeReasoning = item as ReasoningItem;
if (maybeReasoning.type === "reasoning") {
Expand Down Expand Up @@ -776,7 +774,7 @@ export class AgentLoop {
// thinking times so UIs and tests can surface/verify them.
// const thinkingEnd = Date.now();

// Per‑turn measurement – exact time spent between request and
// 1) Per‑turn measurement – exact time spent between request and
// response for *this* command.
// this.onItem({
// id: `thinking-${thinkingEnd}`,
Expand All @@ -792,7 +790,7 @@ export class AgentLoop {
// ],
// });

// Session‑wide cumulative counter so users can track overall wait
// 2) Session‑wide cumulative counter so users can track overall wait
// time across multiple turns.
// this.cumulativeThinkingMs += thinkingEnd - thinkingStart;
// this.onItem({
Expand Down Expand Up @@ -975,6 +973,7 @@ export class AgentLoop {
}

const prefix = `You are operating as and within the Codex CLI, a terminal-based agentic coding assistant built by OpenAI. It wraps OpenAI models to enable natural language interaction with a local codebase. You are expected to be precise, safe, and helpful.

You can:
- Receive user prompts, project context, and files.
- Stream responses and emit function calls (e.g., shell commands, code edits).
Expand Down
3 changes: 3 additions & 0 deletions codex-cli/src/utils/agent/apply-patch.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Based on reference implementation from
// https://cookbook.openai.com/examples/gpt4-1_prompting_guide#reference-implementation-apply_patchpy

import fs from "fs";
import path from "path";

Expand Down
Loading