Python 88.3%
TypeScript 7.6%
Shell 4.1%
1#!/usr/bin/env python32"""code_execution_20250825: bash_code_execution sub-tool + container id. Reuse: pass r['container']['id'] as top-level 'container' on the next call (e2). STATUS: LIVE_VERIFIED 2026-09-18 (e1).3Run: .venv/bin/python examples/anthropic/code-execution/code_execution.py4"""5import json, sys6from pathlib import Path7sys.path.insert(0, str(Path(__file__).resolve().parents[3]))8from scripts.live import anthropic_request9MODEL = "claude-haiku-4-5-20251001"10st, r, _ = anthropic_request("POST", "/v1/messages", {"model": MODEL, "max_tokens": 400, "tools": [{"type": "code_execution_20250825", "name": "code_execution"}], "messages": [{"role": "user", "content": "Use the code execution tool to run print(2+2) and reply with only the number."}]}, beta=None, note="code_execution.py")11print("HTTP", st, "stop_reason:", r.get("stop_reason"))12for b in r.get("content", []):13 print(json.dumps({k: v for k, v in b.items() if k in ("type", "name", "toolset_name", "input", "caller", "text", "content", "tool_use_id", "server_name", "is_error")}, ensure_ascii=False)[:600])14print("usage:", json.dumps(r.get("usage")), "container:", r.get("container"))15