Skip to content

feat: declare temperature support for models that list it - #47

Merged
yuseferi merged 1 commit into
yuseferi:mainfrom
zyc:feat/declare-temperature-support
Oct 26, 2026
Merged

yuseferi merged 1 commit into
yuseferi:mainfrom
zyc:feat/declare-temperature-support

Conversation

@zyc

@zyc zyc commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

OpenCode sends a sampling temperature (its own per-model default, or one set on the agent) only for models flagged as supporting it. The plugin never set the flag, so every discovered model ended up unflagged and the user's temperature was silently ignored, even for models whose /v1/model/info lists temperature in supported_openai_params. This declares temperature for exactly those models, on both OpenCode 1 (config entry) and OpenCode 2 (capabilities.temperature). When the parameter is not listed, or /v1/model/info is unavailable, the field stays unset, so behavior is unchanged for everything else (some deployments, such as reasoning-only endpoints or guardrail classifiers, reject the parameter outright).

Type of change

  • 🐛 Bug fix (non-breaking)
  • ✨ New feature (non-breaking)
  • 💥 Breaking change
  • 📝 Documentation only
  • 🔧 Internal / refactor

Checklist

  • npm run typecheck passes
  • No new runtime dependencies (or justified in this PR description)
  • README updated if public API or behavior changed (Modality-aware row)
  • CHANGELOG.md updated under ## [Unreleased] (not touched: the file is generated by semantic-release from the commit message)
  • Commit messages follow Conventional Commits

Notes for review

  • Behavior change for existing users. This changes what is sent for any model whose /v1/model/info lists temperature in supported_openai_params: the agent's temperature (if set) and OpenCode's per-family defaults (for example gemini 1, glm 1, kimi 0.6, minimax 1) now reach the model. Before, OpenCode never sent a temperature for these models, because the flag was never set. Models that do not list the parameter are unchanged.
  • CACHE_VERSION moves from 5 to 6: cached entries gain a field, so older caches are rediscovered instead of serving models without the flag. Each user rediscovers once after upgrading.
  • On OpenCode 2 the field is added only when it is true; it is never set to false, so "unknown" stays unknown.
  • Behavior measured on OpenCode 1.18.29: with the model flag false/unset, OpenCode never sends temperature, even when the agent config sets one (0.3 in the probe); with true, it sends it. This was checked by capturing the request body against a local OpenAI-compatible server.

How was this tested?

  • npm test: 161 passed (157 before; 4 new). Two of the new tests fail when the source change is reverted: toConfigModel declares temperature only when listed (and leaves it unset when not listed or when /v1/model/info is unavailable), and the OpenCode 2 provider transform registers capabilities.temperature: true only for models that list it.
  • Against a LiteLLM proxy with 6 chat models that all list temperature: before, capabilities.temperature was false on all 6 on OpenCode 1.19.3 and unset on OpenCode 2.1.0; after, it is true on all 6 on both (checked with opencode models --verbose on OpenCode 1 and /api/model on OpenCode 2).

Summary by CodeRabbit

  • New Features

    • Temperature controls are now available only for models whose metadata explicitly lists support for the temperature parameter.
    • Models without confirmed temperature support no longer advertise that capability.
  • Bug Fixes

    • Prevented unavailable or incomplete model metadata from incorrectly enabling temperature controls.
    • Updated cached model data handling so older cache entries are recognized as stale.
  • Documentation

    • Clarified when temperature controls are exposed for supported models.

OpenCode sends a sampling temperature (its own per-model default, or one
set on the agent) only for models flagged as supporting it. The plugin
never set the flag, so every discovered model ended up unflagged and the
user's temperature was silently ignored, even for models whose
/v1/model/info lists `temperature` in `supported_openai_params`.

Declare `temperature` when `supported_openai_params` lists it, on both
the OpenCode 1 config entry and the OpenCode 2 `capabilities`. When the
parameter is not listed, or /v1/model/info is unavailable, the field is
left unset so behavior is unchanged (some deployments, such as
reasoning-only endpoints or guardrail classifiers, reject it).

The cached entry shape gains a field, so CACHE_VERSION moves to 6 and
older caches are rediscovered.
@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 762a6d88-3087-439e-ba02-975e1ea455f8
📥 Commits

Reviewing files that changed from the base of the PR and between e887c4b and 4617f72.

📒 Files selected for processing: 6
  • README.md
  • src/plugin/index.ts
  • src/plugin/v2.ts
  • src/utils/model-cache.ts
  • test/plugin-v2.test.ts
  • test/to-config-model.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

Model temperature capability is now set from LiteLLM model metadata and carried into provider models only when explicitly declared. The model cache version changed from 5 to 6.

Changes: Temperature capability mapping

Layer / File(s) Summary
Map metadata to configuration
src/plugin/index.ts, test/to-config-model.test.ts, README.md
toConfigModel sets temperature support when supported_openai_params lists temperature. Tests cover absent, null, and unavailable model info. The README documents this condition.
Propagate provider capability
src/plugin/v2.ts, test/plugin-v2.test.ts, src/utils/model-cache.ts
toProviderModels sets temperature support only when the model explicitly declares temperature: true. Tests cover models with and without that declaration. The cache version changes from 5 to 6.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: mkowalski

Merge Risk: ⚪ Minimal · up to 4617f

The temperature declaration is limited to models whose metadata lists support. No issue identified here requires resolution before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 5 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: declaring temperature support only for models that list it.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 5 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@yuseferi yuseferi left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Looks good, thanks for the clear write-up and the before/after checks on both OpenCode 1 and 2.

Checked:

  • temperature is set only when supported_openai_params lists it, and is left unset (never false) otherwise. This holds on both the OpenCode 1 config entry and capabilities.temperature on OpenCode 2.
  • The CACHE_VERSION bump to 6 is needed, since the cache stores the built config entries.
  • The tests cover the listed / not-listed / null / missing-/v1/model/info cases.

Notes for the release, no changes needed:

  • Users will notice this. LiteLLM lists temperature for nearly every model, so OpenCode's per-family defaults (Gemini/GLM/MiniMax 1.0, Kimi 0.6, Qwen 0.55) and any agent-level temperature will now reach most models. The release notes should say so.
  • Possible follow-up: a way to opt a single model out (e.g. through modelCapabilities) for proxies whose supported_openai_params lists temperature for a deployment that actually rejects it.

@yuseferi
yuseferi merged commit f68252f into yuseferi:main Oct 26, 2026
5 checks passed
github-actions Bot pushed a commit that referenced this pull request Oct 26, 2026
# [1.8.0](v1.7.1...v1.8.0) (2026-10-26)

### Features

* declare temperature support for models that list it ([#47](#47)) ([f68252f](f68252f))
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