Rename assistant message to agent message and fix item type field naming (#4610)

Naming cleanup
This commit is contained in:
pakrym-oai
2025-10-02 15:07:14 -07:00
committed by GitHub
parent 138be0fd73
commit c405d8c06c
9 changed files with 26 additions and 26 deletions

View File

@@ -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) {

View File

@@ -12,7 +12,7 @@ export type {
} from "./events";
export type {
ThreadItem,
AssistantMessageItem,
AgentMessageItem,
ReasoningItem,
CommandExecutionItem,
FileChangeItem,

View File

@@ -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
| FileChangeItem

View File

@@ -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);

View File

@@ -33,7 +33,7 @@ describe("Codex", () => {
const expectedItems = [
{
id: expect.any(String),
item_type: "assistant_message",
type: "agent_message",
text: "Hi!",
},
];

View File

@@ -45,7 +45,7 @@ describe("Codex", () => {
type: "item.completed",
item: {
id: "item_0",
item_type: "assistant_message",
type: "agent_message",
text: "Hi!",
},
},