#!/usr/bin/env python3 """Shell tool in LOCAL mode: the model proposes commands (shell_call); we execute NOTHING here — we just print the proposal. STATUS: LIVE_VERIFIED 2026-09-18 (gpt-5.4-nano; shell_call.action.commands == ['echo OK']). Hosted mode (environment container_auto) is shown in the skills example. Run: .venv/bin/python examples/openai/tools/shell/shell.py """ import sys from pathlib import Path ROOT = Path(__file__).resolve().parents[4]; sys.path.insert(0, str(ROOT)) from scripts.live import load_env, log_request; load_env() from openai import OpenAI client = OpenAI(); MODEL = "gpt-5.4-nano" r = client.responses.create(model=MODEL, input="Propose the shell command `echo OK`. Do not explain.", tools=[{"type": "shell", "environment": {"type": "local"}}], tool_choice={"type": "shell"}, max_output_tokens=64, reasoning={"effort": "low"}) log_request("openai", "POST", "/v1/responses", 200, 0.0001, "shell.py local proposal") call = next(i for i in r.output if i.type == "shell_call") print("shell_call:", call.call_id, call.action.commands, "timeout_ms=", call.action.timeout_ms, "environment=", call.environment) # To continue you would run the commands yourself and send: # {"type":"shell_call_output","call_id":call.call_id,"output":[{"stdout":"OK\n","stderr":"","outcome":{"type":"exit","exit_code":0}}]}