Skip to content

Expose GLM reasoning-effort tiers in the model picker - #81

Merged
srid merged 7 commits into
mainfrom
stern-lead
Jun 21, 2026
Merged

Expose GLM reasoning-effort tiers in the model picker#81
srid merged 7 commits into
mainfrom
stern-lead

Conversation

@srid

@srid srid commented Jun 21, 2026

Copy link
Copy Markdown
Member

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 same
gateway model is also surfaced at pinned effort levels you can switch between with
ctrl+x m:

Picker entry reasoning_effort Use it for
glm-latest (gateway default) the default — thinking on (unchanged)
glm-max max deepest reasoning
glm-high high strong reasoning, faster
glm-fast none no thinking, fastest replies

GLM-5.2 internally collapses low/medium into high, so max / high / off are the
only distinct levels — no point exposing more.

Change

coding-agents/opencode/settings/juspay.nixmkModel gains an optional id
(wire model id when the picker key differs from the gateway name), and the GLM
family becomes:

glmLimits  = { context = 1000000; output = 32000; };   # 1M window; OpenCode caps wire max_tokens at 32000
glm-latest = glmLimits;                                # default, unchanged reasoning
glm-max    = glmLimits // { reasoningEffort = "max";  id = "glm-latest"; };
glm-high   = glmLimits // { reasoningEffort = "high"; id = "glm-latest"; };
glm-fast   = glmLimits // { reasoningEffort = "none"; id = "glm-latest"; };

All siblings target the gateway model glm-latest via id. OpenCode maps the
camelCase reasoningEffort option to the wire field reasoning_effort
(@ai-sdk/openai-compatible); snake-case in options is silently dropped and the
--variant flag 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 are
selectable and the footer reflects the active one:

Switching GLM reasoning-effort tiers in the OpenCode picker

2. glm-max actually sends reasoning_effort: max — outgoing body captured from
the nix-generated config via a logging proxy (Authorization never logged); the wire
model is the gateway id glm-latest:

{ "model": "glm-latest", "reasoning_effort": "max", "max_tokens": 32000, "stream": true, ... }

glm-fast likewise sends reasoning_effort: "none" (verified the same way).

3. max is the real top tier, and the default is left untouched:

  • Gateway validator for glm-latest (= zai-org/GLM-5.2-dev): reasoning_effort
    "Input should be 'none', 'low', 'medium', 'high' or 'max'".
  • glm-latest with no reasoning_effort (its master form) still returns
    reasoning (reasoning_tokens 119/256/99 across samples), while explicit none
    returns zero — confirming master's default is thinking-on, and this PR preserves it.

Notes

  • glm-flash-experimental (GLM-4.7-Flash) only accepts up to high; left unchanged.
  • Corrected context to 1000000 (the real 1M window; the old 202752 was a
    copy-paste default shared with minimax-m2/open-large). output stays 32000:
    OpenCode caps the wire max_tokens at 32000 for this custom-provider model
    regardless of limit.output (verified), so a higher value only shrinks usable
    input. Keeping the whole model table in sync with the gateway is automated in Refresh opencode model limits (context/output) from the LiteLLM gateway #82.
  • Standalone NixOS tests only assert the litellm provider and bundled skills are
    present, so they're unaffected; verified the package builds and the generated
    opencode.json carries all four GLM entries with the right id/reasoningEffort.

🤖 Generated with Claude Code

srid added 3 commits June 21, 2026 13:43
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.
@srid srid changed the title Enable max thinking mode for GLM (glm-latest) Expose GLM reasoning-effort tiers in the model picker Jun 21, 2026
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).
srid added 2 commits June 21, 2026 15:47
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.
@srid
srid merged commit 1837df4 into main Jun 21, 2026
4 checks passed
@srid
srid deleted the stern-lead branch June 21, 2026 20:00
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