Implementation:Openai Openai python Response Function Shell Tool Call
| Knowledge Sources | |
|---|---|
| Domains | API_Types, Responses_API |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
Concrete response type representing a shell tool call that executes shell commands in a managed environment, provided by the openai-python SDK.
Description
ResponseFunctionShellToolCall is a Pydantic model representing a tool call that executes one or more shell commands in a managed environment. It contains an id for the call, an action field (an Action sub-model with a list of commands, optional max_output_length, and optional timeout_ms), a call_id for response mapping, an optional environment (a discriminated union of ResponseLocalEnvironment or ResponseContainerReference), a status field, a fixed type of "shell_call", and an optional created_by field. This type is auto-generated from the OpenAI OpenAPI specification by Stainless.
Usage
Import ResponseFunctionShellToolCall when processing Responses API output items that contain shell tool calls and you need to execute the requested commands and return results.
Code Reference
Source Location
- Repository: openai-python
- File: src/openai/types/responses/response_function_shell_tool_call.py
Signature
class ResponseFunctionShellToolCall(BaseModel):
"""A tool call that executes one or more shell commands in a managed environment."""
id: str
action: Action
call_id: str
environment: Optional[Environment] = None
status: Literal["in_progress", "completed", "incomplete"]
type: Literal["shell_call"]
created_by: Optional[str] = None
Import
from openai.types.responses import ResponseFunctionShellToolCall
I/O Contract
Fields
| Name | Type | Required | Description |
|---|---|---|---|
| id | str |
Yes | The unique ID of the shell tool call. |
| action | Action |
Yes | The shell commands and limits describing how to run the tool call. |
| call_id | str |
Yes | The unique ID of the shell tool call generated by the model. |
| environment | Optional[Union[ResponseLocalEnvironment, ResponseContainerReference]] |
No | The execution environment for the shell commands. |
| status | Literal["in_progress", "completed", "incomplete"] |
Yes | The status of the shell call. |
| type | Literal["shell_call"] |
Yes | The type of the item. Always "shell_call".
|
| created_by | Optional[str] |
No | The ID of the entity that created this tool call. |
Action Sub-Type
| Name | Type | Required | Description |
|---|---|---|---|
| commands | List[str] |
Yes | The shell commands to execute. |
| max_output_length | Optional[int] |
No | Maximum number of characters to return from each command. |
| timeout_ms | Optional[int] |
No | Timeout in milliseconds for the commands. |
Usage Examples
from openai.types.responses import ResponseFunctionShellToolCall
# Process shell tool calls from response output
for item in response.output:
if isinstance(item, ResponseFunctionShellToolCall):
print(f"Shell call ID: {item.call_id}")
print(f"Commands: {item.action.commands}")
if item.action.timeout_ms:
print(f"Timeout: {item.action.timeout_ms}ms")
# Execute the commands and provide output back
for cmd in item.action.commands:
result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
print(f"stdout: {result.stdout}")