Persistence (Advanced)
- Build your first harness
- Host options
- Send and show media
- Connect clients
- Write a client in any language
- Access and tenants
- Run in the terminal
- Deploy a harness
- Send inputs safely
- Run a tool without a model
- Durable sessions
- Run background work on workers
- List, rename, and fork sessions
- Lifecycle and retention
- Run side effects once
- Wait for a person
- Build on the session log
- Control how a turn ends
- Store settings per thread
- Compact a long session
- Fork and reset a thread
- One log for a session tree
- Write a plugin
- Track usage and cost
- Ask before risky tool calls
- Give your agent coding tools
- Sandbox and extend the coding tools
- Run the coding tools for many threads
- Undo a turn
- Build a coding agent
- Delegate to coding agents
- Switch between agent profiles
- Auth and connectors
- Share a thread between people
- Connect model providers
- Build your own UI
- Code mode in a harness
- Work until a goal is met
- Run agents from a harness
- Hand off a conversation
- Add skills
- Use MCP servers
- Give your agent a computer
- Use from any MCP client
- Use a harness from an editor (ACP)
- Overview
- Quick Start
- ProvidersUpdated
- Harnesses
- Harness Auth
- Workspace
- Tools
- Policy
- Lifecycle & Snapshots
- Portable Snapshots
- Keep Files After Reload
- Save a Named Version
- Branch From a Version
- Send a Frozen File
- Let the Agent Save and Fork
- Pick Which Files to Keep
- What a Snapshot Stores
- Instance Durability
- Durable Runs
- Events
Sandboxes (Advanced)
- Runtime Context
- Bring Your Own Key
- Keep Keys on the Server
- Debug Logging
- Multimodal Content
- Files API
- Per-Model Type Safety
- Runtime Adapter Switching
- Tree-Shaking
- Extend Adapter
- Extend Adapter: Advanced
- Typed Pre-Configured Options
- Test with a Fake Model
- Prompt Caching
- Mid-Conversation Changes
- Approval Flow Processing
Moving reasoning into chat()
Move reasoning, thinking, and thinkingConfig out of modelOptions. Pass reasoning to chat() as a level, or as { level, summary, budgetTokens }.
Upgrade#
- Delete the reasoning field from modelOptions.
- Set reasoning on chat(). Find the old field of your adapter in the table below.
- If you set a token budget, move it to budgetTokens. See Budgets.
- Run your type checker.
There is no codemod for this change.
// Before
chat({
adapter: openaiText("gpt-6.1-sol"),
messages,
modelOptions: { reasoning: { effort: "high", summary: "auto" } },
});import { chat } from "@tanstack/ai";
import { openaiText } from "@tanstack/ai-openai";
const messages = [{ role: "user" as const, content: "Hello" }];
// After
chat({
adapter: openaiText("gpt-6.1-sol"),
messages,
threadId: "thread-1",
reasoning: "high",
});The thinking text streams by default. To hide it, pass reasoning: { level: "high", summary: false }.
Adapter by adapter#
| Adapter | Old modelOptions field | Now |
|---|---|---|
| openaiText, openaiChatCompletions, azureOpenaiText | reasoning: { effort, summary } | reasoning: "high" |
| anthropicText | thinking, effort, output_config.effort | reasoning: "high", or { level, budgetTokens } on budget models |
| geminiText | thinkingConfig | reasoning: "high", or { level, budgetTokens } on Gemini 2.5 |
| geminiTextInteractions | generation_config.thinking_level, thinking_summaries | reasoning: "high" |
| grokText, openRouterText | reasoning: { effort } | reasoning: "high" |
| vercelGatewayText, lovableText | reasoning, include_reasoning | reasoning: "high" |
| bedrockText | reasoning_effort (chat), reasoning (Responses) | reasoning: "high" |
| groqText, llmGatewayText, cloudflareText | reasoning_effort | reasoning: "high" |
| byteplusText | thinking, reasoning_effort | reasoning: "high", or "off" |
| ollamaText | think | reasoning: "high", or "off" |
| codexText | modelReasoningEffort | reasoning: "high" |
"high" is an example. Use any level that your model has. The types show the levels of your model.
Budgets#
An Anthropic or Gemini 2.5 budget moves to budgetTokens:
// Before
modelOptions: { thinking: { type: "enabled", budget_tokens: 8000 } }import { chat } from "@tanstack/ai";
import { anthropicText } from "@tanstack/ai-anthropic";
const messages = [{ role: "user" as const, content: "Hello" }];
// After
chat({
adapter: anthropicText("claude-haiku-4-5"),
messages,
threadId: "thread-1",
reasoning: { level: "high", budgetTokens: 8000 },
});The adapter raises max_tokens when it is below the budget.
Azure#
azureOpenaiText and createAzureOpenaiText read the levels of the OpenAI model name that you pass, not of your deployment name:
import { chat } from "@tanstack/ai";
import { createAzureOpenaiText } from "@tanstack/ai-openai";
const messages = [{ role: "user" as const, content: "Hello" }];
chat({
adapter: createAzureOpenaiText("gpt-6.1-sol", "azure-key", {
resourceName: "my-resource",
deploymentName: "prod-chat",
}),
messages,
threadId: "thread-1",
reasoning: "high",
});If you pass only a deployment name as the model, the adapter has no levels for it, and reasoning is a type error. Pass the OpenAI model name, and set deploymentName.
Codex#
modelReasoningEffort stays on the codexText config. It is the default for a call without reasoning.
Removed types#
- @tanstack/ai-openai: OpenAIReasoningOptions, OpenAIReasoningOptionsWithConcise.
- @tanstack/ai-anthropic: AnthropicThinkingOptions, AnthropicAdaptiveThinkingOptions, AnthropicAdaptiveOnlyThinkingOptions, AnthropicAdaptiveOrDisabledThinkingOptions, AnthropicEffortOptions, AnthropicOutputConfigOptions.
- @tanstack/ai-gemini: GeminiThinkingOptions.
- @tanstack/ai-grok: GrokReasoning, GrokReasoningEffort, GrokBuildProviderOptions.
- @tanstack/ai-openrouter: ReasoningOptions. @tanstack/ai-byteplus: BytePlusThinkingOption, BytePlusReasoningEffort.
Done#
Your type checker passes, and no modelOptions has a reasoning field. One reasoning option now sets reasoning on every provider. For levels, budgets, and middleware, see Reasoning.