Skip to content

fix(ai-import): adapt to models that reject an explicit temperature#4

Open
silasg wants to merge 1 commit into
developfrom
claude/issue-1151-fix-proposal-4a0dkf
Open

fix(ai-import): adapt to models that reject an explicit temperature#4
silasg wants to merge 1 commit into
developfrom
claude/issue-1151-fix-proposal-4a0dkf

Conversation

@silasg

@silasg silasg commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Problem

AI Bean Import fails for OpenAI GPT‑5.x / reasoning models (e.g. gpt-5.6-terra) — they reject a non-default temperature with 400 Unsupported value: 'temperature'. See graphefruit#1151. The request body hard-coded temperature: 0.1 for every model.

Approach

Rather than maintain a model-name allowlist (which would break again on the next new model), send temperature best-effort and adapt:

  1. Send temperature: 0.1 as before.
  2. If a request is rejected specifically because of temperature (a 400 whose body mentions temperature), drop the parameter, retry once, and remember the provider+model so later requests skip it.

This keeps the deterministic low temperature on every model that honors it (Anthropic, Gemini, Mistral, gpt-4o, …) and self-heals for current and future models that don't. Callers that already know a model's capabilities can set supportsTemperature: false to skip even the first failed attempt (wired up in a follow-up PR).

Changes

  • temperature is now an optional, per-protocol build option instead of a hard-coded literal.
  • sendCloudLLMPrompt gains the send → drop/retry-once → remember flow, plus a session cache keyed by provider::baseUrl::model.
  • New supportsTemperature? config flag and resetTemperatureSupportCache() export.

Testing

Added 7 specs covering: default temperature still sent, retry-without-temperature on rejection, remembering it, no retry on unrelated 400s, supportsTemperature:false short-circuit, keeping the value where accepted, and a failing retry surfacing its error.

Note: the full Karma suite could not be executed in the authoring environment — pnpm install is blocked by an egress-policy 403 on xlsx (sheetjs CDN), which the Angular build needs. The changed service is pure TypeScript, so its behavior was verified in isolation (esbuild bundle of the real module, 14/14 assertions incl. the added scenarios) and type-checked with tsc. Please run pnpm test in CI to confirm.

🤖 Generated with Claude Code


Generated by Claude Code

OpenAI GPT-5.x / reasoning models reject a non-default `temperature`
with a 400, which broke AI bean import for those models (graphefruit#1151).

Instead of hard-coding a model-name list, send `temperature` best-effort:
if a request is rejected specifically because of temperature, drop it,
retry once, and remember the provider+model so later requests skip it.
This keeps the deterministic low temperature on every model that honors
it (Anthropic, Gemini, Mistral, gpt-4o, ...) and self-heals for current
and future models that do not. Callers that already know a model's
capabilities (e.g. from OpenRouter's supported_parameters) can set
`supportsTemperature: false` to skip even the first failed attempt.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DKKv2cbKhcgE2cTbkhvzjd
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