挑战Claude Code?OpenAI Codex发布月将至,今先揭秘智能体循环
机器之心·2026-01-24 04:09

Core Insights - OpenAI's CEO Sam Altman announced an upcoming series of exciting releases related to Codex, particularly emphasizing cybersecurity [1] - OpenAI released a technical blog titled "Unrolling the Codex Agent Loop," which details the core architecture of Codex CLI and its functionalities [3][4] Group 1: Codex Overview - Codex CLI is a cross-platform local software agent developed by OpenAI that can generate high-quality software changes [7] - OpenAI has accumulated significant experience in building world-class software agents since the initial release of CLI in April [8] Group 2: Agent Loop Mechanism - The agent loop is the core logic of Codex CLI, coordinating interactions between users, models, and tools for executing software tasks [10] - The agent loop consists of several steps: input acquisition, inference, decoding, decision-making, execution, and retry until a final response is generated [16][17] Group 3: Model Inference and API Interaction - Codex CLI operates model inference by sending HTTP requests to the Responses API, which drives the agent loop [22][23] - The Responses API endpoints used by Codex CLI are configurable, allowing integration with various implementations [24][25] Group 4: Prompt Construction - The initial prompt for the Responses API is constructed based on user inputs and various roles, including system, developer, user, and assistant [28][30] - Codex appends user messages to the input after constructing the initial prompt, facilitating the start of the dialogue [33] Group 5: Performance Considerations - The JSON payload sent to the Responses API can grow quadratically during conversations, but Codex currently avoids using the previous_response_id parameter to maintain statelessness [51] - Prompt caching is crucial for efficiency, allowing Codex to reuse previous inference results and reduce computational costs [52][53] Group 6: Context Management - Codex employs a strategy of compressing dialogue once the token count exceeds a certain threshold, replacing the input with a smaller representation to continue the conversation [58][59] - The Responses API has evolved to support a compact endpoint for more efficient dialogue compression [58] Group 7: Future Directions - The blog introduces the Codex agent loop and discusses practical considerations for developers building agent loops on top of the Responses API [61] - Future articles will delve deeper into the architecture of CLI, exploring tool invocation implementations and the sandbox model of Codex [63]