Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Openai Openai python Response Function Shell Tool Call Output

From Leeroopedia
Knowledge Sources
Domains API_Types, Responses_API
Last Updated 2026-02-15 00:00 GMT

Overview

Concrete response type representing the output of a shell tool call, provided by the openai-python SDK.

Description

ResponseFunctionShellToolCallOutput is a Pydantic model representing the output produced by a shell tool call. It contains an id for the output item, a call_id linking back to the originating shell tool call, an optional max_output_length (generated by the model and passed back with raw output), a list of Output items each containing stdout, stderr, an outcome (either OutputOutcomeTimeout or OutputOutcomeExit with an exit_code), and an optional created_by field. The top-level model also has a status field and a fixed type of "shell_call_output". This type is auto-generated from the OpenAI OpenAPI specification by Stainless.

Usage

Import ResponseFunctionShellToolCallOutput when constructing input items for a follow-up Responses API request that provides the results of previously executed shell commands back to the model.

Code Reference

Source Location

Signature

class ResponseFunctionShellToolCallOutput(BaseModel):
    """The output of a shell tool call that was emitted."""

    id: str
    call_id: str
    max_output_length: Optional[int] = None
    output: List[Output]
    status: Literal["in_progress", "completed", "incomplete"]
    type: Literal["shell_call_output"]
    created_by: Optional[str] = None

Import

from openai.types.responses import ResponseFunctionShellToolCallOutput

I/O Contract

Fields

Name Type Required Description
id str Yes The unique ID of the shell call output.
call_id str Yes The unique ID of the shell tool call generated by the model.
max_output_length Optional[int] No The maximum length of the shell command output, generated by the model.
output List[Output] Yes An array of shell call output contents.
status Literal["in_progress", "completed", "incomplete"] Yes The status of the shell call output.
type Literal["shell_call_output"] Yes The type of the output. Always "shell_call_output".
created_by Optional[str] No The identifier of the actor that created the item.

Output Sub-Type

Name Type Required Description
outcome OutputOutcome Yes Either an exit outcome (with exit_code) or a timeout outcome.
stderr str Yes The standard error output that was captured.
stdout str Yes The standard output that was captured.
created_by Optional[str] No The identifier of the actor that created the item.

Outcome Sub-Types

Type Fields Description
OutputOutcomeTimeout type: Literal["timeout"] Indicates the shell call exceeded its configured time limit.
OutputOutcomeExit exit_code: int, type: Literal["exit"] Indicates the shell commands finished and returned an exit code.

Usage Examples

from openai.types.responses import ResponseFunctionShellToolCallOutput

# Inspect shell call output from a response
for item in response.output:
    if isinstance(item, ResponseFunctionShellToolCallOutput):
        print(f"Shell output for call {item.call_id}")
        for output in item.output:
            print(f"  stdout: {output.stdout}")
            print(f"  stderr: {output.stderr}")
            if output.outcome.type == "exit":
                print(f"  exit code: {output.outcome.exit_code}")
            elif output.outcome.type == "timeout":
                print("  Command timed out")

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment