fix(opencode): prefer per-model temperature over agent override#27797
Open
Alezander9 wants to merge 2 commits into
Open
fix(opencode): prefer per-model temperature over agent override#27797Alezander9 wants to merge 2 commits into
Alezander9 wants to merge 2 commits into
Conversation
`ProviderTransform.temperature(model)` encodes per-model-family temperature values that the model's provider requires (e.g. Moonshot's kimi-k2.* returns HTTP 400 "invalid temperature: only 1 is allowed for this model" if any other value is sent). The session/llm.ts call site consulted it in the wrong order: input.agent.temperature ?? ProviderTransform.temperature(input.model) so the built-in title agent's hard-coded `temperature: 0.5` (agent.ts:253) won over the kimi-required 1.0, and Moonshot rejected the request. Swap the operands. The transform value, when present, is the model-aware answer and should beat a generic agent default. For models that aren't in the transform map, the function returns `undefined` and the agent's preference still applies through `??` fallthrough. Affects: kimi-k2.* (incl. k2.6, thinking, k2-5), gemini, glm-4.6/4.7, minimax-m2, qwen - anywhere the transform has an entry.
This was referenced May 16, 2026
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.
Issue for this PR
Closes #27796
Type of change
What does this PR do?
packages/opencode/src/session/llm.ts:172resolves temperature as:The built-in
titleagent hard-codestemperature: 0.5(packages/opencode/src/agent/agent.ts:253), so??short-circuits and the agent default always wins. For model families where the provider strictly requires a specific temperature (kimi-k2.* in particular),ProviderTransform.temperatureencodes the required value, but it never gets used. Moonshot returnsHTTP 400 invalid temperature: only 1 is allowed for this modelas a result.The fix swaps the operands so the model-aware transform wins, with the agent preference as fallback:
For models without a transform entry (claude, openai, etc.) the function returns
undefinedand the agent preference still applies via??. The only behavior change is on the families already flagged inProviderTransformas needing specific values.This also aligns temperature with the adjacent
topK(no agent override) and is closer in spirit totopP(stillagent ?? transform, buttopPhas no known strict-required cases today).How did you verify your code works?
bun typecheckclean.test/provider/transform.test.tssuite passes locally.temperature: 1and the call succeeds.A reviewer can reproduce by configuring Moonshot kimi-k2.6 and starting any new session; without the patch the title-generation call 400s, with the patch it does not.
Screenshots / recordings
N/A - no UI change.
Checklist