Skip to content

fix(ai): omit sampling params for Opus 4.7/4.8#816

Open
KeremP wants to merge 1 commit into
canaryfrom
fix/opus-4-8-sampling-params
Open

fix(ai): omit sampling params for Opus 4.7/4.8#816
KeremP wants to merge 1 commit into
canaryfrom
fix/opus-4-8-sampling-params

Conversation

@KeremP
Copy link
Copy Markdown
Contributor

@KeremP KeremP commented Jun 3, 2026

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 the effort control. Behavior must be steered via prompting.

generateObjectResponse (src/core/ai/ai.ts) forwards a temperature, and generateSessionName (src/util/name.ts) calls it with temperature: 0.7. On Opus 4.7/4.8 that 400s — and since the error is swallowed by the surrounding try/catch, AI session-name generation silently fell back to the placeholder name on those models.

Fix

  • Add modelSupportsSamplingParams(modelId) — returns false for 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.
  • Apply it centrally in generateObjectResponse so it omits temperature for those models — protecting every current and future caller. Temperature still applies on every other model (Sonnet, Haiku, older Opus, GPT).
  • Scoped to Opus 4.7/4.8 exactly, per the API docs ("same as on Claude Opus 4.7"). Older models' behavior is untouched.

Already correct (no change)

Adaptive thinking: both streamResponse and the Pensar/Bedrock formatter (pensarFormatters.ts) emit { type: "adaptive" } and never budget_tokens, so Opus 4.8 thinking was already handled correctly.

Tests

Added coverage in models.test.ts for 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 check workflow runs on PRs and canary pushes. Integration CI pins Bun 1.3.10 and runs console install/SST/typecheck via bun instead of npm/npx.

Agent skills: Adds the team-shared /create-skill skill (.agents/skills/create-skill/), a .claude/skills symlink, and .gitignore whitelists 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 -w paths off Kali.

Contributor and product docs: AGENTS.md gains working principles, closing-the-loop guidance, UI/UX and barrel-file conventions, and expanded command/CI notes. README.md is 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). Ignores sst-env.d.ts and 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.

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.
@KeremP KeremP changed the base branch from main to canary June 3, 2026 02:28
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