Skip to content

fix: make the API work with current Claude models (temperature 400, content-block 500) - #3

Merged
dpelezo merged 2 commits into
masterfrom
fix/omit-temperature
Nov 23, 2026
Merged

dpelezo merged 2 commits into
masterfrom
fix/omit-temperature

Conversation

@dpelezo

@dpelezo dpelezo commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

Makes the API work with current Claude models. Two problems showed up once a valid key was in place:

  1. 400 BadRequestError on every chat: the API sent temperature=0, and current models (including the default claude-haiku-5-5) reject any temperature other than 1.
  2. 500 on GET /api/thread: current models think adaptively, so a reply can be a list of content blocks (thinking, text) instead of a string. The API stored that list, and the response model, which expects a string, failed. Research steps also broke, because they call .strip() on the reply.

Changes

  • LLM_TEMPERATURE defaults to unset, so it is left out of the request.
  • New message_text() returns only a reply's text blocks. Thinking is never shown to users. It is used in chat, the research steps and the workflow log.
  • New LLM_MAX_TOKENS setting, default 4096 (LangChain's default was 1024), because thinking counts toward the limit.
  • .env.example, docker-compose.yml and the README are updated.

Verification

  • pytest -q: 37 passed. New tests cover the request payload (no sampling parameters, max_tokens), message_text, a thinking-block reply through /api/thread, and a thinking-block research report.
  • ruff check app tests: passes
  • Reproduced the 500 with a thinking-block reply before the fix

After merging

Delete LLM_TEMPERATURE from the Vercel project's environment variables if it is set.

https://claude.ai/code/session_01XtW6Y5JF5GNt1txL7PriFg


Generated by Claude Code

Claude 4.7 and newer models, including the default claude-haiku-5-5,
return 400 invalid_request_error for any temperature other than 1. The
API sent temperature=0 on every call, so every chat request failed.
LLM_TEMPERATURE now defaults to unset, and the request omits it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XtW6Y5JF5GNt1txL7PriFg
@vercel

vercel Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ai-assistant-api Ready Ready Preview Nov 23, 2026 7:53pm UTC

Current Claude models think adaptively, so a reply can be a list of
blocks (thinking, text) instead of a string. Storing that list made
GET /api/thread fail with a 500, and research steps fell back because
they called .strip() on it. message_text() now returns only the text
blocks. max_tokens rises from LangChain's default 1024 to 4096, because
thinking counts toward the limit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XtW6Y5JF5GNt1txL7PriFg
@dpelezo dpelezo changed the title fix: stop sending temperature to Claude (400 on current models) fix: make the API work with current Claude models (temperature 400, content-block 500) Nov 23, 2026
@dpelezo
dpelezo merged commit 8a2a961 into master Nov 23, 2026
4 checks passed
@dpelezo
dpelezo deleted the fix/omit-temperature branch November 23, 2026 21:45

This branch was successfully deployed

2 active (1 outdated) deployments
Preview — af60b768 Deployed Nov 23, 2026 by vercel[bot]
Production — fa958df9 Deployed Nov 23, 2026 by vercel[bot]
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