Skip to content

Hosted shell types and streaming events missing #1750

@Anton-Plagemann

Description

@Anton-Plagemann

Confirm this is a Node library issue and not an underlying OpenAI API issue

  • This is an issue with the Node library

Describe the bug

For the hosted shell tool, some streaming events are not documented and not present in the SDK but the API emits these. I've logged these events once and generated TypeScript types for it:

/**
 * Temporary types for OpenAI shell tool streaming events that are not yet
 * included in the openai SDK's `ResponseStreamEvent` union.
 *
 * These correspond to the following event types observed from the API:
 *  - response.shell_call_command.added
 *  - response.shell_call_command.delta
 *  - response.shell_call_command.done
 *  - response.shell_call_output_content.delta
 *  - response.shell_call_output_content.done
 *
 * Delete this file once the openai SDK ships these types natively.
 */
import type { OpenAI } from "openai";

// ---------------------------------------------------------------------------
// response.shell_call_command.*
// ---------------------------------------------------------------------------

/** Fired when a new shell command starts streaming. */
export interface ResponseShellCallCommandAddedEvent {
  type: "response.shell_call_command.added";
  /** The (initially empty) command text. */
  command: string;
  /** Index of this command within the shell_call's action.commands array. */
  command_index: number;
  /** Index of the parent shell_call output item. */
  output_index: number;
  sequence_number: number;
}

/** Incremental text delta for a shell command being streamed. */
export interface ResponseShellCallCommandDeltaEvent {
  type: "response.shell_call_command.delta";
  /** Index of the command within the shell_call's action.commands array. */
  command_index: number;
  /** The text chunk appended to the command. */
  delta: string;
  /** Opaque obfuscation token (unused). */
  obfuscation: string;
  /** Index of the parent shell_call output item. */
  output_index: number;
  sequence_number: number;
}

/** Fired when a shell command has finished streaming. */
export interface ResponseShellCallCommandDoneEvent {
  type: "response.shell_call_command.done";
  /** The fully-assembled command text. */
  command: string;
  /** Index of the command within the shell_call's action.commands array. */
  command_index: number;
  /** Index of the parent shell_call output item. */
  output_index: number;
  sequence_number: number;
}

// ---------------------------------------------------------------------------
// response.shell_call_output_content.*
// ---------------------------------------------------------------------------

/** Incremental delta for shell execution stdout/stderr. */
export interface ResponseShellCallOutputContentDeltaEvent {
  type: "response.shell_call_output_content.delta";
  /** Index of the command this output belongs to. */
  command_index: number;
  /** Partial stdout/stderr for this chunk. */
  delta: { stdout?: string; stderr?: string };
  /** The shell_call_output item ID. */
  item_id: string;
  /** Index of the shell_call_output item in the response output array. */
  output_index: number;
  sequence_number: number;
}

/** Fired when a shell command's output is complete. */
export interface ResponseShellCallOutputContentDoneEvent {
  type: "response.shell_call_output_content.done";
  /** Index of the command this output belongs to. */
  command_index: number;
  /** The shell_call_output item ID. */
  item_id: string;
  /** Fully-assembled output array with stdout, stderr and outcome. */
  output: OpenAI.Responses.ResponseFunctionShellCallOutputContent[];
  /** Index of the shell_call_output item in the response output array. */
  output_index: number;
  sequence_number: number;
}

// ---------------------------------------------------------------------------
// Union
// ---------------------------------------------------------------------------

/** All shell streaming event types missing from the SDK. */
export type ShellStreamEvent =
  | ResponseShellCallCommandAddedEvent
  | ResponseShellCallCommandDeltaEvent
  | ResponseShellCallCommandDoneEvent
  | ResponseShellCallOutputContentDeltaEvent
  | ResponseShellCallOutputContentDoneEvent;

To Reproduce

  1. Include the hosted shell tool in an api call with instructions to use it (e.g. to generate the 100th member of the fibonacci series with the shell tool using code)
  2. Watch unknown streaming events getting emitted

Code snippets

OS

Linux

Node version

v24.13.1

Library version

6.22.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions