Skip to content

Surface OpenAI models in Opencode#167

Open
asujithan wants to merge 1 commit into
mainfrom
asujithan/opencode-gpt-support
Open

Surface OpenAI models in Opencode#167
asujithan wants to merge 1 commit into
mainfrom
asujithan/opencode-gpt-support

Conversation

@asujithan

Copy link
Copy Markdown
Collaborator

Fixes Issue #154

Root cause
OpenCode lists whatever providers ucode writes into opencode.json, and ucode never wrote a databricks-openai provider. Three layers were each missing a piece: want_codex didn't include "opencode", so codex models were never fetched for opencode launches. URL builder: build_opencode_base_urls had no "openai" entry. Provider config: agents/opencode.py:render_overlay had no third branch; helpers (_resolve_model_selector, default_model) didn't know about an openai bucket.

Fix

Mirrors Pi's already-working databricks-openai wiring — same gateway path, same provider topology:

Changes

  • src/ucode/databricks.py — build_opencode_base_urls now returns "openai": …/ai-gateway/codex/v1
  • src/ucode/cli.py — want_codex includes "opencode" in tools; populates opencode_models["openai"] from codex_models
  • src/ucode/agents/init.py — _TOOL_DISCOVERY_SOURCES["opencode"] includes "codex" so availability errors surface the codex discovery reason
  • src/ucode/agents/opencode.py — third provider branch (databricks-openai via @ai-sdk/openai); PROVIDER_KEYS, _resolve_model_selector, and default_model extended; preference order now Claude → OpenAI → Gemini (matches Pi)

Test plan

  • uv run ruff check . clean
  • uv run pytest — 769 passed, 30 skipped; 2 pre-existing env failures unrelated (sandbox FS + Node v24/undici incompatibility, identical on main)
  • 10 new focused unit tests
  • tests/conftest.py e2e fixture extended so any e2e test using e2e_state["opencode_models"] now exercises the openai bucket

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant