Skip to content

feat(opencode-go): support GLM-5 reasoning controls (#49279) - #50694

Closed
izumi0uu wants to merge 1 commit into
NousResearch:mainfrom
izumi0uu:feat/glm-reasoning-support-49279
Closed

feat(opencode-go): support GLM-5 reasoning controls (#49279)#50694
izumi0uu wants to merge 1 commit into
NousResearch:mainfrom
izumi0uu:feat/glm-reasoning-support-49279

Conversation

@izumi0uu

@izumi0uu izumi0uu commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds GLM-5 reasoning support to the opencode-go profile so Hermes stops silently dropping /reasoning for GLM-5 model IDs routed through plugins/model-providers/opencode-zen/__init__.py.

Before this change, OpenCodeGoProfile.build_api_kwargs_extras() only applied reasoning controls to Kimi K2 and DeepSeek thinking models. glm-5* IDs fell through the gate entirely, so /reasoning high, /reasoning off, and related settings had no effect on GLM-5 requests on this provider path.

This PR adds a GLM-5 model gate and reuses the existing DeepSeek-style mapping already used on OpenCode Go:

  • recognized efforts forward as top-level reasoning_effort
  • disabled reasoning emits extra_body.thinking={"type":"disabled"}
  • unrecognized/no explicit effort falls back to extra_body.thinking={"type":"enabled"}

Related Issue

Fixes #49279

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • Added _is_glm_thinking_model() to plugins/model-providers/opencode-zen/__init__.py
  • Routed GLM-5 IDs through the existing OpenCode Go reasoning-control branch
  • Added GLM-specific unit coverage in tests/plugins/model_providers/test_opencode_go_profile.py
  • Extended model-gating tests to keep glm-4.5 and glm-4.5-flash excluded
  • Added transport integration coverage to verify reasoning_effort reaches final kwargs for GLM-5

How to Test

  1. On main, call OpenCodeGoProfile.build_api_kwargs_extras(..., model="glm-5.1") with a reasoning config and observe that it returns no GLM reasoning controls.
  2. On this branch, repeat the same call and verify that GLM-5 models now emit the same reasoning fields as the existing DeepSeek branch.
  3. Run:
    • ./.venv/bin/python -m pytest tests/plugins/model_providers/test_opencode_go_profile.py -q
    • git diff --check

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS 15.7.7

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Screenshots / Logs

Targeted validation run:

$ ./.venv/bin/python -m pytest tests/plugins/model_providers/test_opencode_go_profile.py -q
28 passed, 3 warnings in 3.70s

$ git diff --check
(no output)

@alt-glitch alt-glitch added type/feature New feature or request comp/plugins Plugin system and bundled plugins provider/zai ZAI provider P3 Low — cosmetic, nice to have labels Jun 22, 2026

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for isolating the missing provider-profile path and adding transport-level coverage.

Problems

  • Current main now has a GLM-5.2-specific OpenCode Go implementation at plugins/model-providers/opencode-zen/__init__.py:64-77; it emits only native top-level reasoning_effort and intentionally leaves disabled/unset requests at server defaults.
  • Current regression coverage explicitly requires glm-5.1 and glm-5 to emit no OpenCode Go reasoning controls (tests/plugins/model_providers/test_opencode_go_profile.py:185-201). The proposed startswith("glm-5") gate changes that contract by applying the DeepSeek wire shape.
  • The linked issue's only comment says the GLM-5.x relay contract was not verified, including whether it accepts top-level reasoning_effort or requires another format.

Suggested changes

  • Verify the OpenCode Go GLM-5.1 relay contract, then add a narrowly scoped GLM-5.1 branch and tests for enabled, disabled, and unset behavior without changing the existing GLM-5.2 contract.

Automated hermes-sweeper review.

return extra_body, top_level

if not _is_deepseek_thinking_model(model):
if not (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This broad glm-5* gate applies DeepSeek's thinking/reasoning_effort contract to GLM-5.1, but the linked issue says the relay contract is unverified. Current main instead scopes native controls to GLM-5.2 and explicitly tests glm-5.1 as non-target; please verify and encode the exact GLM-5.1 wire contract before widening this gate.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 15, 2026
@izumi0uu

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I verified the OpenCode Go contract instead of carrying over the DeepSeek mapping. The official metadata marks GLM-5.1 as reasoning-capable but exposes no configurable reasoning_options; OpenCode maintainers also confirmed that excluding GLM-5/5.1 reasoning variants is intentional.

GLM-5.2 is the supported exception, and its high/max reasoning_effort handling has already landed on main in #58884 (a6079dd). Narrowing this PR to GLM-5.2 would therefore duplicate the existing implementation, while retaining GLM-5.1 support would send an unsupported payload. I’m withdrawing this PR.

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

Labels

comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have provider/zai ZAI provider sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add GLM-5.x reasoning support to OpenCodeGo profile

3 participants