Expose GLM reasoning-effort tiers in the model picker - #81
Merged
Conversation
glm-latest is GLM-5.2, which supports graduated reasoning effort up to "max" — the top tier the Juspay gateway accepts for this model. Set the model's reasoningEffort option so OpenCode forwards reasoning_effort: max on every request and renders GLM's reasoning trace in the TUI. @ai-sdk/openai-compatible maps the camelCase reasoningEffort option to the snake_case reasoning_effort request field. Verified end-to-end against the live gateway by capturing the outgoing request body and driving a real OpenCode session (screenshot in README).
Replace the static screenshot with a recording of a real OpenCode session: prompt -> extended 'Thinking' at reasoning_effort=max (~13s) -> full reasoning trace and answer. Captured from the juspay oneclick build driven against the live gateway.
Completes the previous commit: stage the animated recording and the README reference (the combined add aborted on the already-removed PNG).
Keep glm-latest at the gateway default (thinking on, unchanged from master) and add sibling picker entries that pin reasoning_effort, all targeting the same gateway model via `id`: glm-max -> max (deepest) glm-high -> high (strong, faster) glm-fast -> none (no thinking, fastest) GLM-5.2 collapses low/medium into high, so these are the only distinct levels. Demo replaced with a recording of switching tiers in the picker. Model context/output limits are stale vs the gateway (tracked in #82) and left unchanged here.
Re-record at a 98x26 terminal and render at the content's true aspect ratio (the prior 980x600 canvas letterboxed ~140px of dead space, so the TUI looked off-center).
glm-latest (GLM-5.2) and its effort tiers share a 1M-token context window; the prior 202752/32000 was a copy-paste default. Set context=1000000 with a deliberate output=128000 cap (the gateway advertises a placeholder 1000000 max output, but max_tokens=1000000 400s with ContextWindowExceededError once a prompt is included). Factored the shared values into glmLimits.
Correcting the prior commit: OpenCode caps the wire max_tokens at 32000 for this custom-provider model regardless of limit.output (verified: 16000->16000 but 64000/128000 both ->32000), so output=128000 raised nothing on the wire and only shrank the usable input budget. The real fix is context=1000000.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Expose GLM reasoning-effort tiers in the OpenCode model picker.
glm-latest(GLM-5.2) is left exactly as on
master— it reasons by default — and the samegateway model is also surfaced at pinned effort levels you can switch between with
ctrl+x m:reasoning_effortglm-latestglm-maxmaxglm-highhighglm-fastnoneGLM-5.2 internally collapses low/medium into
high, so max / high / off are theonly distinct levels — no point exposing more.
Change
coding-agents/opencode/settings/juspay.nix—mkModelgains an optionalid(wire model id when the picker key differs from the gateway name), and the GLM
family becomes:
All siblings target the gateway model
glm-latestviaid. OpenCode maps thecamelCase
reasoningEffortoption to the wire fieldreasoning_effort(
@ai-sdk/openai-compatible); snake-case inoptionsis silently dropped and the--variantflag is a no-op for custom providers — both verified empirically.Proof — real OpenCode against the live gateway
1. Switching tiers in the picker (
ctrl+x m), no prompt — all four entries areselectable and the footer reflects the active one:
2.
glm-maxactually sendsreasoning_effort: max— outgoing body captured fromthe nix-generated config via a logging proxy (Authorization never logged); the wire
modelis the gateway idglm-latest:{ "model": "glm-latest", "reasoning_effort": "max", "max_tokens": 32000, "stream": true, ... }glm-fastlikewise sendsreasoning_effort: "none"(verified the same way).3.
maxis the real top tier, and the default is left untouched:glm-latest(=zai-org/GLM-5.2-dev):reasoning_effort—"Input should be
'none','low','medium','high'or'max'".glm-latestwith noreasoning_effort(its master form) still returnsreasoning (
reasoning_tokens119/256/99 across samples), while explicitnonereturns zero — confirming master's default is thinking-on, and this PR preserves it.
Notes
glm-flash-experimental(GLM-4.7-Flash) only accepts up tohigh; left unchanged.contextto1000000(the real 1M window; the old202752was acopy-paste default shared with
minimax-m2/open-large).outputstays32000:OpenCode caps the wire
max_tokensat 32000 for this custom-provider modelregardless of
limit.output(verified), so a higher value only shrinks usableinput. Keeping the whole model table in sync with the gateway is automated in Refresh opencode model limits (context/output) from the LiteLLM gateway #82.
litellmprovider and bundled skills arepresent, so they're unaffected; verified the package builds and the generated
opencode.jsoncarries all four GLM entries with the rightid/reasoningEffort.🤖 Generated with Claude Code