Skip to content
Source
Sign inSign up
TanStack/ai

feat(ai): structured-output middleware coverage (closes #390) #600

MergedAlemTuzlakmerged 20 commits intomain fromrefs/pull/600/headmerged by AlemTuzlak View on GitHub

AlemTuzlakcommented

Summary

  • Routes the final structured-output adapter call in chat({ outputSchema }) (both Promise<T> and streaming variants) through the same middleware pipeline as the agent loop. Closes #390.
  • New public surface: 'structuredOutput' value on ChatMiddlewarePhase, optional onStructuredOutputConfig hook on ChatMiddleware, new exported StructuredOutputMiddlewareConfig type.
  • Standard Schema validation moved into the engine's finalization step (Promise path); validation failures now route through onError instead of throwing post-engine. Streaming path intentionally defers validation to the consumer (documented).
  • Internal cleanup: the RUN_STARTED/RUN_FINISHED suppression hack in runStreamingStructuredOutput is relocated into the engine (streamModelResponse) and gated on finalStructuredOutput.yieldChunks; consumer still sees exactly one outer pair.

Behavior change for existing middleware

  • onChunk now observes chunks from the final structured-output call (attributed to ctx.phase === 'structuredOutput'). Phase-aware middleware can branch on ctx.phase to opt out: if (ctx.phase === 'structuredOutput') return.
  • onFinish fires once at the end of the whole chat() invocation, after finalization (not after the agent loop). info.usage / info.finishReason / info.content reflect the agent-loop's terminal state only — use onUsage to capture finalization tokens.

Files

  • New public surface + engine wiring in packages/typescript/ai/src/activities/chat/**.
  • 11 unit tests in packages/typescript/ai/tests/structured-output-middleware.test.ts (Promise + streaming paths, hook transforms, schema-validation routing, fallback, backward-compat).
  • 2 E2E specs + harness extensions (phase-recorder mode + structured-output(-stream) scenarios) in testing/e2e/.
  • Agent skills and public docs updated (packages/typescript/ai/skills/ai-core/middleware/SKILL.md, packages/typescript/ai/skills/ai-core/structured-outputs/SKILL.md, docs/structured-outputs/overview.md, docs/advanced/middleware.md).

Test plan

  • pnpm --filter @tanstack/ai test:lib — 857 unit tests pass (39 files)
  • pnpm --filter @tanstack/ai test:types — clean
  • pnpm --filter @tanstack/ai test:eslint — clean
  • pnpm --filter @tanstack/ai-e2e test:e2e — 181 tests pass (incl. 2 new structured-output × middleware specs)
  • pnpm test:docs — 297 markdown files, no broken links
  • pnpm test:build — 29 Nx projects clean

Review history

10 commits on this branch. The cr-loop ran 6 rounds + Procedure 3 bucket-(c) audit; load-bearing findings folded back into the diff:

  • Round 1: 14 items (types, error preservation, abort handling, doc claims)
  • Round 2: 3 items (mid-finalization abort routing, finalization-state pollution, synth start-before-error)
  • Round 3: 1 item (info.usage doc claim alignment)
  • Round 4: 1 item (tools field documented as transformable but not forwarded)
  • Round 5: 1 item (runStreamingStructuredOutput JSDoc validation claim)
  • Round 6: 1 item (docs/structured-outputs/overview.md server-side-validation claim)
  • Procedure 3: 1 PROMOTE_TO_A (schema-conversion asymmetry between Promise and streaming) + 3 PROMOTE_TO_B (fallback mock- prefix, RUN_ERROR threadId, JSDoc typo)

Summary by CodeRabbit

  • New Features

    • Added middleware support for structured output with a new structuredOutput phase and onStructuredOutputConfig hook for customizing output schemas.
    • Middleware now observes the entire structured-output finalization process, including chunks and token usage.
  • Bug Fixes

    • Fixed middleware lifecycle timing—onFinish now fires once after all operations complete.
  • Documentation

    • Updated middleware guides with structured-output lifecycle details and examples.

Review Change Stack

    1. 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 integrates the final structured-output provider call into the middleware pipeline. It introduces a new 'structuredOutput' middleware phase, a dedicated onStructuredOutputConfig hook for transforming the output schema before the provider call, routes structured-output finalization through TextEngine, refactors public APIs to use engine-driven finalization, adds comprehensive test and E2E coverage, and updates documentation.

      Changes

      Structured-output middleware integration

      Layer / File(s)Summary
      Type contracts and exports
      packages/typescript/ai/src/activities/chat/middleware/types.ts, packages/typescript/ai/src/activities/chat/middleware/index.ts, packages/typescript/ai/src/index.ts
      New StructuredOutputMiddlewareConfig type extending ChatMiddlewareConfig with outputSchema: JSONSchema, extended ChatMiddlewarePhase to include 'structuredOutput', new optional onStructuredOutputConfig hook on ChatMiddleware, and public re-exports updated.
      MiddlewareRunner structured-output config pipeline
      packages/typescript/ai/src/activities/chat/middleware/compose.ts
      MiddlewareRunner.runOnStructuredOutputConfig() sequentially invokes each middleware's onStructuredOutputConfig hook, shallow-merges partial config returns, and emits instrumentation events.
      TextEngine finalization and lifecycle
      packages/typescript/ai/src/activities/chat/index.ts (lines 38, 58, 298–320, 379–404, 512–538, 563–652, 811–824, 1592–1950)
      Add finalStructuredOutput config/state to TextEngine, implement runStructuredFinalization() to run adapter structured-output stream through middleware, synthesize missing structured-output.start events, route terminal hooks by finalization error, and suppress agent-loop lifecycle events when yieldChunks is enabled.
      Refactored structured-output public APIs
      packages/typescript/ai/src/activities/chat/index.ts (lines 2078, 2227–2245, 2255–2348, 2364–2369, 2420–2434, 2495–2519), packages/typescript/ai/src/activities/chat/tools/schema-converter.ts (lines 342–360, 369–370, 391)
      runAgenticStructuredOutput uses engine finalization with optional Standard Schema validate callback; runStreamingStructuredOutput simplified to drive entire flow through engine with yieldChunks: true; new StandardSchemaValidationError class captures Standard Schema validation issues; fallback error handling improved.
      Unit tests for structured-output middleware
      packages/typescript/ai/tests/structured-output-middleware.test.ts, packages/typescript/ai/tests/chat-structured-output-stream.test.ts, packages/typescript/ai/tests/test-utils.ts
      New Vitest module covering promise/streaming modes, onStructuredOutputConfig transforms, terminal hook routing, failure paths, validation, and backward compatibility; existing streaming tests updated to reflect consumer-side validation responsibility; mock adapter enhanced with structuredOutputStream option.
      E2E phase-capture infrastructure and test harness
      testing/e2e/src/lib/phase-capture.ts, testing/e2e/src/routes/api.middleware-test.ts, testing/e2e/src/routes/middleware-test.tsx, testing/e2e/tests/structured-output-middleware.spec.ts, testing/e2e/fixtures/middleware-test/structured-output.json
      In-memory phase-capture bucket utilities, phase-recorder middleware mode in API route with stream teeing, client-side phase-capture parsing, E2E Playwright spec validating middleware phase observations and consumer lifecycle events, test fixtures for structured-output scenarios.
      Example app phase-counting diagnostics
      examples/ts-react-chat/src/routes/api.structured-output.ts, examples/ts-react-chat/src/routes/generations.structured-output.tsx
      Phase-counting middleware and per-phase tracking in example routes, conditional UI panel rendering phase counts with model info.
      Type docs, middleware docs, and SKILL guides
      docs/, packages/typescript/ai/skills/ai-core/
      New StructuredOutputMiddlewareConfig reference page, updated ChatMiddleware and ChatMiddlewarePhase docs, onStructuredOutputConfig hook and phase semantics documented in advanced middleware guide, ai-core/middleware and ai-core/structured-outputs SKILL.md updated with middleware coverage patterns, numerous "Defined in" reference links updated.

      Estimated code review effort

      🎯 4 (Complex) | ⏱️ ~75 minutes

      • #390: The primary motivation—middleware now wraps the final structured-output provider call via the new structuredOutput phase and onStructuredOutputConfig hook, addressing the missing middleware coverage for structured-output finalization.
      • #570: Changes to structuredOutputStream fallback handling and new structured-output lifecycle event routing in packages/typescript/ai/src/activities/chat/index.ts may affect native adapter implementations.
      • #605: Both PRs introduce the structuredOutput phase and StructuredOutputMiddlewareConfig surface.
      • TanStack/ai#577: Both PRs modify structured-output event lifecycle (structured-output.start/structured-output.complete), messageId handling, and chunk routing; this PR adds middleware phase/hook semantics on top of those event flows.

      Suggested reviewers

      • tombeckenham
      • crutchcorn

      Poem

      🐰 Middleware pipelines now flow so fine, Structured output at the finish line! With phases and hooks in perfect dance, The config transforms take their chance. ✨

      🚥 Pre-merge checks | ✅ 4 | ❌ 1

      ❌ Failed checks (1 warning)

      Check nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring coverage is 52.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
      ✅ Passed checks (4 passed)
      Check nameStatusExplanation
      Title check✅ PassedThe PR title 'feat(ai): structured-output middleware coverage' clearly and specifically summarizes the main change: integrating middleware coverage for structured-output operations, which directly addresses issue #390.
      Description check✅ PassedThe PR description is comprehensive and complete, covering the summary, behavior changes, public API surface additions, files changed, test plan with passing results, and thorough review history documentation.
      Linked Issues check✅ PassedThe PR fully addresses all coding objectives from issue #390: the final structured-output call is routed through middleware pipeline, a dedicated 'structuredOutput' phase and 'onStructuredOutputConfig' hook are provided, behavior is consistent across adapters, and limitations are documented.
      Out of Scope Changes check✅ PassedAll changes are directly scoped to implementing structured-output middleware coverage: engine refactoring, middleware type additions, documentation, tests, and example updates are all aligned with issue #390 objectives.
      ✏️ Tip: You can configure your own custom pre-merge checks in the settings.
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests
      • Commit unit tests in branch `worktree-silly-nibbling-bumblebee`

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands and usage tips.
    2. Actionable comments posted: 1

      🧹 Nitpick comments (1)
      testing/e2e/tests/structured-output-middleware.spec.ts (1)

      82-83: ⚡ Quick win

      Replace fixed 2s sleeps with explicit readiness waits.

      Lines 82 and 113 use page.waitForTimeout(2000) which can cause flaky or unnecessarily slow E2E runs. Use Playwright's explicit wait mechanisms instead (e.g., waitForSelector(), waitForLoadState(), or waitForFunction()) to wait for deterministic UI/server-ready signals.

      🤖 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 `@testing/e2e/tests/structured-output-middleware.spec.ts` around lines 82 - 83,
      The test uses brittle fixed sleeps via page.waitForTimeout(2000); replace those
      calls with deterministic Playwright waits: identify the UI/state the test
      expects (e.g., a rendered element or network idle) and swap
      page.waitForTimeout(2000) with an explicit wait such as
      page.waitForSelector('<selector>') or page.waitForLoadState('networkidle') or
      page.waitForFunction(() => /* readiness predicate */) in the tests inside
      structured-output-middleware.spec.ts so the code paths around the existing
      page.waitForTimeout invocations wait for a concrete selector or readiness
      condition instead of a fixed 2s sleep.
      🤖 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 `@packages/typescript/ai/src/activities/chat/index.ts`:
      - Around line 600-606: The current finalization condition allows structured
      finalization to run even after the agent-loop set earlyTermination for
      RUN_ERROR; update the guard where finalStructuredOutput is checked (the block
      that calls this.runStructuredFinalization()) to also check that earlyTermination
      is false (e.g., include !this.earlyTermination) so structured finalization is
      skipped when the loop ended with RUN_ERROR; apply the same additional check to
      the other occurrence referenced (the block around lines 909-913) so no
      structured-output provider call runs after an earlyTermination.
      
      ---
      
      Nitpick comments:
      In `@testing/e2e/tests/structured-output-middleware.spec.ts`:
      - Around line 82-83: The test uses brittle fixed sleeps via
      page.waitForTimeout(2000); replace those calls with deterministic Playwright
      waits: identify the UI/state the test expects (e.g., a rendered element or
      network idle) and swap page.waitForTimeout(2000) with an explicit wait such as
      page.waitForSelector('<selector>') or page.waitForLoadState('networkidle') or
      page.waitForFunction(() => /* readiness predicate */) in the tests inside
      structured-output-middleware.spec.ts so the code paths around the existing
      page.waitForTimeout invocations wait for a concrete selector or readiness
      condition instead of a fixed 2s sleep.
      🪄 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: 762a55c1-2fc0-416c-9b10-4ea662967eef

      📥 Commits

      Reviewing files that changed from the base of the PR and between 1e4df183553a34ea6a4e9010b692314b48e66e67 and c988bbb941dfca276b908943f8a7521a49b489e5.

      📒 Files selected for processing (35)
      • .changeset/structured-output-middleware-coverage.md
      • docs/advanced/middleware.md
      • docs/reference/functions/chat.md
      • docs/reference/functions/createChatOptions.md
      • docs/reference/index.md
      • docs/reference/interfaces/AbortInfo.md
      • docs/reference/interfaces/AfterToolCallInfo.md
      • docs/reference/interfaces/ChatMiddleware.md
      • docs/reference/interfaces/ChatMiddlewareConfig.md
      • docs/reference/interfaces/ChatMiddlewareContext.md
      • docs/reference/interfaces/ErrorInfo.md
      • docs/reference/interfaces/FinishInfo.md
      • docs/reference/interfaces/IterationInfo.md
      • docs/reference/interfaces/StructuredOutputMiddlewareConfig.md
      • docs/reference/interfaces/ToolCallHookContext.md
      • docs/reference/interfaces/ToolPhaseCompleteInfo.md
      • docs/reference/interfaces/UsageInfo.md
      • docs/reference/type-aliases/BeforeToolCallDecision.md
      • docs/reference/type-aliases/ChatMiddlewarePhase.md
      • docs/structured-outputs/overview.md
      • packages/typescript/ai/skills/ai-core/middleware/SKILL.md
      • packages/typescript/ai/skills/ai-core/structured-outputs/SKILL.md
      • packages/typescript/ai/src/activities/chat/index.ts
      • packages/typescript/ai/src/activities/chat/middleware/compose.ts
      • packages/typescript/ai/src/activities/chat/middleware/index.ts
      • packages/typescript/ai/src/activities/chat/middleware/types.ts
      • packages/typescript/ai/src/index.ts
      • packages/typescript/ai/tests/chat-structured-output-stream.test.ts
      • packages/typescript/ai/tests/structured-output-middleware.test.ts
      • packages/typescript/ai/tests/test-utils.ts
      • testing/e2e/fixtures/middleware-test/structured-output.json
      • testing/e2e/src/lib/phase-capture.ts
      • testing/e2e/src/routes/api.middleware-test.ts
      • testing/e2e/src/routes/middleware-test.tsx
      • testing/e2e/tests/structured-output-middleware.spec.ts
      packages/typescript/ai/src/activities/chat/index.ts lines 610 to 616
      @@ -523,7 +593,14 @@
      523- this.terminalHookCalled = true
      524- await this.middlewareRunner.runOnFinish(this.middlewareCtx, {
      525- finishReason: this.lastFinishReason,
      526- duration: Date.now() - this.streamStartTime,
      527- content: this.accumulatedContent,
      528- usage: this.finishedEvent?.usage,
      529- })
      593+ // ============================================================
      594+ // Structured-output finalization (new — closes issue #390)
      595+ // ============================================================
      596+ // After the agent loop ends, if a structured-output finalization was
      597+ // requested AND the run hasn't already errored/aborted, run it through
      598+ // the middleware pipeline. The terminal hook fires once at the very
      599+ // end (after finalization), not after the agent loop.
      600+ if (
      601+ this.finalStructuredOutput &&
      602+ !this.isCancelled() &&
      603+ !this.finalizationError
      604+ ) {
      605+ yield* this.runStructuredFinalization()
      606+ }

      ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

      Skip structured-output finalization after agent-loop RUN_ERROR.

      Line 909 sets earlyTermination = true on RUN_ERROR, but Line 600 still allows finalization to run. That can issue an extra structured-output provider call after a failed loop and can mis-route terminal behavior.

      💡 Proposed fix
             if (
               this.finalStructuredOutput &&
      +        !this.earlyTermination &&
               !this.isCancelled() &&
               !this.finalizationError
             ) {
               yield* this.runStructuredFinalization()
             }

      Also applies to: 909-913

      🤖 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 `@packages/typescript/ai/src/activities/chat/index.ts` around lines 600 - 606,
      The current finalization condition allows structured finalization to run even
      after the agent-loop set earlyTermination for RUN_ERROR; update the guard where
      finalStructuredOutput is checked (the block that calls
      this.runStructuredFinalization()) to also check that earlyTermination is false
      (e.g., include !this.earlyTermination) so structured finalization is skipped
      when the loop ended with RUN_ERROR; apply the same additional check to the other
      occurrence referenced (the block around lines 909-913) so no structured-output
      provider call runs after an earlyTermination.
    3. 🚀 Changeset Version Preview

      10 package(s) bumped directly, 20 bumped as dependents.

      🟥 Major bumps

      PackageVersionReason
      @tanstack/ai-code-mode0.1.16 → 1.0.0Changeset
      @tanstack/ai-code-mode-skills0.1.16 → 1.0.0Changeset
      @tanstack/ai-elevenlabs0.2.8 → 1.0.0Changeset
      @tanstack/ai-fal0.7.9 → 1.0.0Changeset
      @tanstack/ai-gemini0.10.8 → 1.0.0Changeset
      @tanstack/ai-grok0.8.5 → 1.0.0Changeset
      @tanstack/ai-openai0.9.5 → 1.0.0Changeset
      @tanstack/ai-openrouter0.9.5 → 1.0.0Changeset
      @tanstack/ai-react-ui0.7.2 → 1.0.0Changeset
      @tanstack/ai-anthropic0.10.1 → 1.0.0Dependent
      @tanstack/ai-event-client0.3.6 → 1.0.0Dependent
      @tanstack/ai-groq0.2.4 → 1.0.0Dependent
      @tanstack/ai-isolate-node0.1.16 → 1.0.0Dependent
      @tanstack/ai-isolate-quickjs0.1.16 → 1.0.0Dependent
      @tanstack/ai-ollama0.6.19 → 1.0.0Dependent
      @tanstack/ai-preact0.6.28 → 1.0.0Dependent
      @tanstack/ai-react0.11.3 → 1.0.0Dependent
      @tanstack/ai-solid0.10.3 → 1.0.0Dependent
      @tanstack/ai-solid-ui0.6.7 → 1.0.0Dependent
      @tanstack/ai-svelte0.10.3 → 1.0.0Dependent
      @tanstack/ai-vue0.10.4 → 1.0.0Dependent
      @tanstack/openai-base0.3.4 → 1.0.0Dependent

      🟨 Minor bumps

      PackageVersionReason
      @tanstack/ai0.20.1 → 0.21.0Changeset

      🟩 Patch bumps

      PackageVersionReason
      @tanstack/ai-client0.11.3 → 0.11.4Dependent
      @tanstack/ai-devtools-core0.3.33 → 0.3.34Dependent
      @tanstack/ai-isolate-cloudflare0.2.7 → 0.2.8Dependent
      @tanstack/ai-vue-ui0.1.40 → 0.1.41Dependent
      @tanstack/preact-ai-devtools0.1.37 → 0.1.38Dependent
      @tanstack/react-ai-devtools0.2.37 → 0.2.38Dependent
      @tanstack/solid-ai-devtools0.2.37 → 0.2.38Dependent
    4. View your CI Pipeline Execution ↗ for commit 010c810cf4102b2743727fadeba158800f8770f8

      CommandStatusDurationResult
      nx run-many --targets=build --exclude=examples/...✅ Succeeded1m 5sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-05-21 04:58:27 UTC

    5. Open in StackBlitz

      @tanstack/ai

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

      @tanstack/ai-anthropic

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

      @tanstack/ai-client

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

      @tanstack/ai-code-mode

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

      @tanstack/ai-code-mode-skills

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

      @tanstack/ai-devtools-core

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

      @tanstack/ai-elevenlabs

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

      @tanstack/ai-event-client

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

      @tanstack/ai-fal

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

      @tanstack/ai-gemini

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

      @tanstack/ai-grok

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

      @tanstack/ai-groq

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

      @tanstack/ai-isolate-cloudflare

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

      @tanstack/ai-isolate-node

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

      @tanstack/ai-isolate-quickjs

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

      @tanstack/ai-ollama

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

      @tanstack/ai-openai

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

      @tanstack/ai-openrouter

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

      @tanstack/ai-preact

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

      @tanstack/ai-react

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

      @tanstack/ai-react-ui

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

      @tanstack/ai-solid

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

      @tanstack/ai-solid-ui

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

      @tanstack/ai-svelte

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

      @tanstack/ai-utils

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

      @tanstack/ai-vue

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

      @tanstack/ai-vue-ui

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

      @tanstack/openai-base

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

      @tanstack/preact-ai-devtools

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

      @tanstack/react-ai-devtools

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

      @tanstack/solid-ai-devtools

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

      commit: 27ae70f

    6. 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/reference/interfaces/ChatMiddleware.md`:
      - Around line 179-183: Update the prose for the Chat middleware config hooks
      (specifically the onConfig and onStructuredOutputConfig descriptions) to
      explicitly document that returning null indicates a pass-through/no-op (i.e.,
      leave the current config unchanged and do not perform a merge), in contrast to
      returning void or a Partial<ChatMiddlewareConfig> which performs no change or a
      partial merge respectively; apply the same clarifying sentence to all other
      occurrences of these hook signatures (the other comment blocks referencing
      onConfig/onStructuredOutputConfig) so the null semantics are consistently
      documented.
      🪄 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: 92543861-2971-402b-81fc-cf03fb9d0254

      📥 Commits

      Reviewing files that changed from the base of the PR and between c988bbb941dfca276b908943f8a7521a49b489e5 and d6c1200f29718c3115d08087173b9411c3b47723.

      📒 Files selected for processing (14)
      • docs/reference/functions/chat.md
      • docs/reference/functions/createChatOptions.md
      • docs/reference/index.md
      • docs/reference/interfaces/AbortInfo.md
      • docs/reference/interfaces/AfterToolCallInfo.md
      • docs/reference/interfaces/ChatMiddleware.md
      • docs/reference/interfaces/ErrorInfo.md
      • docs/reference/interfaces/FinishInfo.md
      • docs/reference/interfaces/IterationInfo.md
      • docs/reference/interfaces/StructuredOutputMiddlewareConfig.md
      • docs/reference/interfaces/ToolCallHookContext.md
      • docs/reference/interfaces/ToolPhaseCompleteInfo.md
      • docs/reference/interfaces/UsageInfo.md
      • docs/reference/type-aliases/BeforeToolCallDecision.md
      ✅ Files skipped from review due to trivial changes (12)
      • docs/reference/functions/createChatOptions.md
      • docs/reference/interfaces/AfterToolCallInfo.md
      • docs/reference/interfaces/ToolCallHookContext.md
      • docs/reference/type-aliases/BeforeToolCallDecision.md
      • docs/reference/interfaces/ErrorInfo.md
      • docs/reference/interfaces/AbortInfo.md
      • docs/reference/index.md
      • docs/reference/interfaces/StructuredOutputMiddlewareConfig.md
      • docs/reference/interfaces/FinishInfo.md
      • docs/reference/interfaces/UsageInfo.md
      • docs/reference/interfaces/IterationInfo.md
      • docs/reference/interfaces/ToolPhaseCompleteInfo.md
      docs/reference/interfaces/ChatMiddleware.md lines 179 to 183
      @@ -176,5 +176,8 @@
      176176 optional onConfig: (ctx, config) =>
      177177 | void
      178178 | Partial<ChatMiddlewareConfig>
      179- | Promise<void | Partial<ChatMiddlewareConfig>>
      179+ | Promise<
      180+ | void
      181+ | Partial<ChatMiddlewareConfig>
      182+ | null>
      180183 | null;

      ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

      Document null semantics for config hooks explicitly.

      Both onConfig and onStructuredOutputConfig now allow returning null, but the prose only explains void and partial merges. Please add one sentence clarifying what null does (e.g., pass-through/no-op) to avoid middleware ambiguity.

      Also applies to: 191-193, 327-329, 338-340, 364-366

      🤖 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/reference/interfaces/ChatMiddleware.md` around lines 179 - 183, Update
      the prose for the Chat middleware config hooks (specifically the onConfig and
      onStructuredOutputConfig descriptions) to explicitly document that returning
      null indicates a pass-through/no-op (i.e., leave the current config unchanged
      and do not perform a merge), in contrast to returning void or a
      Partial<ChatMiddlewareConfig> which performs no change or a partial merge
      respectively; apply the same clarifying sentence to all other occurrences of
      these hook signatures (the other comment blocks referencing
      onConfig/onStructuredOutputConfig) so the null semantics are consistently
      documented.
    7. AlemTuzlak merged this188fe11

    8. AlemTuzlak closed this

Sign in to join this conversation.