Use this file to discover all available pages before exploring further.
HUD provides native support for OpenAI’s coding tools (shell and apply_patch), enabling you to build powerful coding agents that can create, modify, and execute code.
Example Code
Follow along with the full working example on GitHub.
OpenAI’s Responses API includes specialized tools for coding tasks:
Tool
Purpose
HUD Implementation
shell
Execute shell commands in a persistent bash session
hud.tools.shell.ShellTool
apply_patch
Create, update, and delete files using V4A diff format
hud.tools.apply_patch.ApplyPatchTool
When you register tools named shell or apply_patch in your environment, the OpenAIAgent automatically converts them to OpenAI’s native tool types for optimal performance.
Prerequisites: You must create the codex_environment_sandbox environment
in hud.ai first before using hub mode. Go to
hud.ai → New → Environment → Import from
hud-evals/codex_environment_sandbox.
Once deployed, your environment will be accessible via connect_hub().
Connect to HUD Hub for full cloud execution and telemetry:
import hudfrom hud.agents.openai import OpenAIAgentfrom hud.settings import settingsfrom openai import AsyncOpenAI# Connect to HUD Hub environmentenv = hud.Environment()env.connect_hub("codex_environment_sandbox")# Use HUD Gateway for inference (full telemetry)model_client = AsyncOpenAI( base_url=settings.hud_gateway_url, api_key=settings.api_key,)agent = OpenAIAgent.create( model="gpt-5.1", model_client=model_client, validate_api_key=False,)async with hud.eval(env(), name="coding-task") as ctx: result = await agent.run(ctx, max_steps=20)
The first request may take a few seconds while the environment spins up in the
cloud. Subsequent requests will be faster.
# Local mode - tools run on your machineuv run python examples/06_codex_coding_agent.py --local# Local mode with persistent output directoryuv run python examples/06_codex_coding_agent.py --local --work-dir ./codex_output# Hub mode - full cloud execution (default)uv run python examples/06_codex_coding_agent.py# Custom taskuv run python examples/06_codex_coding_agent.py --local \ --task "Create a Python script that prints the Fibonacci sequence up to 10 numbers"# Verbose outputuv run python examples/06_codex_coding_agent.py --local --verbose