Skip to content
Source
Sign inSign up
TanStack/ai

ai-claude-code: chat({ reasoning }) is silently ignored for claude-opus-5-5 (missing from CLAUDE_CODE_REASONING) #2224

Closedozolcar(GitHub profile, opens in a new tab) opened this issue 2 comments
ozolcar(GitHub profile, opens in a new tab)commented

TanStack AI version

@tanstack/ai 1.8.0, @tanstack/ai-claude-code 1.0.3, @tanstack/ai-sandbox 1.5.0, @tanstack/ai-sandbox-local-process 1.0.0 (all latest on npm)

Framework/Library version

Node 26.12.0, server only (no UI framework involved)

Describe the bug and the steps to reproduce it

CLAUDE_CODE_REASONING in src/model-meta.ts:59-68 lists claude-opus-4-8, claude-opus-4-7, claude-opus-4-6, claude-sonnet-4-6, claude-haiku-4-5 and the opus, sonnet and haiku aliases. claude-opus-5-5 and the other 5-family models are not in it, so resolveReasoning returns undefined (@tanstack/ai src/reasoning.ts) and chat({ reasoning }) never becomes --effort. claudeCodeReasoning (adapters/text.ts:194-199) then returns { args: [], env: {} }, with no warning, although the default logger has warnings on. The EFFORT_MODELS pattern already matches opus-5; the lookup fails before it is checked.

#2229 (not by me) proposes a fix and is still open.

Steps:

  1. Install @tanstack/ai@1.8.0, @tanstack/ai-claude-code@1.0.3, @tanstack/ai-sandbox@1.5.0 and @tanstack/ai-sandbox-local-process@1.0.0 in an ESM package, and create an empty work/ folder.
  2. Save fake-claude.mjs and repro.mjs below next to each other, and run chmod +x fake-claude.mjs.
  3. Run node repro.mjs.

fake-claude.mjs (make it executable with chmod +x):

#!/usr/bin/env node
// Stands in for the `claude` CLI. Records argv and the thinking env, then prints the
// stream-json lines that @tanstack/ai-claude-code parses.
import { writeFileSync } from 'node:fs'

for await (const _ of process.stdin); // read the prompt, as the CLI does (exiting first gives the runner EPIPE)
const argv = process.argv.slice(2)
writeFileSync(new URL('./last-call.json', import.meta.url), JSON.stringify({ argv, MAX_THINKING_TOKENS: process.env.MAX_THINKING_TOKENS }))

// On --resume the CLI restores the session's saved totals, so result.total_cost_usd is the
// session total (https://code.claude.com/docs/en/agent-sdk/cost-tracking). Here
// run 1 costs $0.25 and the resumed run 2 costs $0.50, so run 2 reports $0.75.
const resumed = argv.includes('--resume')
const say = (line) => console.log(JSON.stringify(line))
say({ type: 'system', subtype: 'init', session_id: 'sess-1', model: 'x', tools: [] })
say({ type: 'assistant', parent_tool_use_id: null, message: { id: resumed ? 'm2' : 'm1', content: [{ type: 'text', text: 'ok' }] } })
say({ type: 'result', subtype: 'success', usage: { input_tokens: 1, output_tokens: 1 }, total_cost_usd: resumed ? 0.75 : 0.25 })

repro.mjs:

// #2224: chat({ reasoning }) is dropped for claude-opus-5-5.
import { readFileSync } from 'node:fs'
import { chat } from '@tanstack/ai'
import { claudeCodeText } from '@tanstack/ai-claude-code'
import { defineSandbox, withSandbox } from '@tanstack/ai-sandbox'
import { localProcessSandbox } from '@tanstack/ai-sandbox-local-process'

const sandbox = defineSandbox({ id: 'repro', provider: localProcessSandbox({ dir: new URL('./work', import.meta.url).pathname }) })

for (const model of ['claude-opus-4-8', 'claude-opus-5-5']) {
  const stream = chat({
    adapter: claudeCodeText(model, { claudeExecutable: new URL('./fake-claude.mjs', import.meta.url).pathname, emitDiff: false }),
    messages: [{ role: 'user', content: 'hi' }],
    threadId: 't1',
    reasoning: 'high',
    middleware: [withSandbox(sandbox)],
  })
  for await (const c of stream) if (c.type === 'RUN_ERROR') console.log(c.message)
  const { argv, MAX_THINKING_TOKENS } = JSON.parse(readFileSync(new URL('./last-call.json', import.meta.url)))
  const i = argv.indexOf('--effort')
  console.log(`${model}: --effort ${i === -1 ? '(none)' : argv[i + 1]}, MAX_THINKING_TOKENS=${MAX_THINKING_TOKENS ?? '(unset)'}`)
}
// Fixed: claude-opus-5-5: --effort high

Output:

claude-opus-4-8: --effort high, MAX_THINKING_TOKENS=(unset)
claude-opus-5-5: --effort (none), MAX_THINKING_TOKENS=(unset)

Expected: claude-opus-5-5: --effort high. The 5-family models are listed with their effort levels, or an unknown model passes the effort through with a warning instead of dropping it.

Inline above. Plain Node script with no network, no model and no API key. fake-claude.mjs stands in for the claude CLI through claudeExecutable: it records the argv the adapter passes and prints the stream-json lines the adapter parses.

Screenshots or Videos (Optional)

None.

Do you intend to try to help solve this bug with your own PR?

Maybe, I'll investigate and start debugging

Terms & Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
  1. tanstack-source added labelsbug

  2. Thanks for the report, @ozolcar! To help us reproduce this, could you add a minimal reproduction?

    A runnable example makes fixes dramatically faster — you can fork one of the official examples, or use StackBlitz / CodeSandbox. For TypeScript-only issues, a TS Playground link works too.

    Automated triage — a maintainer will follow up.
  3. github-actions[bot](GitHub profile, opens in a new tab) added labelswaiting-on: maintainer

  4. I added a minimal, runnable reproduction to the description: a plain Node script with no network, no model and no API key, tested on the current npm releases.

  5. tombeckenham closed this

Sign in to join this conversation.