Skip to content

Fix gemini and codex for opencode#79

Open
mpkrass7 wants to merge 11 commits into
mainfrom
marshall/llm-option-fix
Open

Fix gemini and codex for opencode#79
mpkrass7 wants to merge 11 commits into
mainfrom
marshall/llm-option-fix

Conversation

@mpkrass7

@mpkrass7 mpkrass7 commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

Make the stupid models work

The terminal session strips DATABRICKS_TOKEN from the env for security,
so `{env:DATABRICKS_TOKEN}` in opencode.json interpolated to empty
string. Opencode only falls back to auth.json when `options.apiKey`
is undefined (provider.ts L1683), so the empty value silently
overrode the freshly-rotated auth.json token. GPT/Codex models hit
the gateway direct (no proxy fallback) and returned "Credential was
not sent". Drop apiKey from both providers' options and rely on
auth.json, which cli_auth._update_opencode already keeps in sync.

Also add Claude Haiku 4.5 for parity and drop the duplicate
databricks-gemini-2-5-pro entries in both config blocks.

Co-authored-by: Isaac
@mpkrass7 mpkrass7 changed the title fix(opencode): read auth from auth.json, not stripped env var Fix gemini and codex for opencode Jun 7, 2026
mpkrass7 added 10 commits June 7, 2026 10:31
Opencode's auth loader expects {"type": "api", "key": ...} and silently
drops entries that don't decode. Our previous {"api_key": ...} format
got dropped, leaving provider.key undefined → @ai-sdk/openai threw
"API key missing" once options.apiKey was removed.

Write the correct schema in setup_opencode.py and rotate the `key`
field (not `api_key`) in cli_auth._update_opencode. Updates the
related tests too. Also trims oversized explainer comments.

Co-authored-by: Isaac
GPT-5.x reasoning models send `reasoningSummary` (Responses API
field) on every request. The content-filter proxy forwards to the
chat-completions endpoint, which rejects unknown params. Add it to
the proxy's strip-list alongside stream_options.

Also swap databricks-gpt-5-1-codex-max (not served in stablebox)
for databricks-gpt-5-2-codex, which is.

Co-authored-by: Isaac
gpt-5.4-mini and friends reject reasoning_effort when combined with
function tools on /v1/chat/completions. Strip it the same way we
strip reasoningSummary. Full reasoning is still available via the
direct databricks-openai route which hits /v1/responses.

Co-authored-by: Isaac
Previous strip was blanket and would silently kill Claude's thinking
budget (gateway translates reasoning_effort → Anthropic thinking
params). Restrict the reasoning-field strip to GPT models only;
Claude and Gemini keep it.

Co-authored-by: Isaac
Co-authored-by: Isaac
Gemini's function declaration schema only accepts a narrow subset of
JSON Schema. Add exclusiveMinimum/exclusiveMaximum/multipleOf/
uniqueItems to the strip list alongside the existing \$schema/
additionalProperties.

Co-authored-by: Isaac
Databricks gateway returns Gemini deltas as Anthropic-style content
block arrays ([{type:"text", text:"...", thoughtSignature:"..."}]),
but opencode's openai-compatible Zod schema requires content to be a
plain string. Add _flatten_content_blocks() to the proxy so both
streaming deltas and non-streaming messages get collapsed before
opencode parses them. thoughtSignature and other non-text blocks are
dropped.

Also register databricks-gemini-3-5-flash and
databricks-gemini-3-1-flash-lite in both gateway-mode and fallback
opencode configs.

Co-authored-by: Isaac
Both branches were 95% identical — only the databricks provider's
display name differed, and gateway-mode added an extra
databricks-openai provider. Pull the models dicts up to module
constants and conditionally append the openai provider. Adding a new
model is now a one-line edit instead of two.

Net -117 lines, same generated output.

Co-authored-by: Isaac
…viders

Three related changes squashed together:

1. Workspace introspection (setup_opencode.py)
   At setup time, query Databricks serving-endpoints and models.dev's
   bundled databricks catalog. Mark catalog entries the workspace
   doesn't serve as enabled:false; surface workspace-only chat
   endpoints (Claude Opus 4.8, GPT-5.5 Pro, Llama 4 Maverick, Qwen3,
   etc.) with their gateway display name. Embeddings filtered out by
   task=="llm/v1/chat". Fail-soft on network errors.

2. Llama integer-schema fix (content_filter_proxy.py)
   Llama 4 Maverick's validator rejects "minimum" on integer types.
   Walk the schema and drop minimum/maximum when parent type is
   "integer". String minLength/maxLength and number bounds preserved.

3. Provider whitelist (setup_opencode.py)
   Add enabled_providers config so only databricks (proxy) and
   databricks-openai (direct) show in the picker. Hides everything
   opencode auto-loads from models.dev (google, anthropic, openai,
   etc.) which polluted the picker with no-credentials entries like
   Gemini 3 Flash Preview.

Co-authored-by: Isaac
@mpkrass7 mpkrass7 force-pushed the marshall/llm-option-fix branch from 7dbe0a9 to 04061d4 Compare June 8, 2026 16:14
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