HKUDS/Vibe-Trading · critical · RuntimeError

OpenAI Codex OAuth requires httpx. Install dependencies firs

Error message

OpenAI Codex OAuth requires httpx. Install dependencies first.

What it means

OpenAICodexLLM.__init__ requires httpx for its HTTP transport; if the httpx import failed at module load (symbol is None), constructing the LLM raises immediately rather than failing on the first request.

Source

Thrown at agent/src/providers/openai_codex.py:619

            detail = event.get("error") or event.get("message") or event
            raise RuntimeError(f"OpenAI Codex response failed: {str(detail)[:500]}")


class OpenAICodexLLM:
    """Minimal LangChain-compatible adapter for Vibe-Trading's ChatLLM."""

    def __init__(
        self,
        *,
        model: str,
        temperature: float = 0.0,
        timeout: int = 120,
        tools: list[dict[str, Any]] | None = None,
        reasoning_effort: str | None = None,
        codex_url: str | None = None,
    ) -> None:
        if httpx is None:
            raise RuntimeError("OpenAI Codex OAuth requires httpx. Install dependencies first.")
        self.model = model
        self.temperature = temperature
        self.timeout = timeout
        self.tools = tools or []
        self.reasoning_effort = reasoning_effort
        self.codex_url = validate_codex_base_url(codex_url or get_env_config().llm.openai_codex_base_url)

    def bind_tools(self, tools: list[dict[str, Any]]) -> "OpenAICodexLLM":
        return OpenAICodexLLM(
            model=self.model,
            temperature=self.temperature,
            timeout=self.timeout,
            tools=tools,
            reasoning_effort=self.reasoning_effort,
            codex_url=self.codex_url,
        )

    def _body(self, messages: list[dict[str, Any]], *, stream: bool) -> dict[str, Any]:

View on GitHub (pinned to 80ffdda44c)

Solutions

  1. pip install httpx (or reinstall: pip install -U httpx httpcore)
  2. Resolve version conflicts: pip check, then align httpcore/httpx versions
  3. Construct the LLM in a startup health-check so failures surface at boot, not mid-session

Example fix

# before
RuntimeError: OpenAI Codex OAuth requires httpx...

# after
pip install httpx
Defensive patterns

Strategy: validation

Validate before calling

try:
    import httpx  # noqa: F401
except ImportError:
    raise SystemExit('pip install httpx')

Try / catch

try:
    llm = OpenAICodexLLM(model=...)
except RuntimeError as e:
    if 'httpx' in str(e):
        print('pip install httpx'); sys.exit(1)
    raise

Prevention

When it happens

Trigger: Constructing OpenAICodexLLM (directly or via build_llm with provider=openai-codex) in an environment where httpx is not installed or failed to import.

Common situations: Minimal environments missing the HTTP extra; httpx version conflicts with other libraries (e.g. incompatible httpcore pins); broken installs after partial upgrades.

Related errors


AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28). Data as JSON: /api/errors/e2622a528e342248. Report an issue: GitHub.