Skip to content

support glm-5-2 on opencode #186

Merged
lilly-luo merged 5 commits into
mainfrom
broaden-oss-model-bucket
Jul 7, 2026
Merged

support glm-5-2 on opencode #186
lilly-luo merged 5 commits into
mainfrom
broaden-oss-model-bucket

Conversation

@lilly-luo

@lilly-luo lilly-luo commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

1/ support kimi and glm. i use a hardcoded list instead of just fetching all oss models because not all of them work (ie qwen fails with some error about ints). i confirmed kimi and glm work

2/ cap glm at an output token limit of 25k. otherwise it will fail. we see the same issue in the browser if we don't cap the output token limit.

Screenshot 2026-07-07 at 2 25 22 PM

lilly-luo added 5 commits July 7, 2026 15:05
discover_model_services bucketed OSS models with an allowlist ("kimi-"
only), so GLM/Llama/Qwen/DeepSeek and any future OSS family were
discovered from UC model-services but dropped on the floor — never
reaching opencode_models, so they couldn't be listed or selected in
OpenCode (e.g. system.ai.glm-5-2).

Bucket OSS by exclusion instead: anything not claude/gpt/gemini, minus
non-chat model services (embeddings, rerankers) that can't back a chat
agent. New OSS families now surface without a code change.

Co-authored-by: Isaac
…ents

The Databricks gateway caps GLM's max output (completion) tokens and
rejects requests above it. These limits are a property of the model +
its /ai-gateway/mlflow/v1 route, not of any one agent, so expose them as
a single model_token_limits() helper (family->limits table) in
databricks.py. Each agent translates the limits into its own config
dialect.

OpenCode's per-model schema is strict (`additionalProperties: false`)
and its `limit` object requires BOTH context and output — supplying only
output made the whole opencode.json invalid ("Configuration is
invalid"). The table now always provides both fields, so OpenCode pins
`limit: {context, output}` and clamps `max_tokens` to a gateway-accepted
value. Adding a model/limit is a one-line edit shared across
opencode/pi/copilot.

Co-authored-by: Isaac
The previous catch-all bucketed any non-claude/gpt/gemini model (llama,
qwen, deepseek, ...) into OSS, offering families we haven't validated.
Go back to an explicit allowlist, but include both kimi and glm.

_OSS_MODEL_FAMILIES = ("kimi-", "glm-") replaces the exclusion logic and
its non-chat marker filter (embeddings/rerankers never match the
allowlist, so no filtering is needed).

Co-authored-by: Isaac
Under the kimi/glm allowlist, llama-4-maverick again matches no family,
so the original test (asserting it's reported in the "no families" reason)
holds without the embedding-service substitute.

Co-authored-by: Isaac
@lilly-luo lilly-luo requested a review from rohita5l July 7, 2026 18:24
@lilly-luo lilly-luo merged commit 446a24a into main Jul 7, 2026
2 checks passed
@lilly-luo lilly-luo deleted the broaden-oss-model-bucket branch July 7, 2026 18:27
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.

2 participants