Skip to content

fix(brain): Claude as the brain — temperature is optional, refused params are learned - #74

Merged
rockywuest merged 2 commits into
mainfrom
fix/brain-claude-temperature
Oct 25, 2026
Merged

rockywuest merged 2 commits into
mainfrom
fix/brain-claude-temperature

Conversation

@rockywuest

Copy link
Copy Markdown
Owner

Setting up the brain on the Pi 5 with Claude Opus 5.5 (via https://api.anthropic.com/v1/chat/completions), verified against the live endpoint:

HTTP 400 {"error": {"code": "invalid_request_error", "message": "`temperature` is deprecated for this model."}}

The brain hardcoded "temperature": 0.7, and its existing 400 retry only removed response_format — so the retry failed identically and every voice turn ended in "LLM API error".

Changes

  • LLM_TEMPERATURE env (default 0.7, off sends none)
  • 400 retry drops whichever optional param the error body names (temperature / response_format; falls back to response_format as before), and remembers it for the process — no double round trip per sentence, which matters for voice latency
  • install-brain.sh template: Claude example, plus a warning that a Claude subscription token (sk-ant-oat…) is not an API key (found on the real machine: OpenClaw's token gets invalid x-api-key on the API)

Tests

tests/test_llm_compat.py: verbatim Claude error → dropped + remembered, response_format survives; off sends none; an unrelated 400 is not retried endlessly; autouse fixture isolates the learned set. 656 passed, ruff: no new findings.

🤖 Generated with Claude Code

rockywuest and others added 2 commits October 25, 2026 21:37
…rams are learned

Opus 5.5 (and the other current Claude models), also through Anthropic's
OpenAI-compatible endpoint, answer every request that carries a temperature
with 400 "`temperature` is deprecated for this model". The brain sent a
hardcoded 0.7, and its 400 retry only dropped response_format — so the
retry failed the same way and the dog never got an answer.

- LLM_TEMPERATURE (default 0.7, "off" sends none).
- The 400 retry drops whichever optional parameter the error names
  (temperature or response_format; response_format if it names none) and
  remembers it, so later sentences pay no extra round trip.
- install-brain.sh's template shows the Claude setup, and warns that a
  Claude subscription token (sk-ant-oat...) is not an API key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…y why, budget hint

- request_llm loops until no refusable parameter is left, so a turn where
  the endpoint refuses temperature and then response_format still answers.
- A 400 with nothing left to drop carries the endpoint's own words instead
  of a bare "Bad Request".
- An empty answer with finish_reason "length" says to raise the new
  LLM_MAX_TOKENS (Opus 5.5 always thinks first), not to switch to llama3.2.
- LLM_TEMPERATURE="abc"/"0,7"/"nan" fails naming the setting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rockywuest

Copy link
Copy Markdown
Owner Author

Review folded in: both refused params are dropped within one turn (loop), an unknown 400 now shows the endpoint's message, empty answers with finish_reason: length point to the new LLM_MAX_TOKENS instead of llama3.2, and a bad LLM_TEMPERATURE names the setting. 668 passed.

@rockywuest
rockywuest merged commit ce5ab13 into main Oct 25, 2026
4 checks passed
@rockywuest
rockywuest deleted the fix/brain-claude-temperature branch October 25, 2026 20:41
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