Skip to content

docs: fix inaccurate code samples and expand coverage across guides#691

Merged
AlemTuzlak merged 7 commits into
mainfrom
worktree-lazy-beaming-sloth
Jun 3, 2026
Merged

docs: fix inaccurate code samples and expand coverage across guides#691
AlemTuzlak merged 7 commits into
mainfrom
worktree-lazy-beaming-sloth

Conversation

@AlemTuzlak
Copy link
Copy Markdown
Contributor

@AlemTuzlak AlemTuzlak commented Jun 3, 2026

What

A documentation-only pass that audited the guide pages against the actual package APIs and fixed copy-paste-broken / outdated code samples, plus filled some coverage gaps. Every fix was cross-checked against packages/ source.

Highlights

Middleware & structured outputs

  • New Built-in Middleware page (toolCacheMiddleware, contentGuardMiddleware, otelMiddleware) and a new top-level Middleware nav section.
  • Document transforming structured-output chunks via onChunk + ctx.phase (and the native-combined caveat); correct middleware type import paths (@tanstack/ai/middlewares).
  • One-shot structured outputs now document client consumption via useChat's partial / final.

Correctness fixes (verified against source)

  • chat: providerOptionsmodelOptions; invalid model ids; budget_tokens requires maxTokens; async stream() factory → fetcher; add missing imports; document the default maxIterations(5) and agentLoopStrategy.
  • tools: toServerSentEventsStreamtoServerSentEventsResponse; remove a duplicate tools: key; clarify tool-call vs tool-result states; fix the React examples and state diagram; add emitCustomEvent / runtime-context coverage.
  • media: add required model args to factory calls; fix a recursive generateVideo; TranscriptionResult.words is top-level; speed is a top-level speech option; Gemini audio returns b64Json; onResult transform signature.
  • advanced: adapter.model (not selectedModel); GeminiImageMetadata; source.mimeType; the text.format structured-output shape; fill the empty "How It Works"; createModel capabilities form; soften unsubstantiated bundle-size figures.
  • protocol: rewrite the SSE / HTTP-stream pages to the AG-UI event format (drop obsolete {"type":"content"} shapes and the non-existent [DONE] marker); use toHttpResponse / toHttpStream; expand chunk-definitions with TOOL_CALL_RESULT, MESSAGES_SNAPSHOT, the REASONING_* family, and deprecated-alias notes.
  • adapters: ElevenLabs SFX model id + @elevenlabs/client; Ollama modelOptions placement; Cencori AG-UI event/tools alignment.
  • Fix @tanstack/ai-openai/adapters@tanstack/ai-openai (not a real subpath).

How it was done

Audited via parallel source-cross-checking agents (one per doc cluster), then applied fixes via parallel editors. One auditor claim (complete "isn't a ToolCallState") was wrong — complete is in the union but the runtime never emits it for tool-call parts — so the wording was corrected to be both type- and runtime-accurate.

Verification

  • node scripts/verify-links.ts — no broken links
  • Prettier — clean
  • Docs-only; no source or behavior changes

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Updated model identifiers across examples (Anthropic, OpenAI, Gemini, Gemini TTS, etc.).
    • Added built-in middleware guide for caching, content-guarding, and OpenTelemetry.
    • Expanded middleware, streaming, observability, and protocol event specs and lifecycles.
    • Clarified tool execution, approval flows, hybrid tools, and client/server examples.
    • Improved type-safety, structured-output guidance, and media generation/transcription docs.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 3, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR updates 45 documentation files: protocol and transport specs, new built-in middleware page and imports, widespread adapter/model example string updates, chat streaming/reasoning reconciliation, tool lifecycle and approval clarifications, media/transcription docs, structured-output consumption guidance, and navigation changes.

Changes

Documentation updates

Layer / File(s) Summary
AG-UI event contracts and streaming protocols
docs/protocol/chunk-definitions.md, docs/protocol/http-stream-protocol.md, docs/protocol/sse-protocol.md
AG-UI event types expanded (tool results, reasoning, snapshots/deltas); run events require threadId; RunErrorEvent uses top-level message/code; HTTP/SSE streams accept RunAgentInput and terminate with RUN_FINISHED.
Built-in middleware and type exports
docs/advanced/built-in-middleware.md, docs/advanced/middleware.md, docs/advanced/observability.md, docs/advanced/otel.md
Add built-in-middleware.md documenting toolCacheMiddleware, contentGuardMiddleware, otelMiddleware; move built-in middleware types to @tanstack/ai/middlewares; update observability import paths and frontmatter ordering.
Adapter model IDs and advanced docs
docs/adapters/anthropic.md, docs/adapters/elevenlabs.md, docs/advanced/multimodal-content.md, docs/advanced/runtime-adapter-switching.md, docs/advanced/tree-shaking.md, docs/advanced/typed-options.md, docs/advanced/extend-adapter.md, docs/advanced/per-model-type-safety.md
Systematic example model updates (e.g., gpt-5.2→gpt-5.5, claude-sonnet-4-5→4-6, claude-opus-4-6→4.8); Anthropic thinking guidance uses modelOptions; ElevenLabs SDK/package, option shapes, and examples updated.
Chat streaming and reasoning reconciliation
docs/chat/streaming.md, docs/chat/thinking-content.md, docs/chat/agentic-cycle.md
ThinkingPart reconciles canonical REASONING_MESSAGE_* and legacy STEP_* events; streaming guidance uses message.parts; document fetcher transport signature and cancellation semantics; add agent loop control strategies.
Tool lifecycle, approval, and execution
docs/tools/client-tools.md, docs/tools/server-tools.md, docs/tools/tool-approval.md, docs/tools/tool-architecture.md, docs/tools/tools.md, docs/tools/provider-tools.md
Separate tool-call part state machine from sibling tool-result part; use TOOL_CALL_START/END and toolCallName; document approval wiring (part.approval.id + addToolApprovalResponse), server ToolExecutionContext, and client detection via part.output.
Media generation and transcription
docs/media/*
Update audio/image/video/tts/transcription examples and shapes (e.g., result.audio.b64Json, timestamp_granularities), move some options to top-level, allow onResult to return `TOutput
Structured output schemas and client consumption
docs/structured-outputs/*
Document client consumption patterns for one-shot outputs (useChat({ outputSchema }) vs server-returned JSON); update model examples and Zod .meta() guidance.
Quick-start, examples, and navigation
docs/getting-started/quick-start.md, docs/comparison/vercel-ai-sdk.md, docs/community-adapters/cencori.md, docs/migration/ag-ui-compliance.md, docs/config.json
Add error handling UI in quick-start; update examples to new model IDs and message shapes; refactor Cencori examples to new event types; migrate some imports to @tanstack/ai-openai; extract Middleware into top-level docs section.

Estimated code review effort:
🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • TanStack/ai#635: Overlap in middleware API and import path updates and adapter documentation changes.
  • TanStack/ai#222: Prior documentation update of OpenAI model strings; related to model-string migrations.
  • TanStack/ai#426: Related ElevenLabs and thinking/reasoning documentation updates.

Suggested reviewers

  • harry-whorlow
  • crutchcorn
  • jherr

🐰 "From model strings to middleware, docs anew,
Events reconciled and tool states split in two,
Examples updated, streams now end with FINISHED,
A rabbit hops through docs freshly polished,
Hooray for clear specs and a tidy view!"

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-lazy-beaming-sloth

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
docs/chat/agentic-cycle.md (1)

163-164: maxIterations is correctly exported from @tanstack/ai (no import change needed)
maxIterations is re-exported as a named export from @tanstack/ai (via packages/ai/src/index.ts), so the imports at docs/chat/agentic-cycle.md (lines 163-164) are valid. Optional: combine into import { chat, maxIterations } from "@tanstack/ai";.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/chat/agentic-cycle.md` around lines 163 - 164, The two separate imports
of chat and maxIterations are valid but redundant; update the import statements
to a single combined import to tidy the file by replacing the separate imports
with one line importing both symbols (chat, maxIterations) from "`@tanstack/ai`"
so the module usage remains identical while reducing duplication.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/tools/tool-architecture.md`:
- Around line 137-139: Docs currently state the call part has no "complete"
value but ToolCallState in code includes 'complete'; update the problematic
paragraph describing the call part states (the list on the tool-call part and
the surrounding wording) to include 'complete' among the call states
(awaiting-input, input-streaming, input-complete, approval-requested,
approval-responded, complete) while keeping executing/error/cancelled described
as only present on the sibling tool-result part; ensure you reference part.state
for the tool-call and part.output mirroring to keep the conceptual diagram text
consistent with the ToolCallState type.

---

Nitpick comments:
In `@docs/chat/agentic-cycle.md`:
- Around line 163-164: The two separate imports of chat and maxIterations are
valid but redundant; update the import statements to a single combined import to
tidy the file by replacing the separate imports with one line importing both
symbols (chat, maxIterations) from "`@tanstack/ai`" so the module usage remains
identical while reducing duplication.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a99f3893-7d45-4056-8284-5bdc1d056ba9

📥 Commits

Reviewing files that changed from the base of the PR and between 6df32b5 and fa36233.

📒 Files selected for processing (38)
  • docs/adapters/anthropic.md
  • docs/adapters/elevenlabs.md
  • docs/adapters/ollama.md
  • docs/advanced/built-in-middleware.md
  • docs/advanced/extend-adapter.md
  • docs/advanced/middleware.md
  • docs/advanced/multimodal-content.md
  • docs/advanced/observability.md
  • docs/advanced/otel.md
  • docs/advanced/per-model-type-safety.md
  • docs/advanced/runtime-adapter-switching.md
  • docs/advanced/tree-shaking.md
  • docs/advanced/typed-options.md
  • docs/chat/agentic-cycle.md
  • docs/chat/streaming.md
  • docs/chat/thinking-content.md
  • docs/community-adapters/cencori.md
  • docs/comparison/vercel-ai-sdk.md
  • docs/config.json
  • docs/getting-started/quick-start.md
  • docs/media/audio-generation.md
  • docs/media/generation-hooks.md
  • docs/media/generations.md
  • docs/media/image-generation.md
  • docs/media/text-to-speech.md
  • docs/media/transcription.md
  • docs/media/video-generation.md
  • docs/migration/ag-ui-compliance.md
  • docs/protocol/chunk-definitions.md
  • docs/protocol/http-stream-protocol.md
  • docs/protocol/sse-protocol.md
  • docs/structured-outputs/one-shot.md
  • docs/structured-outputs/overview.md
  • docs/tools/client-tools.md
  • docs/tools/server-tools.md
  • docs/tools/tool-approval.md
  • docs/tools/tool-architecture.md
  • docs/tools/tools.md

Comment on lines +137 to +139
> **Two parts, two state sets — this page is the canonical reference.** Call states (`awaiting-input`, `input-streaming`, `input-complete`, `approval-requested`, `approval-responded`) live on the **`tool-call`** part as `part.state`. There is no `complete`/`error`/`executing`/`cancelled` value on the call part. The *result* lives on a separate sibling **`tool-result`** part whose own `state` is `streaming`, `complete`, or `error`; the resolved value is also mirrored onto the call part's `part.output`.

The diagram below is conceptual: the nodes after `approval-responded` (executing, success, error, cancelled) are **not** `ToolCallState` values — they correspond to the sibling `tool-result` part's state (`complete` / `error`) and the call part's `output` field.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Check the complete ToolCallState type definition to confirm whether 'complete' is a valid call state.

# Search for the ToolCallState type definition
rg -nP -A 10 "^export type ToolCallState\s*=" --type=ts

Repository: TanStack/ai

Length of output: 2465


Fix docs to include ToolCallState’s complete on the call part (tool-architecture.md).

ToolCallState includes 'complete' in the source types (e.g., packages/ai/src/types.ts and the corresponding client/event-client types), but the doc lists only five call states and claims there is no complete value on the call part. Update the call-state list/wording around lines 137-139 to include complete; keep error/executing/cancelled as tool-result-only states.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/tools/tool-architecture.md` around lines 137 - 139, Docs currently state
the call part has no "complete" value but ToolCallState in code includes
'complete'; update the problematic paragraph describing the call part states
(the list on the tool-call part and the surrounding wording) to include
'complete' among the call states (awaiting-input, input-streaming,
input-complete, approval-requested, approval-responded, complete) while keeping
executing/error/cancelled described as only present on the sibling tool-result
part; ensure you reference part.state for the tool-call and part.output
mirroring to keep the conceptual diagram text consistent with the ToolCallState
type.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/chat/thinking-content.md`:
- Line 42: Rewrite the ambiguous phrase to use an explicit comparator: update
the sentence that references passing the thinking option (modelOptions with
type: "enabled" and budget_tokens) to say that if budget_tokens >= maxTokens
then the adapter will automatically increase maxTokens so there is room for the
visible response in addition to the thinking budget; mention the exact fields
(modelOptions.thinking.type, modelOptions.thinking.budget_tokens and maxTokens)
so readers know which values are compared.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f9bf6fda-2d68-4ad6-85ec-28dcce0788ff

📥 Commits

Reviewing files that changed from the base of the PR and between fa36233 and 472348a.

📒 Files selected for processing (17)
  • docs/adapters/anthropic.md
  • docs/adapters/elevenlabs.md
  • docs/advanced/multimodal-content.md
  • docs/advanced/observability.md
  • docs/advanced/typed-options.md
  • docs/chat/thinking-content.md
  • docs/comparison/vercel-ai-sdk.md
  • docs/media/generations.md
  • docs/media/text-to-speech.md
  • docs/media/transcription.md
  • docs/media/video-generation.md
  • docs/protocol/chunk-definitions.md
  • docs/structured-outputs/one-shot.md
  • docs/structured-outputs/overview.md
  • docs/tools/client-tools.md
  • docs/tools/server-tools.md
  • docs/tools/tools.md
✅ Files skipped from review due to trivial changes (6)
  • docs/media/generations.md
  • docs/adapters/anthropic.md
  • docs/advanced/typed-options.md
  • docs/tools/server-tools.md
  • docs/media/transcription.md
  • docs/media/video-generation.md
🚧 Files skipped from review as they are similar to previous changes (6)
  • docs/advanced/observability.md
  • docs/structured-outputs/overview.md
  • docs/media/text-to-speech.md
  • docs/advanced/multimodal-content.md
  • docs/tools/client-tools.md
  • docs/protocol/chunk-definitions.md

Comment thread docs/chat/thinking-content.md Outdated
### Anthropic (Extended Thinking)

Pass the `thinking` option in `providerOptions`. You must specify `budget_tokens` (minimum 1024):
Pass the `thinking` option in `modelOptions` with `type: "enabled"` and a `budget_tokens` (minimum 1024). If `budget_tokens` is not below `maxTokens`, the adapter automatically raises `maxTokens` so there is room for the visible response in addition to the thinking budget:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Clarify the budget_tokens vs maxTokens condition wording.

“not below maxTokens” is ambiguous; use an explicit comparator (for example, “if budget_tokens >= maxTokens”) to avoid misconfiguration.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/chat/thinking-content.md` at line 42, Rewrite the ambiguous phrase to
use an explicit comparator: update the sentence that references passing the
thinking option (modelOptions with type: "enabled" and budget_tokens) to say
that if budget_tokens >= maxTokens then the adapter will automatically increase
maxTokens so there is room for the visible response in addition to the thinking
budget; mention the exact fields (modelOptions.thinking.type,
modelOptions.thinking.budget_tokens and maxTokens) so readers know which values
are compared.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
docs/chat/agentic-cycle.md (1)

163-164: 💤 Low value

Consider combining imports from the same package.

Both chat and maxIterations are imported from @tanstack/ai, so they can be combined into a single import statement for consistency with standard practices.

📦 Proposed fix to combine imports
-import { chat } from "`@tanstack/ai`";
-import { maxIterations } from "`@tanstack/ai`";
+import { chat, maxIterations } from "`@tanstack/ai`";
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/chat/agentic-cycle.md` around lines 163 - 164, Combine the two separate
imports from the same package into a single import statement: replace the
separate imports of chat and maxIterations from "`@tanstack/ai`" with one import
that includes both symbols (e.g., import { chat, maxIterations } from
"`@tanstack/ai`") so update the import lines that reference chat and maxIterations
accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@docs/chat/agentic-cycle.md`:
- Around line 163-164: Combine the two separate imports from the same package
into a single import statement: replace the separate imports of chat and
maxIterations from "`@tanstack/ai`" with one import that includes both symbols
(e.g., import { chat, maxIterations } from "`@tanstack/ai`") so update the import
lines that reference chat and maxIterations accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 812614e8-9b76-4dca-9487-86c9daa8e731

📥 Commits

Reviewing files that changed from the base of the PR and between 472348a and dbcbeb1.

📒 Files selected for processing (24)
  • docs/adapters/anthropic.md
  • docs/advanced/multimodal-content.md
  • docs/advanced/runtime-adapter-switching.md
  • docs/advanced/tree-shaking.md
  • docs/advanced/typed-options.md
  • docs/chat/agentic-cycle.md
  • docs/chat/streaming.md
  • docs/chat/thinking-content.md
  • docs/comparison/vercel-ai-sdk.md
  • docs/getting-started/quick-start.md
  • docs/media/text-to-speech.md
  • docs/protocol/http-stream-protocol.md
  • docs/protocol/sse-protocol.md
  • docs/structured-outputs/multi-turn.md
  • docs/structured-outputs/one-shot.md
  • docs/structured-outputs/overview.md
  • docs/structured-outputs/streaming.md
  • docs/structured-outputs/with-tools.md
  • docs/tools/client-tools.md
  • docs/tools/provider-tools.md
  • docs/tools/server-tools.md
  • docs/tools/tool-approval.md
  • docs/tools/tool-architecture.md
  • docs/tools/tools.md
✅ Files skipped from review due to trivial changes (12)
  • docs/tools/provider-tools.md
  • docs/structured-outputs/overview.md
  • docs/structured-outputs/multi-turn.md
  • docs/structured-outputs/streaming.md
  • docs/tools/tool-approval.md
  • docs/chat/streaming.md
  • docs/structured-outputs/one-shot.md
  • docs/comparison/vercel-ai-sdk.md
  • docs/protocol/http-stream-protocol.md
  • docs/advanced/tree-shaking.md
  • docs/media/text-to-speech.md
  • docs/advanced/typed-options.md
🚧 Files skipped from review as they are similar to previous changes (6)
  • docs/tools/tools.md
  • docs/tools/server-tools.md
  • docs/getting-started/quick-start.md
  • docs/tools/tool-architecture.md
  • docs/protocol/sse-protocol.md
  • docs/chat/thinking-content.md

Audited all guide pages against the actual package APIs and fixed
copy-paste-broken / outdated samples and filled coverage gaps.

Middleware & structured outputs:
- New Built-in Middleware page (toolCache, contentGuard, otel) + new
  top-level Middleware nav section; document structured-output chunk
  transforms via onChunk + ctx.phase; fix middleware type import paths.
- Document client consumption (useChat partial/final) on the one-shot page.

Correctness fixes (verified against packages/ source):
- chat: providerOptions -> modelOptions; invalid model ids; budget_tokens
  requires maxTokens; async stream() factory -> fetcher; add missing
  imports; document default maxIterations(5) and agentLoopStrategy.
- tools: toServerSentEventsStream -> toServerSentEventsResponse; remove
  duplicate tools key; clarify tool-call vs tool-result states; fix the
  React examples and state diagram; add emitCustomEvent / runtime-context.
- media: add required model args to factory calls; fix recursive
  generateVideo; TranscriptionResult.words is top-level; speed is a
  top-level speech option; Gemini audio returns b64Json; onResult transform.
- advanced: adapter.model (not selectedModel); GeminiImageMetadata;
  source.mimeType; text.format structured-output shape; fill How It Works;
  createModel capabilities form; soften unsubstantiated bundle figures.
- protocol: rewrite SSE / HTTP-stream pages to the AG-UI event format
  (drop obsolete chunk shapes and [DONE]); use toHttpResponse/toHttpStream;
  expand chunk-definitions with TOOL_CALL_RESULT, MESSAGES_SNAPSHOT,
  REASONING_* and deprecated-alias notes.
- adapters: elevenlabs SFX model + @elevenlabs/client; ollama modelOptions
  placement; cencori AG-UI event/tools alignment.
- fix @tanstack/ai-openai/adapters -> @tanstack/ai-openai (ag-ui-compliance, otel).
A 7+1-agent confirmation review of the docs PR surfaced further
source-accuracy issues (and caught one regression the first fix pass
introduced). All verified against packages/ source:

- tools/server-tools: JSON-schema tool input is `unknown` (not `any`);
  samples now narrow/cast args.
- thinking-content: drop the adaptive-thinking / output_config.effort
  example — those option types are not wired into any model's typed
  modelOptions; document the `{ type: 'enabled', budget_tokens }` form.
- multimodal-content: correct the Anthropic modality bullets (no
  `claude-3*` ids; Claude Haiku 3 supports documents).
- comparison: fix the ImagePart (`source: { type:'url', url }`) and
  TextPart (`content`) shapes in the flagship example.
- chunk-definitions: RUN_STARTED/RUN_FINISHED `threadId` is required;
  add REASONING_MESSAGE_CHUNK to the internal-members note.
- media: createOpenaiVideo needs a model arg; video `seconds` is a
  string union; transcription `responseFormat`/`prompt` are top-level
  (not modelOptions); drop the non-existent gpt-4o-mini-audio-preview
  TTS model; add the Audio row to the generations table.
- advanced: typed-options gpt-image-1 size must be a GptImageSize.
- observability: aiEventClient imports from @tanstack/ai-event-client
  (the @tanstack/ai/event-client subpath does not exist).
- adapters: revert claude-haiku-3 -> claude-3-haiku (the id passed to
  anthropicText); clarify max_tokens auto-adjust; @elevenlabs/client
  (not @11labs/client); elevenlabs agentId optional, debug is DebugOption.
- structured-outputs: Standard JSON Schema /json-schema link; Zod v4.2+.

Model ids touched in these fixes use the latest per provider from
model-meta.ts (gpt-5.5, claude-sonnet-4-6, etc.).
Sweep example model ids across the PR's docs to the latest available
per provider, sourced from each adapter's model-meta.ts:
- OpenAI: gpt-5.2 -> gpt-5.5, gpt-5-mini -> gpt-5.4-mini
- Anthropic: claude-sonnet-4-5 -> claude-sonnet-4-6,
  claude-opus-4-6 -> claude-opus-4.8
- Gemini: gemini-2.0-flash -> gemini-3-flash-preview,
  image -> gemini-3.1-flash-image-preview, tts -> gemini-3.1-flash-tts-preview

Every replacement id was verified present in model-meta.ts. Intentional
cases preserved: negative/capability-contrast examples
(per-model-type-safety), the claude-3-haiku web_search note, model
enumeration/availability tables, DALL-E and o-series demos, and the
Cencori pass-through ids (external provider, no in-repo model-meta).
After rebasing onto main (which merged #660 moving temperature/topP/
maxTokens into modelOptions), fix the two spots where our edits still
assumed top-level sampling:
- thinking-content.md: max_tokens now lives in modelOptions alongside
  the thinking budget (was a top-level maxTokens).
- anthropic.md: drop the stale "auto-raises top-level maxTokens" note;
  budget_tokens must be below modelOptions.max_tokens.

(ollama.md and typed-options.md conflicts were resolved to main's new
convention during the rebase.)
@AlemTuzlak AlemTuzlak force-pushed the worktree-lazy-beaming-sloth branch from dbcbeb1 to 5017df7 Compare June 3, 2026 10:55
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2026

🚀 Changeset Version Preview

No changeset entries found. Merging this PR will not cause a version bump for any packages.

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Jun 3, 2026

View your CI Pipeline Execution ↗ for commit f74d5eb

Command Status Duration Result
nx run-many --targets=build --exclude=examples/... ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-06-03 12:09:26 UTC

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 3, 2026

Open in StackBlitz

@tanstack/ai

npm i https://pkg.pr.new/@tanstack/ai@691

@tanstack/ai-anthropic

npm i https://pkg.pr.new/@tanstack/ai-anthropic@691

@tanstack/ai-client

npm i https://pkg.pr.new/@tanstack/ai-client@691

@tanstack/ai-code-mode

npm i https://pkg.pr.new/@tanstack/ai-code-mode@691

@tanstack/ai-code-mode-skills

npm i https://pkg.pr.new/@tanstack/ai-code-mode-skills@691

@tanstack/ai-devtools-core

npm i https://pkg.pr.new/@tanstack/ai-devtools-core@691

@tanstack/ai-elevenlabs

npm i https://pkg.pr.new/@tanstack/ai-elevenlabs@691

@tanstack/ai-event-client

npm i https://pkg.pr.new/@tanstack/ai-event-client@691

@tanstack/ai-fal

npm i https://pkg.pr.new/@tanstack/ai-fal@691

@tanstack/ai-gemini

npm i https://pkg.pr.new/@tanstack/ai-gemini@691

@tanstack/ai-grok

npm i https://pkg.pr.new/@tanstack/ai-grok@691

@tanstack/ai-groq

npm i https://pkg.pr.new/@tanstack/ai-groq@691

@tanstack/ai-isolate-cloudflare

npm i https://pkg.pr.new/@tanstack/ai-isolate-cloudflare@691

@tanstack/ai-isolate-node

npm i https://pkg.pr.new/@tanstack/ai-isolate-node@691

@tanstack/ai-isolate-quickjs

npm i https://pkg.pr.new/@tanstack/ai-isolate-quickjs@691

@tanstack/ai-ollama

npm i https://pkg.pr.new/@tanstack/ai-ollama@691

@tanstack/ai-openai

npm i https://pkg.pr.new/@tanstack/ai-openai@691

@tanstack/ai-openrouter

npm i https://pkg.pr.new/@tanstack/ai-openrouter@691

@tanstack/ai-preact

npm i https://pkg.pr.new/@tanstack/ai-preact@691

@tanstack/ai-react

npm i https://pkg.pr.new/@tanstack/ai-react@691

@tanstack/ai-react-ui

npm i https://pkg.pr.new/@tanstack/ai-react-ui@691

@tanstack/ai-solid

npm i https://pkg.pr.new/@tanstack/ai-solid@691

@tanstack/ai-solid-ui

npm i https://pkg.pr.new/@tanstack/ai-solid-ui@691

@tanstack/ai-svelte

npm i https://pkg.pr.new/@tanstack/ai-svelte@691

@tanstack/ai-utils

npm i https://pkg.pr.new/@tanstack/ai-utils@691

@tanstack/ai-vue

npm i https://pkg.pr.new/@tanstack/ai-vue@691

@tanstack/ai-vue-ui

npm i https://pkg.pr.new/@tanstack/ai-vue-ui@691

@tanstack/openai-base

npm i https://pkg.pr.new/@tanstack/openai-base@691

@tanstack/preact-ai-devtools

npm i https://pkg.pr.new/@tanstack/preact-ai-devtools@691

@tanstack/react-ai-devtools

npm i https://pkg.pr.new/@tanstack/react-ai-devtools@691

@tanstack/solid-ai-devtools

npm i https://pkg.pr.new/@tanstack/solid-ai-devtools@691

commit: c07bea1

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/advanced/middleware.md (1)

701-733: ⚠️ Potential issue | 🟠 Major

Fix the documented middleware type import paths in docs/advanced/middleware.md (701-733)

  • The text claims built-in middleware option/type exports come from @tanstack/ai/middlewares “not the main barrel”, but ToolCacheMiddlewareOptions is documented as importable from @tanstack/ai directly—so the “not the main barrel” statement is likely wrong and will mislead users.
  • Update this section to match the actual exported TypeScript paths for ToolCacheMiddlewareOptions, ContentGuardMiddlewareOptions, and ContentFilteredInfo (or adjust the wording to reflect the correct barrel/subpath exports).
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/advanced/middleware.md` around lines 701 - 733, The docs incorrectly
state that built-in middleware types are exported from the subpath
"`@tanstack/ai/middlewares`"; update the text to reflect the actual export surface
for the types (e.g., ToolCacheMiddlewareOptions, ToolCacheStorage,
ToolCacheEntry, ContentGuardMiddlewareOptions, ContentGuardRule,
ContentFilteredInfo) by either changing the import example to use the main
barrel "`@tanstack/ai`" if those symbols are exported there or by adjusting the
wording to accurately say which specific types come from the subpath and which
come from the main barrel; ensure the examples and sentence about "not the main
barrel" consistently match the real TypeScript export locations for those
symbols.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@docs/advanced/middleware.md`:
- Around line 701-733: The docs incorrectly state that built-in middleware types
are exported from the subpath "`@tanstack/ai/middlewares`"; update the text to
reflect the actual export surface for the types (e.g.,
ToolCacheMiddlewareOptions, ToolCacheStorage, ToolCacheEntry,
ContentGuardMiddlewareOptions, ContentGuardRule, ContentFilteredInfo) by either
changing the import example to use the main barrel "`@tanstack/ai`" if those
symbols are exported there or by adjusting the wording to accurately say which
specific types come from the subpath and which come from the main barrel; ensure
the examples and sentence about "not the main barrel" consistently match the
real TypeScript export locations for those symbols.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8b9a44cd-7a0b-4538-97d1-c0f471947597

📥 Commits

Reviewing files that changed from the base of the PR and between dbcbeb1 and 5017df7.

📒 Files selected for processing (41)
  • docs/adapters/anthropic.md
  • docs/adapters/elevenlabs.md
  • docs/advanced/built-in-middleware.md
  • docs/advanced/extend-adapter.md
  • docs/advanced/middleware.md
  • docs/advanced/multimodal-content.md
  • docs/advanced/observability.md
  • docs/advanced/otel.md
  • docs/advanced/per-model-type-safety.md
  • docs/advanced/runtime-adapter-switching.md
  • docs/advanced/tree-shaking.md
  • docs/advanced/typed-options.md
  • docs/chat/agentic-cycle.md
  • docs/chat/streaming.md
  • docs/chat/thinking-content.md
  • docs/community-adapters/cencori.md
  • docs/comparison/vercel-ai-sdk.md
  • docs/config.json
  • docs/getting-started/quick-start.md
  • docs/media/audio-generation.md
  • docs/media/generation-hooks.md
  • docs/media/generations.md
  • docs/media/image-generation.md
  • docs/media/text-to-speech.md
  • docs/media/transcription.md
  • docs/media/video-generation.md
  • docs/migration/ag-ui-compliance.md
  • docs/protocol/chunk-definitions.md
  • docs/protocol/http-stream-protocol.md
  • docs/protocol/sse-protocol.md
  • docs/structured-outputs/multi-turn.md
  • docs/structured-outputs/one-shot.md
  • docs/structured-outputs/overview.md
  • docs/structured-outputs/streaming.md
  • docs/structured-outputs/with-tools.md
  • docs/tools/client-tools.md
  • docs/tools/provider-tools.md
  • docs/tools/server-tools.md
  • docs/tools/tool-approval.md
  • docs/tools/tool-architecture.md
  • docs/tools/tools.md
✅ Files skipped from review due to trivial changes (27)
  • docs/structured-outputs/with-tools.md
  • docs/structured-outputs/streaming.md
  • docs/structured-outputs/multi-turn.md
  • docs/media/generation-hooks.md
  • docs/tools/provider-tools.md
  • docs/media/audio-generation.md
  • docs/advanced/otel.md
  • docs/advanced/per-model-type-safety.md
  • docs/structured-outputs/overview.md
  • docs/chat/agentic-cycle.md
  • docs/community-adapters/cencori.md
  • docs/advanced/extend-adapter.md
  • docs/advanced/tree-shaking.md
  • docs/migration/ag-ui-compliance.md
  • docs/tools/tools.md
  • docs/media/video-generation.md
  • docs/comparison/vercel-ai-sdk.md
  • docs/advanced/observability.md
  • docs/tools/server-tools.md
  • docs/structured-outputs/one-shot.md
  • docs/tools/tool-architecture.md
  • docs/advanced/typed-options.md
  • docs/chat/streaming.md
  • docs/media/text-to-speech.md
  • docs/advanced/built-in-middleware.md
  • docs/protocol/http-stream-protocol.md
  • docs/media/transcription.md

The "safe allowlist" example still forwarded temperature/maxTokens as
top-level chat() options (missed by #660's sampling-into-modelOptions
migration). Map them into modelOptions under OpenAI's native keys
(temperature / max_output_tokens) so the example type-checks.
- Remove the deprecated Observability page (event-client observability is
  superseded; otelMiddleware is the supported path) and its nav entry +
  inbound links.
- Remove the protocol pages (chunk-definitions, sse-protocol,
  http-stream-protocol) — TanStack AI implements AG-UI, whose protocol is
  documented upstream; repoint the few inbound links to docs.ag-ui.com.
- Fix the broken ToolCacheStorage snippet (it imported the type then
  re-declared it) and verify the shape against source.
- Remove every `as <Type>` assertion cast from the docs (JSON-schema tool
  inputs, JSON.parse, formData, custom-event values, type brands, …),
  replacing them with typeof/in guards, type guards, typed annotations, or
  schema validation. `createModel`'s provider-option brand now uses a typed
  const instead of `{} as X`.
- CLAUDE.md / AGENTS.md: codify the docs conventions — no `as` casts in
  samples, use the latest model per provider from model-meta.ts, and show
  both server and client sides when a doc spans both.
…t transform

- built-in-middleware.md: gpt-4o -> gpt-5.5 in the examples.
- middleware.md: make the "Transforming structured-output chunks" example
  self-contained — redact SSNs inline in the streaming JSON delta instead of
  calling an undefined `redact()` helper.

(The docs conventions — no casts, latest models, show both sides — already
live in the project CLAUDE.md / AGENTS.md; the earlier global-CLAUDE.md
addition has been reverted.)
@AlemTuzlak AlemTuzlak merged commit b906666 into main Jun 3, 2026
10 checks passed
@AlemTuzlak AlemTuzlak deleted the worktree-lazy-beaming-sloth branch June 3, 2026 12:15
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