Lightweight coding agent that runs in your terminal
Rust
Rename assistant message to agent message and fix item type field naming (#4610)
pakrym-oaic405d8c06c87
diff --git a/codex-rs/exec/src/event_processor_with_jsonl_output.rs b/codex-rs/exec/src/event_processor_with_jsonl_output.rsindex b3c82fc943..51ecd71a9b 100644--- a/codex-rs/exec/src/event_processor_with_jsonl_output.rs+++ b/codex-rs/exec/src/event_processor_with_jsonl_output.rs@@ -5,7 +5,7 @@ use std::sync::atomic::AtomicU64;use crate::event_processor::CodexStatus;use crate::event_processor::EventProcessor;use crate::event_processor::handle_last_message;-use crate::exec_events::AssistantMessageItem;+use crate::exec_events::AgentMessageItem;use crate::exec_events::CommandExecutionItem;use crate::exec_events::CommandExecutionStatus;use crate::exec_events::FileChangeItem;@@ -162,7 +162,7 @@ impl EventProcessorWithJsonOutput {let item = ThreadItem {id: self.get_next_item_id(),- details: ThreadItemDetails::AssistantMessage(AssistantMessageItem {+ details: ThreadItemDetails::AgentMessage(AgentMessageItem {text: payload.message.clone(),}),};diff --git a/codex-rs/exec/src/exec_events.rs b/codex-rs/exec/src/exec_events.rsindex 4ea57e19b5..606cf9187a 100644--- a/codex-rs/exec/src/exec_events.rs+++ b/codex-rs/exec/src/exec_events.rs@@ -95,11 +95,11 @@ pub struct ThreadItem {/// Typed payloads for each supported thread item type.#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, TS)]-#[serde(tag = "item_type", rename_all = "snake_case")]+#[serde(tag = "type", rename_all = "snake_case")]pub enum ThreadItemDetails {/// Response from the agent./// Either a natural-language response or a JSON string when structured output is requested.- AssistantMessage(AssistantMessageItem),+ AgentMessage(AgentMessageItem),/// Agent's reasoning summary.Reasoning(ReasoningItem),/// Tracks a command executed by the agent. The item starts when the command is@@ -124,7 +124,7 @@ pub enum ThreadItemDetails {/// Response from the agent./// Either a natural-language response or a JSON string when structured output is requested.#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, TS)]-pub struct AssistantMessageItem {+pub struct AgentMessageItem {pub text: String,}diff --git a/codex-rs/exec/tests/event_processor_with_json_output.rs b/codex-rs/exec/tests/event_processor_with_json_output.rsindex 9cbff57943..b6475ad111 100644--- a/codex-rs/exec/tests/event_processor_with_json_output.rs+++ b/codex-rs/exec/tests/event_processor_with_json_output.rs@@ -14,7 +14,7 @@ use codex_core::protocol::PatchApplyEndEvent;use codex_core::protocol::SessionConfiguredEvent;use codex_core::protocol::WebSearchEndEvent;use codex_exec::event_processor_with_jsonl_output::EventProcessorWithJsonOutput;-use codex_exec::exec_events::AssistantMessageItem;+use codex_exec::exec_events::AgentMessageItem;use codex_exec::exec_events::CommandExecutionItem;use codex_exec::exec_events::CommandExecutionStatus;use codex_exec::exec_events::ItemCompletedEvent;@@ -410,7 +410,7 @@ fn agent_reasoning_produces_item_completed_reasoning() {}#[test]-fn agent_message_produces_item_completed_assistant_message() {+fn agent_message_produces_item_completed_agent_message() {let mut ep = EventProcessorWithJsonOutput::new(None);let ev = event("e1",@@ -424,7 +424,7 @@ fn agent_message_produces_item_completed_assistant_message() {vec![ThreadEvent::ItemCompleted(ItemCompletedEvent {item: ThreadItem {id: "item_0".to_string(),- details: ThreadItemDetails::AssistantMessage(AssistantMessageItem {+ details: ThreadItemDetails::AgentMessage(AgentMessageItem {text: "hello".to_string(),}),},diff --git a/sdk/typescript/samples/basic_streaming.ts b/sdk/typescript/samples/basic_streaming.tsindex 97098d8a69..e78a0d41ac 100755--- a/sdk/typescript/samples/basic_streaming.ts+++ b/sdk/typescript/samples/basic_streaming.ts@@ -16,8 +16,8 @@ const thread = codex.startThread();const rl = createInterface({ input, output });const handleItemCompleted = (item: ThreadItem): void => {- switch (item.item_type) {- case "assistant_message":+ switch (item.type) {+ case "agent_message":console.log(`Assistant: ${item.text}`);break;case "reasoning":@@ -38,7 +38,7 @@ const handleItemCompleted = (item: ThreadItem): void => {};const handleItemUpdated = (item: ThreadItem): void => {- switch (item.item_type) {+ switch (item.type) {case "todo_list": {console.log(`Todo:`);for (const todo of item.items) {diff --git a/sdk/typescript/src/index.ts b/sdk/typescript/src/index.tsindex b759b3c68f..fc8383f363 100644--- a/sdk/typescript/src/index.ts+++ b/sdk/typescript/src/index.ts@@ -12,7 +12,7 @@ export type {} from "./events";export type {ThreadItem,- AssistantMessageItem,+ AgentMessageItem,ReasoningItem,CommandExecutionItem,FileChangeItem,diff --git a/sdk/typescript/src/items.ts b/sdk/typescript/src/items.tsindex 85f54d78ca..37563f9af9 100644--- a/sdk/typescript/src/items.ts+++ b/sdk/typescript/src/items.ts@@ -6,7 +6,7 @@ export type CommandExecutionStatus = "in_progress" | "completed" | "failed";/** A command executed by the agent. */export type CommandExecutionItem = {id: string;- item_type: "command_execution";+ type: "command_execution";/** The command line executed by the agent. */command: string;/** Aggregated stdout and stderr captured while the command was running. */@@ -32,7 +32,7 @@ export type PatchApplyStatus = "completed" | "failed";/** A set of file changes by the agent. Emitted once the patch succeeds or fails. */export type FileChangeItem = {id: string;- item_type: "file_change";+ type: "file_change";/** Individual file changes that comprise the patch. */changes: FileUpdateChange[];/** Whether the patch ultimately succeeded or failed. */@@ -48,7 +48,7 @@ export type McpToolCallStatus = "in_progress" | "completed" | "failed";*/export type McpToolCallItem = {id: string;- item_type: "mcp_tool_call";+ type: "mcp_tool_call";/** Name of the MCP server handling the request. */server: string;/** The tool invoked on the MCP server. */@@ -58,9 +58,9 @@ export type McpToolCallItem = {};/** Response from the agent. Either natural-language text or JSON when structured output is requested. */-export type AssistantMessageItem = {+export type AgentMessageItem = {id: string;- item_type: "assistant_message";+ type: "agent_message";/** Either natural-language text or JSON when structured output is requested. */text: string;};@@ -68,21 +68,21 @@ export type AssistantMessageItem = {/** Agent's reasoning summary. */export type ReasoningItem = {id: string;- item_type: "reasoning";+ type: "reasoning";text: string;};/** Captures a web search request. Completes when results are returned to the agent. */export type WebSearchItem = {id: string;- item_type: "web_search";+ type: "web_search";query: string;};/** Describes a non-fatal error surfaced as an item. */export type ErrorItem = {id: string;- item_type: "error";+ type: "error";message: string;};@@ -98,19 +98,19 @@ export type TodoItem = {*/export type TodoListItem = {id: string;- item_type: "todo_list";+ type: "todo_list";items: TodoItem[];};export type SessionItem = {id: string;- item_type: "session";+ type: "session";session_id: string;};/** Canonical union of thread items and their type-specific payloads. */export type ThreadItem =- | AssistantMessageItem+ | AgentMessageItem| ReasoningItem| CommandExecutionItem| FileChangeItemdiff --git a/sdk/typescript/src/thread.ts b/sdk/typescript/src/thread.tsindex fe32a27136..b710fec399 100644--- a/sdk/typescript/src/thread.ts+++ b/sdk/typescript/src/thread.ts@@ -87,7 +87,7 @@ export class Thread {let finalResponse: string = "";for await (const event of generator) {if (event.type === "item.completed") {- if (event.item.item_type === "assistant_message") {+ if (event.item.type === "agent_message") {finalResponse = event.item.text;}items.push(event.item);diff --git a/sdk/typescript/tests/run.test.ts b/sdk/typescript/tests/run.test.tsindex 357d8cd0db..17cdae09e6 100644--- a/sdk/typescript/tests/run.test.ts+++ b/sdk/typescript/tests/run.test.ts@@ -33,7 +33,7 @@ describe("Codex", () => {const expectedItems = [{id: expect.any(String),- item_type: "assistant_message",+ type: "agent_message",text: "Hi!",},];diff --git a/sdk/typescript/tests/runStreamed.test.ts b/sdk/typescript/tests/runStreamed.test.tsindex 1db273b98a..f95203ae3b 100644--- a/sdk/typescript/tests/runStreamed.test.ts+++ b/sdk/typescript/tests/runStreamed.test.ts@@ -45,7 +45,7 @@ describe("Codex", () => {type: "item.completed",item: {id: "item_0",- item_type: "assistant_message",+ type: "agent_message",text: "Hi!",},},