fix(ai): omit sampling params for Opus 4.7/4.8#816
Open
KeremP wants to merge 1 commit into
Open
Conversation
Claude Opus 4.7 and 4.8 reject non-default temperature/top_p/top_k with a
400 error. generateObjectResponse forwarded a temperature, and
generateSessionName passed temperature: 0.7, so AI session naming silently
failed (placeholder fallback) on those models.
Add modelSupportsSamplingParams() (matches native, Bedrock, and OpenRouter
id forms) and omit temperature in generateObjectResponse for unsupported
models. Temperature still applies on every other model.
Thinking is already correct: streamResponse and the Pensar/Bedrock
formatter both emit { type: "adaptive" }, never budget_tokens.
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.
Problem
Claude Opus 4.7 and 4.8 reject any non-default sampling parameter (
temperature,top_p,top_k) with a 400 error — they expose only adaptive thinking and theeffortcontrol. Behavior must be steered via prompting.generateObjectResponse(src/core/ai/ai.ts) forwards atemperature, andgenerateSessionName(src/util/name.ts) calls it withtemperature: 0.7. On Opus 4.7/4.8 that 400s — and since the error is swallowed by the surroundingtry/catch, AI session-name generation silently fell back to the placeholder name on those models.Fix
modelSupportsSamplingParams(modelId)— returnsfalsefor Opus 4.7/4.8, matching native (claude-opus-4-8), Bedrock (…anthropic.claude-opus-4-8), and OpenRouter (anthropic/claude-opus-4.8) id forms.generateObjectResponseso it omitstemperaturefor those models — protecting every current and future caller. Temperature still applies on every other model (Sonnet, Haiku, older Opus, GPT).Already correct (no change)
Adaptive thinking: both
streamResponseand the Pensar/Bedrock formatter (pensarFormatters.ts) emit{ type: "adaptive" }and neverbudget_tokens, so Opus 4.8 thinking was already handled correctly.Tests
Added coverage in
models.test.tsfor the id-form matching. All 157 AI/findings tests pass; biome clean.Note
Low Risk
Changes are mostly CI, documentation, and static assets; build smoke tests add coverage but do not alter runtime auth or pentest logic in the diff shown.
Overview
This PR is mostly tooling, CI, docs, and packaged assets—not the Opus 4.7/4.8 sampling fix described in the PR text (that logic is not in the diff shown).
CI and quality gates: Lint is documented and wired for Biome (plus Prettier for Markdown/YAML). A reusable knip dead-code job is added to the main CI pipeline. Build smoke tests expand to cover global npm install under Node and Bun, TUI behavior when Bun is missing, and the compiled binary. A new
fern checkworkflow runs on PRs andcanarypushes. Integration CI pins Bun 1.3.10 and runs console install/SST/typecheck viabuninstead ofnpm/npx.Agent skills: Adds the team-shared
/create-skillskill (.agents/skills/create-skill/), a.claude/skillssymlink, and.gitignorewhitelists so only that skill is committed by default.Bundled wordlists: Ships
assets/wordlists/(tiny,common,large, SecLists license/README) so dir-bruteforce tools have portable-wpaths off Kali.Contributor and product docs:
AGENTS.mdgains working principles, closing-the-loop guidance, UI/UX and barrel-file conventions, and expanded command/CI notes.README.mdis restructured (use cases, install table, headless CLI flags, W&B Weave, OpenTelemetry). VS Code defaults to Biome on save.Misc: Removes root
.prettierignore(format scope shifts with Biome). Ignoressst-env.d.tsand local Claude settings under skills.Reviewed by Cursor Bugbot for commit 136fe5a. Bugbot is set up for automated code reviews on this repo. Configure here.