Skip to content
Source
Sign inSign up
TanStack/ai

feat(interrupts): AG-UI interrupt lifecycle overhaul (ephemeral) #970

MergedAlemTuzlakmerged 94 commits intomain fromrefs/pull/970/headmerged by AlemTuzlak View on GitHub

AlemTuzlakcommented

Extracts the AG-UI interrupts overhaul (from #935, which was stacked on the persistence PR #785) into its own PR targeting main, excluding the persistence story. Interrupts run fully ephemeral here: resume reconstructs pending tool calls from the client's message history in a fresh child run. A follow-up stacked PR will add durable persistence back on top.

What's in scope

  • AG-UI interrupt lifecycle: RUN_FINISHED with outcome.type === 'interrupt', interrupt descriptors/bindings, ephemeral resume via parentRunId + resume batch.
  • Tool-approval and client-tool interrupt kinds.
  • Client-side interruptManager (hydrate / resolve / batch submit), useChat integration across frameworks.
  • ts-react-chat interrupt-lab example for manual testing.

Explicitly out of scope (deferred to the stacked persistence PR)

  • @tanstack/ai-persistence, -drizzle, -prisma, -cloudflare.
  • Durable interrupts (recovery via joinRun, server-side interrupt state fetchers).

Notable fixes

  • Forward parentRunId so ephemeral resume correlates the interrupted run to its continuation child run.
  • Resolve the approval tool-call's owning message from history when a MESSAGES_SNAPSHOT reset the live maps, so the approval UI state still updates.
  • Removed durable (interrupts-v2) e2e routes/fixtures/specs and persistence-era recovery tests; these return with persistence.

Testing

  • tool-approval.spec.ts e2e green across all providers (approve continuation, denial, issue #532 follow-up).
  • Unit tests, typecheck, lint, build green for affected packages.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added AG-UI interrupt lifecycle with support for tool approvals, generic responses, and client-tool execution, including typed payloads/edited args, cancellation, retry, and atomic multi-interrupt resolution.
    • Introduced resumable interrupt state via resume/continuation handling, plus persistence with durable interrupt recovery (ephemeral enabled by default) and new storage-adapter options.
    • Expanded interrupt/resume state and controls across React, Preact, Vue, Solid, Svelte, and Angular integrations.
    • Added an “Interrupts Lab” example and new /interrupts UI flow.
  • Documentation

    • Reworked and expanded guides covering the interrupt protocol, migration, tool approvals, generic interrupts, and durable vs ephemeral behavior.
    1. github-actions[bot](GitHub profile, opens in a new tab)commented

      🚀 Changeset Version Preview

      9 package(s) bumped directly, 38 bumped as dependents.

      🟥 Major bumps

      PackageVersionReason
      @tanstack/ai-angular0.3.1 → 1.0.0Changeset
      @tanstack/ai-durable-stream0.0.0 → 1.0.0Changeset
      @tanstack/ai-preact0.11.1 → 1.0.0Changeset
      @tanstack/ai-react0.18.1 → 1.0.0Changeset
      @tanstack/ai-solid0.15.1 → 1.0.0Changeset
      @tanstack/ai-svelte0.15.1 → 1.0.0Changeset
      @tanstack/ai-vue0.15.1 → 1.0.0Changeset
      @tanstack/ai-acp0.2.3 → 1.0.0Dependent
      @tanstack/ai-anthropic0.16.3 → 1.0.0Dependent
      @tanstack/ai-bedrock0.1.4 → 1.0.0Dependent
      @tanstack/ai-claude-code0.2.3 → 1.0.0Dependent
      @tanstack/ai-code-mode0.3.8 → 1.0.0Dependent
      @tanstack/ai-code-mode-skills0.3.11 → 1.0.0Dependent
      @tanstack/ai-codex0.2.3 → 1.0.0Dependent
      @tanstack/ai-elevenlabs0.2.34 → 1.0.0Dependent
      @tanstack/ai-fal0.9.12 → 1.0.0Dependent
      @tanstack/ai-gemini0.20.1 → 1.0.0Dependent
      @tanstack/ai-grok0.14.9 → 1.0.0Dependent
      @tanstack/ai-grok-build0.2.3 → 1.0.0Dependent
      @tanstack/ai-groq0.5.3 → 1.0.0Dependent
      @tanstack/ai-isolate-node0.1.47 → 1.0.0Dependent
      @tanstack/ai-isolate-quickjs0.1.47 → 1.0.0Dependent
      @tanstack/ai-mistral0.2.3 → 1.0.0Dependent
      @tanstack/ai-ollama0.8.16 → 1.0.0Dependent
      @tanstack/ai-openai0.17.1 → 1.0.0Dependent
      @tanstack/ai-opencode0.2.3 → 1.0.0Dependent
      @tanstack/ai-openrouter0.15.10 → 1.0.0Dependent
      @tanstack/ai-react-ui0.8.15 → 1.0.0Dependent
      @tanstack/ai-sandbox0.2.4 → 1.0.0Dependent
      @tanstack/ai-sandbox-cloudflare0.2.4 → 1.0.0Dependent
      @tanstack/ai-sandbox-daytona0.2.0 → 1.0.0Dependent
      @tanstack/ai-sandbox-docker0.2.0 → 1.0.0Dependent
      @tanstack/ai-sandbox-local-process0.2.0 → 1.0.0Dependent
      @tanstack/ai-sandbox-sprites0.2.1 → 1.0.0Dependent
      @tanstack/ai-sandbox-vercel0.2.0 → 1.0.0Dependent
      @tanstack/ai-solid-ui0.7.14 → 1.0.0Dependent
      @tanstack/openai-base0.9.9 → 1.0.0Dependent

      🟨 Minor bumps

      PackageVersionReason
      @tanstack/ai0.42.0 → 0.43.0Changeset
      @tanstack/ai-client0.22.1 → 0.23.0Changeset

      🟩 Patch bumps

      PackageVersionReason
      @tanstack/ai-devtools-core0.4.24 → 0.4.25Dependent
      @tanstack/ai-isolate-cloudflare0.2.38 → 0.2.39Dependent
      @tanstack/ai-mcp0.2.5 → 0.2.6Dependent
      @tanstack/ai-vue-ui0.2.34 → 0.2.35Dependent
      @tanstack/preact-ai-devtools0.1.67 → 0.1.68Dependent
      @tanstack/react-ai-devtools0.2.67 → 0.2.68Dependent
      @tanstack/solid-ai-devtools0.2.67 → 0.2.68Dependent
      ag-ui0.0.2 → 0.0.3Dependent
    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Review Change Stack

      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 introduces AG-UI interrupt outcomes, typed approval and generic resolution, atomic resume batches, optional interrupt persistence, framework bindings, migration documentation, and a new Interrupt Lab example with ephemeral and durable scenarios.

      Changes

      AG-UI interrupt lifecycle

      Layer / File(s)Summary
      Interrupt contracts and validation
      packages/ai/src/interrupts.ts, packages/ai/src/interrupt-resume.ts, packages/ai/src/activities/chat/tools/*
      Adds typed interrupt bindings, approval schemas, resume validation, JSON Schema validation, canonical serialization, and structured submission errors.
      Chat engine and client continuation
      packages/ai/src/activities/chat/index.ts, packages/ai-client/src/chat-client.ts, packages/ai-client/src/interrupt-manager.ts
      Emits snapshot-plus-RUN_FINISHED interrupt outcomes, validates and resumes batches in child runs, tracks interrupt state, and preserves compatibility APIs.
      Persistence and framework bindings
      packages/ai-client/src/chat-persistence-controller.ts, packages/ai-client/src/storage-adapters.ts, packages/ai-react/src/*, packages/ai-preact/src/*, packages/ai-solid/src/*, packages/ai-svelte/src/*, packages/ai-vue/src/*, packages/ai-angular/src/*
      Adds message/resume persistence coordination and exposes interrupt state and controls across framework integrations.
      Documentation and migration
      docs/interrupts/*, docs/architecture/approval-flow-processing.md, docs/tools/*, docs/reference/functions/toolDefinition.md
      Documents interrupt lifecycle, generic validation, approval branches, batching, cancellation, migration, and client-tool execution.
      Interrupt Lab and integration coverage
      examples/ts-react-chat/src/lib/interrupt-lab/*, testing/e2e/src/routes/*, packages/*/tests/*
      Adds scenario tools, ephemeral and durable routes, diagnostic UI, error/retry demonstrations, and tests for interrupt, resume, persistence, and type behavior.

      Estimated code review effort: 5 (Critical) | ~120 minutes

      Possibly related PRs

      • TanStack/ai#597 — Both modify RunAgentInputContext and its interrupt-resume request surface.
      • TanStack/ai#661 — Both extend ChatClient persistence plumbing for resumable state.
      • TanStack/ai#700 — Both touch tool-execution plumbing in tool-calls.ts.

      Suggested reviewers: tombeckenham

      🚥 Pre-merge checks | ✅ 3 | ❌ 2

      ❌ Failed checks (2 warnings)

      Check nameStatusExplanationResolution
      Description check⚠️ WarningThe description is detailed but does not follow the repository’s required template or include the checklist and release-impact sections.Reformat into the required template with ## 🎯 Changes, ## ✅ Checklist, and ## 🚀 Release Impact, and complete the checklist items.
      Docstring Coverage⚠️ WarningDocstring coverage is 4.27% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
      ✅ Passed checks (3 passed)
      Check nameStatusExplanation
      Title check✅ PassedThe title clearly summarizes the main change: an ephemeral AG-UI interrupts overhaul.
      Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests
      • Commit unit tests in branch `feat/interrupts-overhaul`

      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.
    3. socket-security[bot](GitHub profile, opens in a new tab)commented

      All alerts resolved. Learn more about Socket for GitHub.

      This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

      View full report

    4. nx-cloud[bot](GitHub profile, opens in a new tab)commented

      View your CI Pipeline Execution ↗ for commit ae36548d81b32ca07bb4a393f17d20b2091f5868

      CommandStatusDurationResult
      nx run-many --targets=build --exclude=examples/...✅ Succeeded1sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-07-22 10:33:34 UTC

    5. pkg-pr-new[bot](GitHub profile, opens in a new tab)commented

      Open in StackBlitz

      @tanstack/ai

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

      @tanstack/ai-acp

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-acp@970

      @tanstack/ai-angular

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-angular@970

      @tanstack/ai-anthropic

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

      @tanstack/ai-bedrock

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-bedrock@970

      @tanstack/ai-claude-code

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-claude-code@970

      @tanstack/ai-client

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

      @tanstack/ai-code-mode

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

      @tanstack/ai-code-mode-skills

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

      @tanstack/ai-codex

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-codex@970

      @tanstack/ai-devtools-core

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

      @tanstack/ai-durable-stream

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-durable-stream@970

      @tanstack/ai-elevenlabs

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

      @tanstack/ai-event-client

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

      @tanstack/ai-fal

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

      @tanstack/ai-gemini

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

      @tanstack/ai-grok

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

      @tanstack/ai-grok-build

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-grok-build@970

      @tanstack/ai-groq

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

      @tanstack/ai-isolate-cloudflare

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

      @tanstack/ai-isolate-node

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

      @tanstack/ai-isolate-quickjs

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

      @tanstack/ai-mcp

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-mcp@970

      @tanstack/ai-mistral

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-mistral@970

      @tanstack/ai-ollama

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

      @tanstack/ai-openai

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

      @tanstack/ai-opencode

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-opencode@970

      @tanstack/ai-openrouter

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

      @tanstack/ai-preact

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

      @tanstack/ai-react

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

      @tanstack/ai-react-ui

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

      @tanstack/ai-sandbox

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox@970

      @tanstack/ai-sandbox-cloudflare

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-cloudflare@970

      @tanstack/ai-sandbox-daytona

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-daytona@970

      @tanstack/ai-sandbox-docker

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-docker@970

      @tanstack/ai-sandbox-local-process

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-local-process@970

      @tanstack/ai-sandbox-sprites

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-sprites@970

      @tanstack/ai-sandbox-vercel

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-vercel@970

      @tanstack/ai-solid

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

      @tanstack/ai-solid-ui

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

      @tanstack/ai-svelte

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

      @tanstack/ai-utils

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

      @tanstack/ai-vue

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

      @tanstack/ai-vue-ui

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

      @tanstack/openai-base

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/openai-base@970

      @tanstack/preact-ai-devtools

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

      @tanstack/react-ai-devtools

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

      @tanstack/solid-ai-devtools

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

      commit: ae36548

    6. Actionable comments posted: 8

      Caution

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

      ⚠️ Outside diff range comments (3)
      examples/ts-react-chat/src/routes/generations.structured-output.tsx (1)

      146-153: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

      Restore the PartialResult cast

      payload.value.object is still unknown, so setResult(payload.value.object) won’t typecheck against PartialResult | null. Keep the cast or add a real type guard before assigning.

      🤖 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 `@examples/ts-react-chat/src/routes/generations.structured-output.tsx` around
      lines 146 - 153, Restore the PartialResult cast when assigning
      payload.value.object to the result state, or add a type guard that narrows the
      unknown value to PartialResult before the setResult call. Update the assignment
      path using StreamChunkPayload while preserving the existing null handling.
      packages/ai-svelte/src/create-generation.svelte.ts (2)

      1-1: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

      Gate the raw onResult passthrough behind disposed, like every other callback.

      Both files add a disposed flag this PR and gate onError/onProgress/onChunk/onResultChange/onLoadingChange/onErrorChange/onStatusChange (and, in the video file, onJobCreated/onStatusUpdate/onJobIdChange/onVideoStatusChange) behind it — but the raw onResult pass-through to the user-supplied callback is left unguarded in both. If a generation resolves after dispose() is called (e.g. component unmounted while a fetch is in flight), the user's onResult will still fire despite every other callback being suppressed post-disposal.

      • packages/ai-svelte/src/create-generation.svelte.ts#L184-186: wrap options.onResult?.(r) in if (!disposed).
      • packages/ai-svelte/src/create-generate-video.svelte.ts#L188-190: wrap options.onResult?.(r) in if (!disposed).
      🛡️ Proposed fix
      -    onResult: ((r: TResult) => options.onResult?.(r)) as (
      -      result: TResult,
      -    ) => TOutput | null | void,
      +    onResult: ((r: TResult) => {
      +      if (disposed) return
      +      return options.onResult?.(r)
      +    }) as (result: TResult) => TOutput | null | void,
      🤖 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/ai-svelte/src/create-generation.svelte.ts` at line 1, Guard the raw
      onResult callbacks in the generation result handlers with the existing disposed
      flag. Update the onResult handling in create-generation.svelte.ts and
      create-generate-video.svelte.ts so options.onResult is invoked only when
      disposed is false, matching the guards on the other callbacks.

      254-292: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

      Clear resumeSnapshot on reset client.reset() clears the client state, but the wrapper still exposes the previous resumeSnapshot, so resumeState, pendingArtifacts, and resultArtifacts can stay stale after a reset. Reset the local snapshot too, or have the client emit a cleared snapshot.

      🤖 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/ai-svelte/src/create-generation.svelte.ts` around lines 254 - 292,
      Update the reset flow around the returned reset API and local resumeSnapshot
      state so reset clears resumeSnapshot after invoking client.reset(). Ensure
      resumeState, pendingArtifacts, and resultArtifacts immediately return their
      empty/null defaults after reset, while preserving existing reset behavior.
      🧹 Nitpick comments (11)
      docs/tools/tool-approval.md (3)

      282-288: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

      Avoid non-null assertions (!) in documentation code samples.

      As per coding guidelines, documentation code samples must not use type-assertion casts and should type-check by narrowing or validating values. Please remove the non-null assertion or extract it to a local constant outside the closure.

      ♻️ Proposed refactor
                     <button
                       key={i}
                       onClick={() =>
                         addToolApprovalResponse({
      -                    id: part.approval!.id,
      +                    id: part.approval.id,
                           approved: true,
                         })
                       }
      🤖 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-approval.md` around lines 282 - 288, Update the onClick
      handler around addToolApprovalResponse to remove the non-null assertion on
      part.approval. Narrow or validate part.approval before the closure, using a
      local constant if needed, while preserving the existing approval ID and
      approved: true behavior.

      Source: Coding guidelines


      191-197: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

      Avoid non-null assertions (!) in documentation code samples.

      As per coding guidelines, documentation code samples must not use type-assertion casts and should type-check by narrowing or validating values. The non-null assertion part.approval! acts as a type assertion.

      Since part.approval is checked in the outer if statement and part is not reassigned, TypeScript should be able to narrow it without the !. If TypeScript loses the narrowing inside the onClick closure, extract the ID to a constant before the return statement: const approval = part.approval;

      ♻️ Proposed refactor
                         <button
                           onClick={() =>
                             addToolApprovalResponse({
      -                        id: part.approval!.id,
      +                        id: part.approval.id,
                               approved: true,
                             })
                           }
      🤖 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-approval.md` around lines 191 - 197, Remove the non-null
      assertion from the approval ID access in the addToolApprovalResponse onClick
      handler, relying on the surrounding part.approval narrowing. If narrowing is not
      preserved inside the closure, capture part.approval in a local constant before
      returning the element and use that validated value.

      Source: Coding guidelines


      201-207: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

      Avoid non-null assertions (!) in documentation code samples.

      As per coding guidelines, documentation code samples must not use type-assertion casts and should type-check by narrowing or validating values. Please remove the non-null assertion or extract it to a local constant outside the closure.

      ♻️ Proposed refactor
                         <button
                           onClick={() =>
                             addToolApprovalResponse({
      -                        id: part.approval!.id,
      +                        id: part.approval.id,
                               approved: false,
                             })
                           }
      🤖 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-approval.md` around lines 201 - 207, Remove the non-null
      assertion from the onClick handler’s use of part.approval in the
      addToolApprovalResponse call. Narrow or validate part.approval before accessing
      its id, extracting a local value outside the closure if needed, while preserving
      the existing approved: false behavior.

      Source: Coding guidelines

      packages/ai-client/src/generation-client.ts (1)

      527-578: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoff

      Extract the shared resume-snapshot persistence lifecycle and coalesce per-chunk writes. observeResumeSnapshot, completePlainFetcherResumeSnapshot, persistResumeSnapshot, writeResumeSnapshot (and the getResumeSnapshot/getResumePersistenceError/getStatus getters) are identical in both clients, so any fix to the queue/persistence logic must be applied in two places and can silently drift. Separately, observeResumeSnapshot enqueues a serverPersistence.setItem write on every stream chunk; with last-write-wins semantics the intermediate writes are wasted I/O (notably for high-frequency VIDEO_STATUS polling chunks).

      • packages/ai-client/src/generation-client.ts#L527-L578: move these helpers into a shared module/mixin (e.g. a ResumeSnapshotPersister used by both clients) and coalesce writes (debounce/trailing-write or persist only on meaningful transitions: running→complete/error, artifact/result changes).
      • packages/ai-client/src/video-generation-client.ts#L613-L664: replace the duplicated helpers with the shared implementation so both clients stay in sync.
      🤖 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/ai-client/src/generation-client.ts` around lines 527 - 578, Extract
      the duplicated resume-snapshot lifecycle from generation-client.ts#L527-L578 and
      video-generation-client.ts#L613-L664, including observeResumeSnapshot,
      completePlainFetcherResumeSnapshot, persistResumeSnapshot, writeResumeSnapshot,
      and the related getters, into one shared ResumeSnapshotPersister implementation
      used by both clients. Add trailing-write coalescing or equivalent
      meaningful-transition persistence so per-chunk updates do not enqueue redundant
      serverPersistence.setItem calls, while preserving final complete/error snapshots
      and existing persistence-error behavior; update both sites to delegate to the
      shared implementation.
      packages/ai-client/tests/interrupts-types.test-d.ts (1)

      162-164: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

      toMatchTypeOf is deprecated; prefer toExtend.

      Per expect-type's docs, .toMatchTypeOf is deprecated in favor of .toExtend (identical semantics) or .toMatchObjectType (stricter, plain-object-only). Not urgent since removal isn't planned, but new tests shouldn't introduce the deprecated form.

      ♻️ Suggested fix
      -expectTypeOf<Extract<Interrupt, { kind: 'tool-approval' }>>().toMatchTypeOf<
      +expectTypeOf<Extract<Interrupt, { kind: 'tool-approval' }>>().toExtend<
         ToolApprovalInterrupt<Tools[number]>
       >()
      🤖 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/ai-client/tests/interrupts-types.test-d.ts` around lines 162 - 164,
      Replace the deprecated toMatchTypeOf assertion in the Interrupt type test with
      toExtend, preserving the existing Extract<Interrupt, { kind: 'tool-approval' }>
      and ToolApprovalInterrupt<Tools[number]> type relationship.
      packages/ai-client/tests/generation-resume-state.test.ts (1)

      245-258: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

      Test doesn't exercise "explicit stop" scenario despite its name.

      Only a RUN_STARTED chunk is reduced; there's no finishReason: 'stop' (or equivalent) chunk in the input, so the assertions about cancelled/cancelEndpoint pass trivially regardless of whether the reducer actually models explicit stop correctly. This leaves the described guard unverified.

      ♻️ Suggested fix: actually reduce a stop-related chunk
         it('does not model explicit stop as durable cancel state', () => {
           const snapshot = reduceChunks([
             {
               type: EventType.RUN_STARTED,
               threadId: 'thread-1',
               runId: 'run-1',
               timestamp: 1,
             },
      +      {
      +        type: EventType.RUN_FINISHED,
      +        threadId: 'thread-1',
      +        runId: 'run-1',
      +        finishReason: 'stop',
      +        timestamp: 2,
      +      },
           ])
      
      -    expect(snapshot.status).toBe('running')
      +    expect(snapshot.status).toBe('complete')
           expect(snapshot).not.toHaveProperty('cancelled')
           expect(snapshot).not.toHaveProperty('cancelEndpoint')
         })
      🤖 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/ai-client/tests/generation-resume-state.test.ts` around lines 245 -
      258, Update the test around reduceChunks to include a run-completion chunk
      representing an explicit stop, using the repository’s established finishReason
      or equivalent stop event shape. Keep the assertions that the resulting snapshot
      is not marked cancelled and has no cancelEndpoint, so the test verifies reducer
      behavior rather than only the initial RUN_STARTED state.
      packages/ai/src/activities/chat/tools/json-schema-validator.ts (1)

      105-119: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

      Reuse a shared Ajv2020 instance

      compileJsonSchema202012 creates a fresh Ajv2020 and re-registers formats on every validation. This helper is on the interrupt-resume and interrupt-manager validation paths, so the setup cost repeats on each schema check. Move the Ajv instance (and addFormats) to module scope, or cache compiled validators by schema identity.

      🤖 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/ai/src/activities/chat/tools/json-schema-validator.ts` around lines
      105 - 119, Update compileJsonSchema202012 to reuse a module-scoped Ajv2020
      instance configured with the existing options and registered formats, rather
      than constructing Ajv2020 and calling addFormats on every invocation. Preserve
      the current validation behavior and schema compilation flow.
      packages/ai-angular/src/inject-chat.ts (1)

      279-287: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

      Redundant if/else — both branches are identical.

      resolveInterrupts branches on typeof resolution === 'boolean' but both arms call client.resolveInterrupts(resolution) with no difference. Since client.resolveInterrupts is already overloaded to accept both boolean and resolver-function forms, this wrapper can just forward the argument directly.

      ♻️ Proposed simplification
         const resolveInterrupts = (
           resolution: boolean | ((interrupt: ChatInterrupt<TTools>) => undefined),
         ) => {
      -    if (typeof resolution === 'boolean') {
      -      client.resolveInterrupts(resolution)
      -    } else {
      -      client.resolveInterrupts(resolution)
      -    }
      +    client.resolveInterrupts(resolution)
         }
      🤖 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/ai-angular/src/inject-chat.ts` around lines 279 - 287, Simplify
      resolveInterrupts by removing the redundant typeof-based if/else and directly
      forwarding resolution to client.resolveInterrupts; preserve support for both
      boolean and resolver-function inputs through the existing overloads.
      packages/ai-react/src/types.ts (1)

      204-225: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

      Add JSDoc for the new interrupt/resume return fields.

      Every other member of BaseUseChatReturn has a doc comment; this new block (resumeState, interrupts, interruptErrors, resuming, resolveInterrupts, cancelInterrupts, retryInterrupts, resumeInterruptsUnsafe) has none except the two @deprecated aliases. This is a sizable new public API surface for consumers to discover without editor tooltips.

      🤖 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/ai-react/src/types.ts` around lines 204 - 225, Add concise JSDoc
      comments to each new public member in BaseUseChatReturn: resumeState,
      interrupts, interruptErrors, resuming, resolveInterrupts, cancelInterrupts,
      retryInterrupts, and resumeInterruptsUnsafe. Describe each member’s purpose and
      usage, while preserving the existing deprecation comments for pendingInterrupts
      and resumeInterrupts.
      packages/ai-vue/src/use-generate-video.ts (1)

      45-48: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

      Inconsistent with sibling composables: doesn't derive persistence/initialResumeSnapshot/resume fields via Pick/Omit.

      use-generate-image.ts, use-generate-speech.ts, and use-transcription.ts derive persistence/initialResumeSnapshot via Pick<UseGenerationOptions<...>, ...> and derive resume/artifact return fields via Omit<UseGenerationReturn<TOutput>, 'generate'>. This file duplicates the same fields manually, risking type drift if GenerationClientOptions/UseGenerationReturn change later.

      ♻️ Suggested alignment with sibling composables
      +import type {
      +  UseGenerationOptions,
      +  UseGenerationReturn,
      +} from './use-generation'
      +
      -export interface UseGenerateVideoOptions<TOutput = VideoGenerateResult> {
      +export interface UseGenerateVideoOptions<
      +  TOutput = VideoGenerateResult,
      +> extends Pick<
      +  UseGenerationOptions<VideoGenerateInput, VideoGenerateResult, TOutput>,
      +  'persistence' | 'initialResumeSnapshot'
      +> {
         /** Connect-based adapter for streaming transport (server handles polling) */
         connection?: ConnectConnectionAdapter
         ...
      -  /** Server-side lightweight generation state persistence. */
      -  persistence?: GenerationPersistenceOptions
      -  /** Initial lightweight resume snapshot restored by the app (read-only state). */
      -  initialResumeSnapshot?: GenerationResumeSnapshot
         ...
       }
      
      -export interface UseGenerateVideoReturn<TOutput = VideoGenerateResult> {
      +export interface UseGenerateVideoReturn<
      +  TOutput = VideoGenerateResult,
      +> extends Omit<UseGenerationReturn<TOutput>, 'generate'> {
         ...
      -  resumeSnapshot: DeepReadonly<ShallowRef<GenerationResumeSnapshot | undefined>>
      -  resumeState: DeepReadonly<ShallowRef<GenerationResumeState | null>>
      -  pendingArtifacts: DeepReadonly<ShallowRef<Array<GenerationPendingArtifact>>>
      -  resultArtifacts: DeepReadonly<ShallowRef<Array<PersistedArtifactRef>>>
       }

      Also applies to: 93-100

      🤖 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/ai-vue/src/use-generate-video.ts` around lines 45 - 48, Align
      useGenerateVideo’s option and return types with the sibling composables by
      deriving persistence and initialResumeSnapshot through
      Pick<UseGenerationOptions<...>, ...>, and deriving resume/artifact return fields
      through Omit<UseGenerationReturn<TOutput>, 'generate'>. Remove the duplicated
      manual field declarations while preserving the existing generate API and
      video-specific types.
      packages/ai-react/src/use-generation.ts (1)

      240-243: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

      Extract the resume-field derivation to avoid duplication with use-generate-video.ts.

      The resumeState/pendingArtifacts/resultArtifacts derivation from resumeSnapshot here is byte-for-byte duplicated in use-generate-video.ts (which has its own independent client-construction path rather than delegating to useGeneration). A shared helper (e.g. deriveResumeFields(snapshot) in a small shared module) would keep both in sync if GenerationResumeSnapshot's shape evolves.

      ♻️ Proposed shared helper
      +function deriveResumeFields<TArtifact>(
      +  snapshot: GenerationResumeSnapshot | undefined,
      +): {
      +  resumeState: GenerationResumeState | null
      +  pendingArtifacts: Array<GenerationPendingArtifact>
      +  resultArtifacts: Array<TArtifact>
      +} {
      +  return {
      +    resumeState: snapshot?.resumeState ?? null,
      +    pendingArtifacts: snapshot?.pendingArtifacts ?? [],
      +    resultArtifacts: (snapshot?.result?.artifacts ?? []) as Array<TArtifact>,
      +  }
      +}
      🤖 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/ai-react/src/use-generation.ts` around lines 240 - 243, Extract the
      duplicated resumeSnapshot field derivation from the current hook and
      use-generate-video.ts into a shared helper such as deriveResumeFields(snapshot).
      Update both client-construction paths to call the helper while preserving the
      existing null and empty-array defaults for resumeState, pendingArtifacts, and
      resultArtifacts.
      🤖 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/architecture/approval-flow-processing.md`:
      - Around line 137-145: Update both documentation
      snippets—docs/architecture/approval-flow-processing.md lines 137-145 and
      docs/interrupts/tool-approval.md lines 72-80—to use the gpt-chat-latest alias in
      their openaiText calls instead of gpt-5.5; no other example behavior should
      change.
      
      In `@docs/config.json`:
      - Around line 104-112: Update the timestamp metadata for all pages modified or
      added in this change, including the entries represented by the visible Tool
      Approval Flow object and the referenced locations, to use "2026-07-20" for
      updatedAt and, for newly added pages, addedAt as well.
      
      In `@packages/ai-client/tests/chat-client-interrupts.test.ts`:
      - Line 1: Re-save packages/ai-client/tests/chat-client-interrupts.test.ts as
      UTF-8 without a BOM and replace the mojibake em-dashes in comments at lines 148,
      328, and 395; likewise remove the leading BOM from
      packages/ai-client/tests/chat-client-resume.test.ts before its import statement.
      
      In `@packages/ai-solid/src/use-chat.ts`:
      - Around line 331-334: Update resumeInterruptsUnsafe to await the underlying
      client().resumeInterruptsUnsafe call, then invoke syncResumeState() after it
      settles, matching the other resume/interrupt-affecting methods and keeping its
      existing arguments and return behavior.
      
      In `@packages/ai/src/activities/chat/index.ts`:
      - Around line 3307-3328: Update applyResumeToolState to merge
      state.genericInterrupts into the corresponding resume-state collection,
      preserving each interrupt’s identifier and resolution like the existing
      approvals, clientToolResults, and deniedToolResults handling. Ensure
      reconstructed generic-interrupt resume resolutions are retained.
      
      In `@testing/e2e/src/components/ChatUI.tsx`:
      - Around line 36-38: Update the Send button’s disabled condition in ChatUI to
      include hasPendingInterrupt, so it is disabled when an interrupt is pending or
      the input is empty. Keep handleSubmit’s existing no-op guard and apply the same
      pending-interrupt state consistently to the other affected input controls.
      
      In `@testing/e2e/src/routes/`$provider/$feature.tsx:
      - Around line 122-145: Update parsePendingInterrupts to validate every array
      entry and throw a TypeError when an entry is not a record or lacks string
      id/reason, matching deserializeMessages and deserializeResumeSnapshot behavior.
      Preserve the existing normalization of valid toolCallId and metadata fields, but
      remove the silent continue paths so malformed persisted data cannot produce a
      partial list.
      
      In `@testing/e2e/tests/tool-approval.spec.ts`:
      - Line 13: Update the suite title in the tool-approval test.describe declaration
      to use the intended em dash character (—) instead of the mojibake sequence
      (—); preserve the existing provider interpolation and title text.
      
      ---
      
      Outside diff comments:
      In `@examples/ts-react-chat/src/routes/generations.structured-output.tsx`:
      - Around line 146-153: Restore the PartialResult cast when assigning
      payload.value.object to the result state, or add a type guard that narrows the
      unknown value to PartialResult before the setResult call. Update the assignment
      path using StreamChunkPayload while preserving the existing null handling.
      
      In `@packages/ai-svelte/src/create-generation.svelte.ts`:
      - Line 1: Guard the raw onResult callbacks in the generation result handlers
      with the existing disposed flag. Update the onResult handling in
      create-generation.svelte.ts and create-generate-video.svelte.ts so
      options.onResult is invoked only when disposed is false, matching the guards on
      the other callbacks.
      - Around line 254-292: Update the reset flow around the returned reset API and
      local resumeSnapshot state so reset clears resumeSnapshot after invoking
      client.reset(). Ensure resumeState, pendingArtifacts, and resultArtifacts
      immediately return their empty/null defaults after reset, while preserving
      existing reset behavior.
      
      ---
      
      Nitpick comments:
      In `@docs/tools/tool-approval.md`:
      - Around line 282-288: Update the onClick handler around addToolApprovalResponse
      to remove the non-null assertion on part.approval. Narrow or validate
      part.approval before the closure, using a local constant if needed, while
      preserving the existing approval ID and approved: true behavior.
      - Around line 191-197: Remove the non-null assertion from the approval ID access
      in the addToolApprovalResponse onClick handler, relying on the surrounding
      part.approval narrowing. If narrowing is not preserved inside the closure,
      capture part.approval in a local constant before returning the element and use
      that validated value.
      - Around line 201-207: Remove the non-null assertion from the onClick handler’s
      use of part.approval in the addToolApprovalResponse call. Narrow or validate
      part.approval before accessing its id, extracting a local value outside the
      closure if needed, while preserving the existing approved: false behavior.
      
      In `@packages/ai-angular/src/inject-chat.ts`:
      - Around line 279-287: Simplify resolveInterrupts by removing the redundant
      typeof-based if/else and directly forwarding resolution to
      client.resolveInterrupts; preserve support for both boolean and
      resolver-function inputs through the existing overloads.
      
      In `@packages/ai-client/src/generation-client.ts`:
      - Around line 527-578: Extract the duplicated resume-snapshot lifecycle from
      generation-client.ts#L527-L578 and video-generation-client.ts#L613-L664,
      including observeResumeSnapshot, completePlainFetcherResumeSnapshot,
      persistResumeSnapshot, writeResumeSnapshot, and the related getters, into one
      shared ResumeSnapshotPersister implementation used by both clients. Add
      trailing-write coalescing or equivalent meaningful-transition persistence so
      per-chunk updates do not enqueue redundant serverPersistence.setItem calls,
      while preserving final complete/error snapshots and existing persistence-error
      behavior; update both sites to delegate to the shared implementation.
      
      In `@packages/ai-client/tests/generation-resume-state.test.ts`:
      - Around line 245-258: Update the test around reduceChunks to include a
      run-completion chunk representing an explicit stop, using the repository’s
      established finishReason or equivalent stop event shape. Keep the assertions
      that the resulting snapshot is not marked cancelled and has no cancelEndpoint,
      so the test verifies reducer behavior rather than only the initial RUN_STARTED
      state.
      
      In `@packages/ai-client/tests/interrupts-types.test-d.ts`:
      - Around line 162-164: Replace the deprecated toMatchTypeOf assertion in the
      Interrupt type test with toExtend, preserving the existing Extract<Interrupt, {
      kind: 'tool-approval' }> and ToolApprovalInterrupt<Tools[number]> type
      relationship.
      
      In `@packages/ai-react/src/types.ts`:
      - Around line 204-225: Add concise JSDoc comments to each new public member in
      BaseUseChatReturn: resumeState, interrupts, interruptErrors, resuming,
      resolveInterrupts, cancelInterrupts, retryInterrupts, and
      resumeInterruptsUnsafe. Describe each member’s purpose and usage, while
      preserving the existing deprecation comments for pendingInterrupts and
      resumeInterrupts.
      
      In `@packages/ai-react/src/use-generation.ts`:
      - Around line 240-243: Extract the duplicated resumeSnapshot field derivation
      from the current hook and use-generate-video.ts into a shared helper such as
      deriveResumeFields(snapshot). Update both client-construction paths to call the
      helper while preserving the existing null and empty-array defaults for
      resumeState, pendingArtifacts, and resultArtifacts.
      
      In `@packages/ai-vue/src/use-generate-video.ts`:
      - Around line 45-48: Align useGenerateVideo’s option and return types with the
      sibling composables by deriving persistence and initialResumeSnapshot through
      Pick<UseGenerationOptions<...>, ...>, and deriving resume/artifact return fields
      through Omit<UseGenerationReturn<TOutput>, 'generate'>. Remove the duplicated
      manual field declarations while preserving the existing generate API and
      video-specific types.
      
      In `@packages/ai/src/activities/chat/tools/json-schema-validator.ts`:
      - Around line 105-119: Update compileJsonSchema202012 to reuse a module-scoped
      Ajv2020 instance configured with the existing options and registered formats,
      rather than constructing Ajv2020 and calling addFormats on every invocation.
      Preserve the current validation behavior and schema compilation flow.
      🪄 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: 300877ad-3d76-45c8-be03-b57ded65d2e7

      📥 Commits

      Reviewing files that changed from the base of the PR and between 7c7aa09a7402b45e6285ebc78a606131aec3e288 and 0883ecbfee62dafd806e77e8a0422411d38d780e.

      ⛔ Files ignored due to path filters (1)
      • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
      📒 Files selected for processing (268)
      • .changeset/ag-ui-interrupts.md
      • docs/architecture/approval-flow-processing.md
      • docs/config.json
      • docs/interrupts/generic.md
      • docs/interrupts/migration.md
      • docs/interrupts/multiple.md
      • docs/interrupts/overview.md
      • docs/interrupts/tool-approval.md
      • docs/reference/functions/toolDefinition.md
      • docs/tools/client-tools.md
      • docs/tools/tool-approval.md
      • examples/ts-code-mode-web/src/routes/_database-demo/api.database-demo.ts
      • examples/ts-react-chat/.env.example
      • examples/ts-react-chat/README.md
      • examples/ts-react-chat/package.json
      • examples/ts-react-chat/src/components/Header.tsx
      • examples/ts-react-chat/src/lib/guitar-tools.ts
      • examples/ts-react-chat/src/lib/interrupt-lab/InterruptLabPage.tsx
      • examples/ts-react-chat/src/lib/interrupt-lab/client-ui.test.ts
      • examples/ts-react-chat/src/lib/interrupt-lab/client-ui.ts
      • examples/ts-react-chat/src/lib/interrupt-lab/scenarios.ts
      • examples/ts-react-chat/src/lib/interrupt-lab/server.test.ts
      • examples/ts-react-chat/src/lib/interrupt-lab/server.ts
      • examples/ts-react-chat/src/lib/realtime-tools.ts
      • examples/ts-react-chat/src/lib/server-audio-adapters.ts
      • examples/ts-react-chat/src/lib/server-fns.ts
      • examples/ts-react-chat/src/routeTree.gen.ts
      • examples/ts-react-chat/src/routes/api.generate.image.ts
      • examples/ts-react-chat/src/routes/api.generate.video.ts
      • examples/ts-react-chat/src/routes/api.interrupts.ts
      • examples/ts-react-chat/src/routes/api.mcp-apps-call.ts
      • examples/ts-react-chat/src/routes/api.mcp-manual.ts
      • examples/ts-react-chat/src/routes/api.mcp-pool.ts
      • examples/ts-react-chat/src/routes/api.structured-output.ts
      • examples/ts-react-chat/src/routes/api.tanchat.ts
      • examples/ts-react-chat/src/routes/example.runtime-context.tsx
      • examples/ts-react-chat/src/routes/generation-hooks.tsx
      • examples/ts-react-chat/src/routes/generations.audio.tsx
      • examples/ts-react-chat/src/routes/generations.image.tsx
      • examples/ts-react-chat/src/routes/generations.speech.tsx
      • examples/ts-react-chat/src/routes/generations.structured-chat.tsx
      • examples/ts-react-chat/src/routes/generations.structured-output.tsx
      • examples/ts-react-chat/src/routes/generations.summarize.tsx
      • examples/ts-react-chat/src/routes/generations.video.tsx
      • examples/ts-react-chat/src/routes/image-tool-repro.tsx
      • examples/ts-react-chat/src/routes/interrupts.tsx
      • examples/ts-react-chat/src/routes/issue-176-tool-result.tsx
      • examples/ts-react-chat/src/routes/mcp-apps.tsx
      • examples/ts-react-chat/src/routes/mcp-demo.tsx
      • examples/ts-react-chat/src/routes/realtime.tsx
      • examples/ts-react-chat/src/routes/threads.tsx
      • packages/ai-acp/tests/compatible.test.ts
      • packages/ai-acp/tests/sandbox-provisioning.test.ts
      • packages/ai-angular/package.json
      • packages/ai-angular/src/inject-chat.ts
      • packages/ai-angular/src/inject-generate-audio.ts
      • packages/ai-angular/src/inject-generate-image.ts
      • packages/ai-angular/src/inject-generate-speech.ts
      • packages/ai-angular/src/inject-generate-video.ts
      • packages/ai-angular/src/inject-generation.ts
      • packages/ai-angular/src/inject-summarize.ts
      • packages/ai-angular/src/inject-transcription.ts
      • packages/ai-angular/src/types.ts
      • packages/ai-angular/tests/inject-audio-recorder.test.ts
      • packages/ai-angular/tests/inject-chat-types.test.ts
      • packages/ai-angular/tests/inject-chat.test.ts
      • packages/ai-angular/tests/inject-generation.test.ts
      • packages/ai-angular/tests/test-utils.ts
      • packages/ai-anthropic/tests/anthropic-adapter.test.ts
      • packages/ai-client/package.json
      • packages/ai-client/src/chat-client.ts
      • packages/ai-client/src/chat-persistence-controller.ts
      • packages/ai-client/src/cleared-stream-tracker.ts
      • packages/ai-client/src/client-persistor.ts
      • packages/ai-client/src/connection-adapters.ts
      • packages/ai-client/src/generation-client.ts
      • packages/ai-client/src/generation-types.ts
      • packages/ai-client/src/index.ts
      • packages/ai-client/src/interrupt-manager.ts
      • packages/ai-client/src/interrupt-recovery-parse.ts
      • packages/ai-client/src/storage-adapters.ts
      • packages/ai-client/src/types.ts
      • packages/ai-client/src/video-generation-client.ts
      • packages/ai-client/tests/chat-client-interrupt-correlation.test.ts
      • packages/ai-client/tests/chat-client-interrupts.test.ts
      • packages/ai-client/tests/chat-client-resume.test.ts
      • packages/ai-client/tests/chat-client.test.ts
      • packages/ai-client/tests/chat-persistence-controller.test.ts
      • packages/ai-client/tests/cleared-stream-tracker.test.ts
      • packages/ai-client/tests/client-persistor.test.ts
      • packages/ai-client/tests/connection-adapters-xhr.test.ts
      • packages/ai-client/tests/generation-client.test.ts
      • packages/ai-client/tests/generation-resume-state.test.ts
      • packages/ai-client/tests/interrupts-types.test-d.ts
      • packages/ai-client/tests/storage-adapters-types.test-d.ts
      • packages/ai-client/tests/storage-adapters.test.ts
      • packages/ai-client/tests/test-utils.ts
      • packages/ai-event-client/src/index.ts
      • packages/ai-event-client/tests/emit.test.ts
      • packages/ai-event-client/tests/generation-events-types.test-d.ts
      • packages/ai-gemini/tests/text-interactions-adapter.test.ts
      • packages/ai-openrouter/tests/openrouter-responses-adapter.test.ts
      • packages/ai-preact/src/types.ts
      • packages/ai-preact/src/use-chat.ts
      • packages/ai-preact/tests/mcp-apps.test.tsx
      • packages/ai-preact/tests/test-utils.ts
      • packages/ai-preact/tests/use-chat-types.test.ts
      • packages/ai-preact/tests/use-chat.test.ts
      • packages/ai-react/src/types.ts
      • packages/ai-react/src/use-chat.ts
      • packages/ai-react/src/use-generate-audio.ts
      • packages/ai-react/src/use-generate-image.ts
      • packages/ai-react/src/use-generate-speech.ts
      • packages/ai-react/src/use-generate-video.ts
      • packages/ai-react/src/use-generation.ts
      • packages/ai-react/src/use-summarize.ts
      • packages/ai-react/src/use-transcription.ts
      • packages/ai-react/tests/mcp-apps.test.tsx
      • packages/ai-react/tests/test-utils.ts
      • packages/ai-react/tests/use-chat-fetcher.test.ts
      • packages/ai-react/tests/use-chat-options-probe.test.ts
      • packages/ai-react/tests/use-chat-structured-output.test.ts
      • packages/ai-react/tests/use-chat-types.test.ts
      • packages/ai-react/tests/use-chat.test.ts
      • packages/ai-react/tests/use-generation.test.ts
      • packages/ai-solid/src/types.ts
      • packages/ai-solid/src/use-chat.ts
      • packages/ai-solid/src/use-generate-audio.ts
      • packages/ai-solid/src/use-generate-image.ts
      • packages/ai-solid/src/use-generate-speech.ts
      • packages/ai-solid/src/use-generate-video.ts
      • packages/ai-solid/src/use-generation.ts
      • packages/ai-solid/src/use-summarize.ts
      • packages/ai-solid/src/use-transcription.ts
      • packages/ai-solid/tests/test-utils.ts
      • packages/ai-solid/tests/use-chat-types.test.ts
      • packages/ai-solid/tests/use-chat.test.ts
      • packages/ai-solid/tests/use-generation.test.ts
      • packages/ai-svelte/src/create-chat.svelte.ts
      • packages/ai-svelte/src/create-generate-audio.svelte.ts
      • packages/ai-svelte/src/create-generate-image.svelte.ts
      • packages/ai-svelte/src/create-generate-speech.svelte.ts
      • packages/ai-svelte/src/create-generate-video.svelte.ts
      • packages/ai-svelte/src/create-generation.svelte.ts
      • packages/ai-svelte/src/create-summarize.svelte.ts
      • packages/ai-svelte/src/create-transcription.svelte.ts
      • packages/ai-svelte/src/types.ts
      • packages/ai-svelte/tests/create-chat-types.test.ts
      • packages/ai-svelte/tests/create-generation.test.ts
      • packages/ai-svelte/tests/test-utils.ts
      • packages/ai-svelte/tests/use-chat.test.ts
      • packages/ai-utils/src/base64.ts
      • packages/ai-utils/src/index.ts
      • packages/ai-utils/tests/base64.test.ts
      • packages/ai-vue/src/types.ts
      • packages/ai-vue/src/use-chat.ts
      • packages/ai-vue/src/use-generate-audio.ts
      • packages/ai-vue/src/use-generate-image.ts
      • packages/ai-vue/src/use-generate-speech.ts
      • packages/ai-vue/src/use-generate-video.ts
      • packages/ai-vue/src/use-generation.ts
      • packages/ai-vue/src/use-summarize.ts
      • packages/ai-vue/src/use-transcription.ts
      • packages/ai-vue/tests/test-utils.ts
      • packages/ai-vue/tests/use-chat-types.test.ts
      • packages/ai-vue/tests/use-chat.test.ts
      • packages/ai-vue/tests/use-generation.test.ts
      • packages/ai/package.json
      • packages/ai/skills/ai-core/tool-calling/SKILL.md
      • packages/ai/src/activities/chat/index.ts
      • packages/ai/src/activities/chat/mcp/manager.ts
      • packages/ai/src/activities/chat/mcp/types.ts
      • packages/ai/src/activities/chat/messages.ts
      • packages/ai/src/activities/chat/middleware/index.ts
      • packages/ai/src/activities/chat/middleware/types.ts
      • packages/ai/src/activities/chat/stream/processor.ts
      • packages/ai/src/activities/chat/tools/approval-schema.ts
      • packages/ai/src/activities/chat/tools/json-schema-validator.ts
      • packages/ai/src/activities/chat/tools/tool-calls.ts
      • packages/ai/src/activities/chat/tools/tool-definition.ts
      • packages/ai/src/activities/generateAudio/index.ts
      • packages/ai/src/activities/generateImage/index.ts
      • packages/ai/src/activities/generateSpeech/index.ts
      • packages/ai/src/activities/generateTranscription/index.ts
      • packages/ai/src/activities/generateVideo/index.ts
      • packages/ai/src/activities/generation-run.ts
      • packages/ai/src/activities/middleware/index.ts
      • packages/ai/src/activities/middleware/run.ts
      • packages/ai/src/activities/middleware/types.ts
      • packages/ai/src/activities/stream-generation-result.ts
      • packages/ai/src/client.ts
      • packages/ai/src/custom-events.ts
      • packages/ai/src/index.ts
      • packages/ai/src/interrupt-resume.ts
      • packages/ai/src/interrupt-serialization.ts
      • packages/ai/src/interrupts.ts
      • packages/ai/src/stream-to-response.ts
      • packages/ai/src/types.ts
      • packages/ai/src/utilities/chat-params.ts
      • packages/ai/tests/ag-ui-wire.test.ts
      • packages/ai/tests/agent-loop-strategies.test.ts
      • packages/ai/tests/chat-mcp-manager.test.ts
      • packages/ai/tests/chat-params.test.ts
      • packages/ai/tests/chat-structured-output-null-normalization.test.ts
      • packages/ai/tests/chat-structured-output-stream.test.ts
      • packages/ai/tests/chat.test.ts
      • packages/ai/tests/content-guard-middleware.test.ts
      • packages/ai/tests/custom-events.test.ts
      • packages/ai/tests/debug-logging-chat.test.ts
      • packages/ai/tests/devtools-system-prompt-mirror.test.ts
      • packages/ai/tests/extend-adapter.test.ts
      • packages/ai/tests/generation-params.test.ts
      • packages/ai/tests/generation-result-transforms.test.ts
      • packages/ai/tests/generation-run-identity-replay.test.ts
      • packages/ai/tests/interrupts-types.test-d.ts
      • packages/ai/tests/interrupts.test.ts
      • packages/ai/tests/lazy-tool-manager.test.ts
      • packages/ai/tests/message-updaters.test.ts
      • packages/ai/tests/messages.test.ts
      • packages/ai/tests/middleware.test.ts
      • packages/ai/tests/middlewares/otel.test.ts
      • packages/ai/tests/multimodal-tool-result.test.ts
      • packages/ai/tests/strategies.test.ts
      • packages/ai/tests/stream-generation.test.ts
      • packages/ai/tests/stream-processor.test.ts
      • packages/ai/tests/stream-to-response.test.ts
      • packages/ai/tests/summarize-max-length.test.ts
      • packages/ai/tests/system-prompts.test.ts
      • packages/ai/tests/test-utils.ts
      • packages/ai/tests/tool-cache-middleware.test.ts
      • packages/ai/tests/tool-call-manager.test.ts
      • packages/ai/tests/tool-calls-null-input.test.ts
      • packages/ai/tests/tool-definition.test.ts
      • packages/ai/tests/tool-result.test.ts
      • packages/ai/tests/type-check.test.ts
      • packages/ai/tests/usage-cost-types.test.ts
      • pnpm-workspace.yaml
      • testing/e2e/src/components/AudioGenUI.tsx
      • testing/e2e/src/components/ChatUI.tsx
      • testing/e2e/src/components/ImageGenUI.tsx
      • testing/e2e/src/components/TTSUI.tsx
      • testing/e2e/src/components/TranscriptionUI.tsx
      • testing/e2e/src/components/VideoGenUI.tsx
      • testing/e2e/src/lib/feature-support.ts
      • testing/e2e/src/lib/features.ts
      • testing/e2e/src/lib/media-providers.ts
      • testing/e2e/src/lib/types.ts
      • testing/e2e/src/routes/$provider/$feature.tsx
      • testing/e2e/src/routes/$provider/index.tsx
      • testing/e2e/src/routes/api.audio.stream.ts
      • testing/e2e/src/routes/api.audio.ts
      • testing/e2e/src/routes/api.chat.ts
      • testing/e2e/src/routes/api.image.stream.ts
      • testing/e2e/src/routes/api.image.ts
      • testing/e2e/src/routes/api.middleware-test.ts
      • testing/e2e/src/routes/api.multimodal-tool-result-wire.ts
      • testing/e2e/src/routes/api.openai-shell-skills-wire.ts
      • testing/e2e/src/routes/api.openrouter-web-tools-wire.ts
      • testing/e2e/src/routes/api.otel-usage.ts
      • testing/e2e/src/routes/api.tools-test.ts
      • testing/e2e/src/routes/api.tts.stream.ts
      • testing/e2e/src/routes/api.tts.ts
      • testing/e2e/src/routes/api.video.stream.ts
      • testing/e2e/src/routes/api.video.ts
      • testing/e2e/src/routes/devtools-generation-hooks.tsx
      • testing/e2e/src/routes/middleware-test.tsx
      • testing/e2e/src/routes/tools-test.tsx
      • testing/e2e/tests/tool-approval.spec.ts
      💤 Files with no reviewable changes (4)
      • packages/ai-client/tests/client-persistor.test.ts
      • packages/ai-client/src/client-persistor.ts
      • packages/ai/src/stream-to-response.ts
      • examples/ts-react-chat/src/routes/realtime.tsx
      @@ -333,0 +125,21 @@
      125+```ts
      126+// app/api/chat/route.ts
      127+import {
      128+ chat,
      129+ chatParamsFromRequest,
      130+ toServerSentEventsResponse,
      131+} from '@tanstack/ai'
      132+import { openaiText } from '@tanstack/ai-openai'
      133+import { deleteProject } from './tools'
      134+
      135+export async function POST(request: Request) {
      136+ const params = await chatParamsFromRequest(request)
      137+ const stream = chat({
      138+ adapter: openaiText('gpt-5.5'),
      139+ messages: params.messages,
      140+ threadId: params.threadId,
      141+ runId: params.runId,
      142+ parentRunId: params.parentRunId,
      143+ ...(params.resume ? { resume: params.resume } : {}),
      144+ tools: [deleteProject],
      145+ })
      coderabbitai[bot](GitHub profile, opens in a new tab)commented

      🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

      🧩 Analysis chain

      🏁 Script executed:

      #!/bin/bash
      # Find the OpenAI adapter model-meta file and list its models
      fd 'model-meta.ts' packages/ai-openai --exec cat {}

      Repository: TanStack/ai

      Length of output: 50367


      🏁 Script executed:

      #!/bin/bash
      set -euo pipefail
      
      printf '\n-- docs/architecture/approval-flow-processing.md --\n'
      sed -n '125,155p' docs/architecture/approval-flow-processing.md
      
      printf '\n-- docs/interrupts/tool-approval.md --\n'
      sed -n '60,90p' docs/interrupts/tool-approval.md
      
      printf '\n-- OpenAI model entries around gpt-5.5 --\n'
      rg -n "GPT_5_5|GPT_CHAT_LATEST|GPT_5_5_PRO|openaiText\\('gpt-5.5'\\)" packages -n

      Repository: TanStack/ai

      Length of output: 8027


      🏁 Script executed:

      #!/bin/bash
      set -euo pipefail
      
      python3 - <<'PY'
      from pathlib import Path
      p = Path('packages/ai-openai/src/model-meta.ts')
      text = p.read_text()
      for key in ["const GPT_5_5 =", "const GPT_CHAT_LATEST =", "export const OPENAI_CHAT_MODELS = ["]:
          idx = text.find(key)
          print(f"\n### {key} @ {idx}")
          if idx != -1:
              start = max(0, idx-250)
              end = min(len(text), idx+900)
              print(text[start:end])
      PY

      Repository: TanStack/ai

      Length of output: 3717


      🏁 Script executed:

      #!/bin/bash
      set -euo pipefail
      
      python3 - <<'PY'
      from pathlib import Path
      for path in [Path('docs/architecture/approval-flow-processing.md'), Path('docs/interrupts/tool-approval.md')]:
          print(f"\n## {path}")
          text = path.read_text().splitlines()
          for i, line in enumerate(text, 1):
              if "gpt-5.5" in line or "openaiText(" in line:
                  for j in range(max(1, i-3), min(len(text), i+4)+1):
                      print(f"{j:4}: {text[j-1]}")
                  print()
      PY

      Repository: TanStack/ai

      Length of output: 904


      Use gpt-chat-latest in both snippets

      Both docs examples still use openaiText('gpt-5.5'); switch them to the latest OpenAI chat model alias.

      📍 Affects 2 files
      • docs/architecture/approval-flow-processing.md#L137-L145 (this comment)
      • docs/interrupts/tool-approval.md#L72-L80
      🤖 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/architecture/approval-flow-processing.md` around lines 137 - 145, Update
      both documentation snippets—docs/architecture/approval-flow-processing.md lines
      137-145 and docs/interrupts/tool-approval.md lines 72-80—to use the
      gpt-chat-latest alias in their openaiText calls instead of gpt-5.5; no other
      example behavior should change.

      Source: Coding guidelines

      @@ -102,11 +102,11 @@
      102102 "label": "Client Tools",
      103103 "to": "tools/client-tools",
      104104 "addedAt": "2026-04-15",
      105- "updatedAt": "2026-07-08"
      105+ "updatedAt": "2026-07-14"
      106106 },
      107107 {
      108108 "label": "Tool Approval Flow",
      109109 "to": "tools/tool-approval",
      110110 "addedAt": "2026-04-15",
      111- "updatedAt": "2026-07-08"
      111+ "updatedAt": "2026-07-14"
      112112 },
      coderabbitai[bot](GitHub profile, opens in a new tab)commented

      📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

      Update timestamps to today's date.

      As per coding guidelines, when making substantive content changes or adding new pages, you must set or refresh the timestamps to today's date. The current date is July 20, 2026, but the updatedAt and addedAt fields modified in this PR are set to past dates (e.g., 2026-07-14, 2026-07-15, 2026-07-16, etc.).

      Please update the modified updatedAt fields (and addedAt for newly added pages) to "2026-07-20".

      Also applies to: 147-149, 181-183, 212-214, 361-363, 394-396, 437-439, 506-508, 874-876

      🤖 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/config.json` around lines 104 - 112, Update the timestamp metadata for
      all pages modified or added in this change, including the entries represented by
      the visible Tool Approval Flow object and the referenced locations, to use
      "2026-07-20" for updatedAt and, for newly added pages, addedAt as well.

      Source: Coding guidelines

      @@ -245,0 +314,21 @@
      314+ resolution: boolean | ((interrupt: ChatInterrupt<TTools>) => undefined),
      315+ ) => {
      316+ if (typeof resolution === 'boolean') {
      317+ client().resolveInterrupts(resolution)
      318+ } else {
      319+ client().resolveInterrupts(resolution)
      320+ }
      321+ }
      322+
      323+ const cancelInterrupts = () => {
      324+ client().cancelInterrupts()
      325+ }
      326+
      327+ const retryInterrupts = () => {
      328+ client().retryInterrupts()
      329+ }
      330+
      331+ const resumeInterruptsUnsafe = (
      332+ resumeItems: Array<RunAgentResumeItem>,
      333+ state?: ChatResumeState,
      334+ ) => client().resumeInterruptsUnsafe(resumeItems, state)
      coderabbitai[bot](GitHub profile, opens in a new tab)commented

      🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

      resumeInterruptsUnsafe doesn't resync resumeState/interrupt signals after resolving.

      Every other resume/interrupt-affecting async method in this file (sendMessage, append, reload, addToolApprovalResponse, and even the deprecated resumeInterrupts alias at Line 304-311) calls syncResumeState() after the underlying client call settles. resumeInterruptsUnsafe — the recommended non-deprecated API per the JSDoc on its deprecated sibling — skips this, so resumeState(), interrupts(), interruptErrors(), and resuming() can remain stale after a resume until an unrelated state change triggers a resync.

      🐛 Proposed fix
         const resumeInterruptsUnsafe = (
           resumeItems: Array<RunAgentResumeItem>,
           state?: ChatResumeState,
      -  ) => client().resumeInterruptsUnsafe(resumeItems, state)
      +  ) => client().resumeInterruptsUnsafe(resumeItems, state).finally(syncResumeState)
      📝 Committable suggestion

      ‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

      Suggested change
      331- const resumeInterruptsUnsafe = (
      332- resumeItems: Array<RunAgentResumeItem>,
      333- state?: ChatResumeState,
      334- ) => client().resumeInterruptsUnsafe(resumeItems, state)
      331+ const resumeInterruptsUnsafe = (
      332+ resumeItems: Array<RunAgentResumeItem>,
      333+ state?: ChatResumeState,
      334+ ) => client().resumeInterruptsUnsafe(resumeItems, state).finally(syncResumeState)
      🤖 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/ai-solid/src/use-chat.ts` around lines 331 - 334, Update
      resumeInterruptsUnsafe to await the underlying client().resumeInterruptsUnsafe
      call, then invoke syncResumeState() after it settles, matching the other
      resume/interrupt-affecting methods and keeping its existing arguments and return
      behavior.
      @@ -33,4 +33,6 @@
      3333 queue?: Array<QueuedMessage>
      3434 /** Remove a queued message before it drains. */
      3535 cancelQueued?: (id: string) => void
      36+ /** Block new input while pending interrupts await resolution. */
      37+ hasPendingInterrupt?: boolean
      3638 }
      coderabbitai[bot](GitHub profile, opens in a new tab)commented

      🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

      Send button stays enabled while hasPendingInterrupt is true.

      handleSubmit correctly no-ops when hasPendingInterrupt, but the Send button's disabled={!input.trim()} (line 287) doesn't factor in the new flag, so it remains clickable. Since this component drives e2e assertions, a spec checking for a disabled Send button during a pending interrupt would fail even though submission is safely blocked.

      🛠️ Suggested fix
      -          disabled={!input.trim()}
      +          disabled={!input.trim() || hasPendingInterrupt}

      Also applies to: 52-52, 64-69

      🤖 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/src/components/ChatUI.tsx` around lines 36 - 38, Update the Send
      button’s disabled condition in ChatUI to include hasPendingInterrupt, so it is
      disabled when an interrupt is pending or the input is empty. Keep handleSubmit’s
      existing no-op guard and apply the same pending-interrupt state consistently to
      the other affected input controls.
      @@ -10,4 +10,4 @@
      1010 import { providersFor } from './test-matrix'
      1111
      1212 for (const provider of providersFor('tool-approval')) {
      13- test.describe(`${provider} — tool-approval`, () => {
      13+ test.describe(`${provider} — tool-approval`, () => {
      coderabbitai[bot](GitHub profile, opens in a new tab)commented

      📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

      Restore the suite-title encoding.

      The title contains — instead of the intended em dash —, which degrades Playwright report readability.

      Proposed fix
      -  test.describe(`${provider} — tool-approval`, () => {
      +  test.describe(`${provider} — tool-approval`, () => {
      📝 Committable suggestion

      ‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

      Suggested change
      13- test.describe(`${provider} — tool-approval`, () => {
      13+ test.describe(`${provider} — tool-approval`, () => {
      🤖 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/tool-approval.spec.ts` at line 13, Update the suite title
      in the tool-approval test.describe declaration to use the intended em dash
      character (—) instead of the mojibake sequence (—); preserve the existing
      provider interpolation and title text.
    7. Actionable comments posted: 9

      ♻️ Duplicate comments (1)
      testing/e2e/tests/tool-approval.spec.ts (1)

      13-13: 📐 Maintainability & Code Quality | 🟡 Minor | 💤 Low value

      Restore the suite-title encoding.

      The title contains — instead of the intended em dash —, which degrades Playwright report readability.

      🛠️ Proposed fix
      -  test.describe(`${provider} — tool-approval`, () => {
      +  test.describe(`${provider} — tool-approval`, () => {
      🤖 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/tool-approval.spec.ts` at line 13, Restore the intended em
      dash character in the suite title template within the tool-approval
      test.describe declaration, replacing the mojibake `—` while preserving the
      provider interpolation and remaining title text.
      🧹 Nitpick comments (3)
      packages/ai-react/src/use-chat.ts (1)

      421-432: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

      Dead branching in resolveInterrupts — both arms are identical.

      The typeof resolution === 'boolean' check has no effect; both branches call client.resolveInterrupts(resolution) with no distinction. Simplify by removing the conditional.

      ♻️ Suggested simplification
         const resolveInterrupts = useCallback(
           (
             resolution: boolean | ((interrupt: ChatInterrupt<TTools>) => undefined),
           ) => {
      -      if (typeof resolution === 'boolean') {
      -        client.resolveInterrupts(resolution)
      -      } else {
      -        client.resolveInterrupts(resolution)
      -      }
      +      client.resolveInterrupts(resolution)
           },
           [client],
         )
      🤖 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/ai-react/src/use-chat.ts` around lines 421 - 432, Remove the
      redundant typeof resolution conditional in resolveInterrupts and directly call
      client.resolveInterrupts(resolution), preserving the existing callback signature
      and client dependency.
      packages/ai-react/src/types.ts (1)

      210-213: 📐 Maintainability & Code Quality | 🔵 Trivial

      Resolver return type => undefined is stricter than typical callback typing.

      Typing the function-resolver branch as (interrupt: ChatInterrupt<TTools>) => undefined forces callers' arrow functions to literally evaluate to undefined; any other return value (even though it's discarded at runtime) will fail type-checking. Consider => void instead, which is the idiomatic TS pattern for callbacks whose return value is intentionally ignored, unless there's a good reason to hard-enforce undefined here.

      ♻️ Suggested typing change
         resolveInterrupts: {
           (approved: boolean): void
      -    (resolver: (interrupt: ChatInterrupt<TTools>) => undefined): void
      +    (resolver: (interrupt: ChatInterrupt<TTools>) => void): void
         }
      🤖 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/ai-react/src/types.ts` around lines 210 - 213, Update the
      function-resolver overload in resolveInterrupts to accept callbacks returning
      void instead of requiring a literal undefined return. Keep the approved boolean
      overload unchanged and preserve the existing ChatInterrupt<TTools> parameter
      type.
      docs/interrupts/generic.md (1)

      14-104: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

      Page shows only the client-side flow; no server-side snippet for emitting a generic interrupt.

      This page documents both the concept and a full client rendering example for generic interrupts, but never shows how a server route actually emits one (the responseSchema/interrupt outcome). Per docs guidelines, pages that "cover both server and client behavior" should include snippets for both halves — docs/architecture/approval-flow-processing.md does this for tool approvals (Server setup + client UI sections), but this page has no equivalent server example.

      As per coding guidelines, "When a documentation page covers both server and client behavior, include snippets for both halves: the server endpoint and the client consumption."

      🤖 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/interrupts/generic.md` around lines 14 - 104, Add a concise server-side
      example before or alongside the client section showing how a server route emits
      a generic interrupt outcome, including a JSON-compatible responseSchema and
      interrupt message/reason, then resumes or processes the submitted value
      server-side. Keep the existing GenericInterruptForm and GenericInterrupts client
      flow unchanged, and use the established generic interrupt/server API symbols
      from the codebase rather than inventing a separate protocol.

      Source: Coding guidelines

      🤖 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/functions/toolDefinition.md`:
      - Around line 146-159: Mark the new resolveInterrupt example block in the
      documentation as non-type-checked by changing its TypeScript fence to the
      project’s `ts ignore` convention. Keep the existing branch-specific
      resolveInterrupt examples unchanged.
      
      In `@examples/ts-react-chat/src/routes/generations.structured-chat.tsx`:
      - Line 243: Annotate the recipe variable in the structured chat generation flow
      as Partial<Recipe> while retaining the existing part.data, part.partial, and
      empty-object fallback behavior, so later property access such as recipe.cuisine
      remains type-safe.
      
      In `@examples/ts-react-chat/src/routes/generations.structured-output.tsx`:
      - Line 236: Restore the type assertion on payload.value.object in the setResult
      call within the streaming result update flow, casting it to the state’s expected
      PartialResult-compatible type so the unknown StreamChunkPayload value satisfies
      SetStateAction<PartialResult | null>.
      
      In `@packages/ai-angular/src/inject-chat.ts`:
      - Around line 275-278: Update the pendingInterrupts computed selector to return
      interruptState().pendingInterrupts instead of interruptState().interrupts. Keep
      the interrupts, interruptErrors, and resuming selectors unchanged so
      hasPendingInterrupt and approval-gating flows receive only pending interrupts.
      
      In `@packages/ai-preact/src/use-chat.ts`:
      - Around line 58-65: Initialize interruptState from the initial resume snapshot
      synchronously, matching resumeState and the Angular/Svelte hooks. Update the
      useState initializer around interruptState to derive its value from the newly
      constructed client’s getInterruptState() rather than hardcoded empty arrays,
      while preserving the existing resuming and interrupt error state.
      
      In `@packages/ai-svelte/tests/create-chat-types.test.ts`:
      - Around line 232-233: Remove the duplicate Generic type alias declaration in
      the test scope, retaining a single `type Generic = Extract<Interrupt, { kind:
      'generic' }>` definition so the file typechecks without changing its usage.
      
      In `@packages/ai/src/activities/chat/tools/approval-schema.ts`:
      - Around line 198-205: Update hashSchemaInput so non-JSON-convertible schemas do
      not all use the constant standardValidator identity. Preserve the
      undefined-schema hash behavior, but for schemas where
      schemaToWire(schema).jsonSchema is absent, either reject hashing explicitly or
      derive the identity from schema-specific stable metadata such as vendor and a
      caller-supplied version/id, ensuring schema changes produce different hashes for
      interrupt resume drift checks.
      
      In `@packages/ai/src/activities/chat/tools/json-schema-validator.ts`:
      - Around line 105-138: Refactor compileJsonSchema202012 to reuse a module-scoped
      Ajv2020 instance with the existing options and full-format registration, rather
      than constructing Ajv2020 and calling addFormats on every invocation. Keep
      schema compilation and JsonSchemaCompilationError handling within
      compileJsonSchema202012, using the shared instance to compile each independent
      schema.
      
      In `@packages/ai/src/activities/chat/tools/tool-calls.ts`:
      - Around line 455-461: Preserve explicit null tool-argument edits by updating
      editedApprovalArgs to return a wrapper such as { value: unknown } when the
      approved resolution has its own editedArgs property, including null, and
      undefined otherwise. At packages/ai/src/activities/chat/tools/tool-calls.ts
      lines 455-461, check for the editedArgs property explicitly; at lines 845-852
      and 917-924, replace nullish-coalescing fallback with the wrapper-unwrapping
      logic so input is updated whenever an edit exists, including an intentional
      null.
      
      ---
      
      Duplicate comments:
      In `@testing/e2e/tests/tool-approval.spec.ts`:
      - Line 13: Restore the intended em dash character in the suite title template
      within the tool-approval test.describe declaration, replacing the mojibake `—`
      while preserving the provider interpolation and remaining title text.
      
      ---
      
      Nitpick comments:
      In `@docs/interrupts/generic.md`:
      - Around line 14-104: Add a concise server-side example before or alongside the
      client section showing how a server route emits a generic interrupt outcome,
      including a JSON-compatible responseSchema and interrupt message/reason, then
      resumes or processes the submitted value server-side. Keep the existing
      GenericInterruptForm and GenericInterrupts client flow unchanged, and use the
      established generic interrupt/server API symbols from the codebase rather than
      inventing a separate protocol.
      
      In `@packages/ai-react/src/types.ts`:
      - Around line 210-213: Update the function-resolver overload in
      resolveInterrupts to accept callbacks returning void instead of requiring a
      literal undefined return. Keep the approved boolean overload unchanged and
      preserve the existing ChatInterrupt<TTools> parameter type.
      
      In `@packages/ai-react/src/use-chat.ts`:
      - Around line 421-432: Remove the redundant typeof resolution conditional in
      resolveInterrupts and directly call client.resolveInterrupts(resolution),
      preserving the existing callback signature and client dependency.
      🪄 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: 300877ad-3d76-45c8-be03-b57ded65d2e7

      📥 Commits

      Reviewing files that changed from the base of the PR and between 7c7aa09a7402b45e6285ebc78a606131aec3e288 and 0883ecbfee62dafd806e77e8a0422411d38d780e.

      ⛔ Files ignored due to path filters (1)
      • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
      📒 Files selected for processing (268)
      • .changeset/ag-ui-interrupts.md
      • docs/architecture/approval-flow-processing.md
      • docs/config.json
      • docs/interrupts/generic.md
      • docs/interrupts/migration.md
      • docs/interrupts/multiple.md
      • docs/interrupts/overview.md
      • docs/interrupts/tool-approval.md
      • docs/reference/functions/toolDefinition.md
      • docs/tools/client-tools.md
      • docs/tools/tool-approval.md
      • examples/ts-code-mode-web/src/routes/_database-demo/api.database-demo.ts
      • examples/ts-react-chat/.env.example
      • examples/ts-react-chat/README.md
      • examples/ts-react-chat/package.json
      • examples/ts-react-chat/src/components/Header.tsx
      • examples/ts-react-chat/src/lib/guitar-tools.ts
      • examples/ts-react-chat/src/lib/interrupt-lab/InterruptLabPage.tsx
      • examples/ts-react-chat/src/lib/interrupt-lab/client-ui.test.ts
      • examples/ts-react-chat/src/lib/interrupt-lab/client-ui.ts
      • examples/ts-react-chat/src/lib/interrupt-lab/scenarios.ts
      • examples/ts-react-chat/src/lib/interrupt-lab/server.test.ts
      • examples/ts-react-chat/src/lib/interrupt-lab/server.ts
      • examples/ts-react-chat/src/lib/realtime-tools.ts
      • examples/ts-react-chat/src/lib/server-audio-adapters.ts
      • examples/ts-react-chat/src/lib/server-fns.ts
      • examples/ts-react-chat/src/routeTree.gen.ts
      • examples/ts-react-chat/src/routes/api.generate.image.ts
      • examples/ts-react-chat/src/routes/api.generate.video.ts
      • examples/ts-react-chat/src/routes/api.interrupts.ts
      • examples/ts-react-chat/src/routes/api.mcp-apps-call.ts
      • examples/ts-react-chat/src/routes/api.mcp-manual.ts
      • examples/ts-react-chat/src/routes/api.mcp-pool.ts
      • examples/ts-react-chat/src/routes/api.structured-output.ts
      • examples/ts-react-chat/src/routes/api.tanchat.ts
      • examples/ts-react-chat/src/routes/example.runtime-context.tsx
      • examples/ts-react-chat/src/routes/generation-hooks.tsx
      • examples/ts-react-chat/src/routes/generations.audio.tsx
      • examples/ts-react-chat/src/routes/generations.image.tsx
      • examples/ts-react-chat/src/routes/generations.speech.tsx
      • examples/ts-react-chat/src/routes/generations.structured-chat.tsx
      • examples/ts-react-chat/src/routes/generations.structured-output.tsx
      • examples/ts-react-chat/src/routes/generations.summarize.tsx
      • examples/ts-react-chat/src/routes/generations.video.tsx
      • examples/ts-react-chat/src/routes/image-tool-repro.tsx
      • examples/ts-react-chat/src/routes/interrupts.tsx
      • examples/ts-react-chat/src/routes/issue-176-tool-result.tsx
      • examples/ts-react-chat/src/routes/mcp-apps.tsx
      • examples/ts-react-chat/src/routes/mcp-demo.tsx
      • examples/ts-react-chat/src/routes/realtime.tsx
      • examples/ts-react-chat/src/routes/threads.tsx
      • packages/ai-acp/tests/compatible.test.ts
      • packages/ai-acp/tests/sandbox-provisioning.test.ts
      • packages/ai-angular/package.json
      • packages/ai-angular/src/inject-chat.ts
      • packages/ai-angular/src/inject-generate-audio.ts
      • packages/ai-angular/src/inject-generate-image.ts
      • packages/ai-angular/src/inject-generate-speech.ts
      • packages/ai-angular/src/inject-generate-video.ts
      • packages/ai-angular/src/inject-generation.ts
      • packages/ai-angular/src/inject-summarize.ts
      • packages/ai-angular/src/inject-transcription.ts
      • packages/ai-angular/src/types.ts
      • packages/ai-angular/tests/inject-audio-recorder.test.ts
      • packages/ai-angular/tests/inject-chat-types.test.ts
      • packages/ai-angular/tests/inject-chat.test.ts
      • packages/ai-angular/tests/inject-generation.test.ts
      • packages/ai-angular/tests/test-utils.ts
      • packages/ai-anthropic/tests/anthropic-adapter.test.ts
      • packages/ai-client/package.json
      • packages/ai-client/src/chat-client.ts
      • packages/ai-client/src/chat-persistence-controller.ts
      • packages/ai-client/src/cleared-stream-tracker.ts
      • packages/ai-client/src/client-persistor.ts
      • packages/ai-client/src/connection-adapters.ts
      • packages/ai-client/src/generation-client.ts
      • packages/ai-client/src/generation-types.ts
      • packages/ai-client/src/index.ts
      • packages/ai-client/src/interrupt-manager.ts
      • packages/ai-client/src/interrupt-recovery-parse.ts
      • packages/ai-client/src/storage-adapters.ts
      • packages/ai-client/src/types.ts
      • packages/ai-client/src/video-generation-client.ts
      • packages/ai-client/tests/chat-client-interrupt-correlation.test.ts
      • packages/ai-client/tests/chat-client-interrupts.test.ts
      • packages/ai-client/tests/chat-client-resume.test.ts
      • packages/ai-client/tests/chat-client.test.ts
      • packages/ai-client/tests/chat-persistence-controller.test.ts
      • packages/ai-client/tests/cleared-stream-tracker.test.ts
      • packages/ai-client/tests/client-persistor.test.ts
      • packages/ai-client/tests/connection-adapters-xhr.test.ts
      • packages/ai-client/tests/generation-client.test.ts
      • packages/ai-client/tests/generation-resume-state.test.ts
      • packages/ai-client/tests/interrupts-types.test-d.ts
      • packages/ai-client/tests/storage-adapters-types.test-d.ts
      • packages/ai-client/tests/storage-adapters.test.ts
      • packages/ai-client/tests/test-utils.ts
      • packages/ai-event-client/src/index.ts
      • packages/ai-event-client/tests/emit.test.ts
      • packages/ai-event-client/tests/generation-events-types.test-d.ts
      • packages/ai-gemini/tests/text-interactions-adapter.test.ts
      • packages/ai-openrouter/tests/openrouter-responses-adapter.test.ts
      • packages/ai-preact/src/types.ts
      • packages/ai-preact/src/use-chat.ts
      • packages/ai-preact/tests/mcp-apps.test.tsx
      • packages/ai-preact/tests/test-utils.ts
      • packages/ai-preact/tests/use-chat-types.test.ts
      • packages/ai-preact/tests/use-chat.test.ts
      • packages/ai-react/src/types.ts
      • packages/ai-react/src/use-chat.ts
      • packages/ai-react/src/use-generate-audio.ts
      • packages/ai-react/src/use-generate-image.ts
      • packages/ai-react/src/use-generate-speech.ts
      • packages/ai-react/src/use-generate-video.ts
      • packages/ai-react/src/use-generation.ts
      • packages/ai-react/src/use-summarize.ts
      • packages/ai-react/src/use-transcription.ts
      • packages/ai-react/tests/mcp-apps.test.tsx
      • packages/ai-react/tests/test-utils.ts
      • packages/ai-react/tests/use-chat-fetcher.test.ts
      • packages/ai-react/tests/use-chat-options-probe.test.ts
      • packages/ai-react/tests/use-chat-structured-output.test.ts
      • packages/ai-react/tests/use-chat-types.test.ts
      • packages/ai-react/tests/use-chat.test.ts
      • packages/ai-react/tests/use-generation.test.ts
      • packages/ai-solid/src/types.ts
      • packages/ai-solid/src/use-chat.ts
      • packages/ai-solid/src/use-generate-audio.ts
      • packages/ai-solid/src/use-generate-image.ts
      • packages/ai-solid/src/use-generate-speech.ts
      • packages/ai-solid/src/use-generate-video.ts
      • packages/ai-solid/src/use-generation.ts
      • packages/ai-solid/src/use-summarize.ts
      • packages/ai-solid/src/use-transcription.ts
      • packages/ai-solid/tests/test-utils.ts
      • packages/ai-solid/tests/use-chat-types.test.ts
      • packages/ai-solid/tests/use-chat.test.ts
      • packages/ai-solid/tests/use-generation.test.ts
      • packages/ai-svelte/src/create-chat.svelte.ts
      • packages/ai-svelte/src/create-generate-audio.svelte.ts
      • packages/ai-svelte/src/create-generate-image.svelte.ts
      • packages/ai-svelte/src/create-generate-speech.svelte.ts
      • packages/ai-svelte/src/create-generate-video.svelte.ts
      • packages/ai-svelte/src/create-generation.svelte.ts
      • packages/ai-svelte/src/create-summarize.svelte.ts
      • packages/ai-svelte/src/create-transcription.svelte.ts
      • packages/ai-svelte/src/types.ts
      • packages/ai-svelte/tests/create-chat-types.test.ts
      • packages/ai-svelte/tests/create-generation.test.ts
      • packages/ai-svelte/tests/test-utils.ts
      • packages/ai-svelte/tests/use-chat.test.ts
      • packages/ai-utils/src/base64.ts
      • packages/ai-utils/src/index.ts
      • packages/ai-utils/tests/base64.test.ts
      • packages/ai-vue/src/types.ts
      • packages/ai-vue/src/use-chat.ts
      • packages/ai-vue/src/use-generate-audio.ts
      • packages/ai-vue/src/use-generate-image.ts
      • packages/ai-vue/src/use-generate-speech.ts
      • packages/ai-vue/src/use-generate-video.ts
      • packages/ai-vue/src/use-generation.ts
      • packages/ai-vue/src/use-summarize.ts
      • packages/ai-vue/src/use-transcription.ts
      • packages/ai-vue/tests/test-utils.ts
      • packages/ai-vue/tests/use-chat-types.test.ts
      • packages/ai-vue/tests/use-chat.test.ts
      • packages/ai-vue/tests/use-generation.test.ts
      • packages/ai/package.json
      • packages/ai/skills/ai-core/tool-calling/SKILL.md
      • packages/ai/src/activities/chat/index.ts
      • packages/ai/src/activities/chat/mcp/manager.ts
      • packages/ai/src/activities/chat/mcp/types.ts
      • packages/ai/src/activities/chat/messages.ts
      • packages/ai/src/activities/chat/middleware/index.ts
      • packages/ai/src/activities/chat/middleware/types.ts
      • packages/ai/src/activities/chat/stream/processor.ts
      • packages/ai/src/activities/chat/tools/approval-schema.ts
      • packages/ai/src/activities/chat/tools/json-schema-validator.ts
      • packages/ai/src/activities/chat/tools/tool-calls.ts
      • packages/ai/src/activities/chat/tools/tool-definition.ts
      • packages/ai/src/activities/generateAudio/index.ts
      • packages/ai/src/activities/generateImage/index.ts
      • packages/ai/src/activities/generateSpeech/index.ts
      • packages/ai/src/activities/generateTranscription/index.ts
      • packages/ai/src/activities/generateVideo/index.ts
      • packages/ai/src/activities/generation-run.ts
      • packages/ai/src/activities/middleware/index.ts
      • packages/ai/src/activities/middleware/run.ts
      • packages/ai/src/activities/middleware/types.ts
      • packages/ai/src/activities/stream-generation-result.ts
      • packages/ai/src/client.ts
      • packages/ai/src/custom-events.ts
      • packages/ai/src/index.ts
      • packages/ai/src/interrupt-resume.ts
      • packages/ai/src/interrupt-serialization.ts
      • packages/ai/src/interrupts.ts
      • packages/ai/src/stream-to-response.ts
      • packages/ai/src/types.ts
      • packages/ai/src/utilities/chat-params.ts
      • packages/ai/tests/ag-ui-wire.test.ts
      • packages/ai/tests/agent-loop-strategies.test.ts
      • packages/ai/tests/chat-mcp-manager.test.ts
      • packages/ai/tests/chat-params.test.ts
      • packages/ai/tests/chat-structured-output-null-normalization.test.ts
      • packages/ai/tests/chat-structured-output-stream.test.ts
      • packages/ai/tests/chat.test.ts
      • packages/ai/tests/content-guard-middleware.test.ts
      • packages/ai/tests/custom-events.test.ts
      • packages/ai/tests/debug-logging-chat.test.ts
      • packages/ai/tests/devtools-system-prompt-mirror.test.ts
      • packages/ai/tests/extend-adapter.test.ts
      • packages/ai/tests/generation-params.test.ts
      • packages/ai/tests/generation-result-transforms.test.ts
      • packages/ai/tests/generation-run-identity-replay.test.ts
      • packages/ai/tests/interrupts-types.test-d.ts
      • packages/ai/tests/interrupts.test.ts
      • packages/ai/tests/lazy-tool-manager.test.ts
      • packages/ai/tests/message-updaters.test.ts
      • packages/ai/tests/messages.test.ts
      • packages/ai/tests/middleware.test.ts
      • packages/ai/tests/middlewares/otel.test.ts
      • packages/ai/tests/multimodal-tool-result.test.ts
      • packages/ai/tests/strategies.test.ts
      • packages/ai/tests/stream-generation.test.ts
      • packages/ai/tests/stream-processor.test.ts
      • packages/ai/tests/stream-to-response.test.ts
      • packages/ai/tests/summarize-max-length.test.ts
      • packages/ai/tests/system-prompts.test.ts
      • packages/ai/tests/test-utils.ts
      • packages/ai/tests/tool-cache-middleware.test.ts
      • packages/ai/tests/tool-call-manager.test.ts
      • packages/ai/tests/tool-calls-null-input.test.ts
      • packages/ai/tests/tool-definition.test.ts
      • packages/ai/tests/tool-result.test.ts
      • packages/ai/tests/type-check.test.ts
      • packages/ai/tests/usage-cost-types.test.ts
      • pnpm-workspace.yaml
      • testing/e2e/src/components/AudioGenUI.tsx
      • testing/e2e/src/components/ChatUI.tsx
      • testing/e2e/src/components/ImageGenUI.tsx
      • testing/e2e/src/components/TTSUI.tsx
      • testing/e2e/src/components/TranscriptionUI.tsx
      • testing/e2e/src/components/VideoGenUI.tsx
      • testing/e2e/src/lib/feature-support.ts
      • testing/e2e/src/lib/features.ts
      • testing/e2e/src/lib/media-providers.ts
      • testing/e2e/src/lib/types.ts
      • testing/e2e/src/routes/$provider/$feature.tsx
      • testing/e2e/src/routes/$provider/index.tsx
      • testing/e2e/src/routes/api.audio.stream.ts
      • testing/e2e/src/routes/api.audio.ts
      • testing/e2e/src/routes/api.chat.ts
      • testing/e2e/src/routes/api.image.stream.ts
      • testing/e2e/src/routes/api.image.ts
      • testing/e2e/src/routes/api.middleware-test.ts
      • testing/e2e/src/routes/api.multimodal-tool-result-wire.ts
      • testing/e2e/src/routes/api.openai-shell-skills-wire.ts
      • testing/e2e/src/routes/api.openrouter-web-tools-wire.ts
      • testing/e2e/src/routes/api.otel-usage.ts
      • testing/e2e/src/routes/api.tools-test.ts
      • testing/e2e/src/routes/api.tts.stream.ts
      • testing/e2e/src/routes/api.tts.ts
      • testing/e2e/src/routes/api.video.stream.ts
      • testing/e2e/src/routes/api.video.ts
      • testing/e2e/src/routes/devtools-generation-hooks.tsx
      • testing/e2e/src/routes/middleware-test.tsx
      • testing/e2e/src/routes/tools-test.tsx
      • testing/e2e/tests/tool-approval.spec.ts
      💤 Files with no reviewable changes (4)
      • packages/ai-client/src/client-persistor.ts
      • packages/ai-client/tests/client-persistor.test.ts
      • examples/ts-react-chat/src/routes/realtime.tsx
      • packages/ai/src/stream-to-response.ts
      @@ -239,4 +240,4 @@
      239240 // Read whichever is freshest — they converge once `status === 'complete'`.
      240241 // Both fields are typed via the schema, so `recipe.title` etc. accesses
      241242 // below are checked at compile time.
      242- const recipe = part.data ?? part.partial ?? ({} as Partial<Recipe>)
      243+ const recipe = part.data ?? part.partial ?? {}
      coderabbitai[bot](GitHub profile, opens in a new tab)commented

      🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

      Fix TypeScript inference for the fallback object.

      Removing the as Partial<Recipe> cast is good, but without an explicit type annotation on the variable, TypeScript infers the fallback {} as an empty object type. Accessing properties like recipe.cuisine later will cause a type error under strict mode because {} has no properties.

      Explicitly annotating the variable as Partial<Recipe> resolves the type error safely.

      💻 Proposed fix
      -  const recipe = part.data ?? part.partial ?? {}
      +  const recipe: Partial<Recipe> = part.data ?? part.partial ?? {}
      📝 Committable suggestion

      ‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

      Suggested change
      243- const recipe = part.data ?? part.partial ?? {}
      243+ const recipe: Partial<Recipe> = part.data ?? part.partial ?? {}
      🤖 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 `@examples/ts-react-chat/src/routes/generations.structured-chat.tsx` at line
      243, Annotate the recipe variable in the structured chat generation flow as
      Partial<Recipe> while retaining the existing part.data, part.partial, and
      empty-object fallback behavior, so later property access such as recipe.cuisine
      remains type-safe.
      @@ -240,3 +272,7 @@
      240272 }) => {
      241273 await client.addToolApprovalResponse(response)
      242274 }
      275+ const interrupts = computed(() => interruptState().interrupts)
      276+ const pendingInterrupts = computed(() => interruptState().interrupts)
      277+ const interruptErrors = computed(() => interruptState().interruptErrors)
      278+ const resuming = computed(() => interruptState().resuming)
      coderabbitai[bot](GitHub profile, opens in a new tab)commented

      🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

      pendingInterrupts selector returns the wrong field.

      Line 276 reads interruptState().interrupts instead of interruptState().pendingInterrupts. Per the ChatInterruptState contract (interrupts, pendingInterrupts, interruptErrors, resuming are distinct fields), this makes the exposed pendingInterrupts signal identical to interrupts — consumers gating UI on "still awaiting resolution" interrupts will see already-resolved ones too, breaking approval-gating flows that this PR's ChatUI relies on (hasPendingInterrupt).

      🐛 Proposed fix
      -  const pendingInterrupts = computed(() => interruptState().interrupts)
      +  const pendingInterrupts = computed(() => interruptState().pendingInterrupts)
      📝 Committable suggestion

      ‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

      Suggested change
      275- const interrupts = computed(() => interruptState().interrupts)
      276- const pendingInterrupts = computed(() => interruptState().interrupts)
      277- const interruptErrors = computed(() => interruptState().interruptErrors)
      278- const resuming = computed(() => interruptState().resuming)
      275+ const interrupts = computed(() => interruptState().interrupts)
      276+ const pendingInterrupts = computed(() => interruptState().pendingInterrupts)
      277+ const interruptErrors = computed(() => interruptState().interruptErrors)
      278+ const resuming = computed(() => interruptState().resuming)
      🤖 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/ai-angular/src/inject-chat.ts` around lines 275 - 278, Update the
      pendingInterrupts computed selector to return interruptState().pendingInterrupts
      instead of interruptState().interrupts. Keep the interrupts, interruptErrors,
      and resuming selectors unchanged so hasPendingInterrupt and approval-gating
      flows receive only pending interrupts.
      @@ -42,3 +52,14 @@
      4252 useState<ConnectionStatus>('disconnected')
      4353 const [sessionGenerating, setSessionGenerating] = useState(false)
      4454 const [queue, setQueue] = useState<Array<QueuedMessage>>([])
      55+ const [resumeState, setResumeState] = useState<ChatResumeState | null>(
      56+ options.initialResumeSnapshot?.resumeState ?? null,
      57+ )
      58+ const [interruptState, setInterruptState] = useState<
      59+ ChatInterruptState<TTools>
      60+ >(() => ({
      61+ interrupts: EMPTY_INTERRUPTS,
      62+ pendingInterrupts: EMPTY_INTERRUPTS,
      63+ interruptErrors: EMPTY_INTERRUPT_ERRORS,
      64+ resuming: false,
      65+ }))
      coderabbitai[bot](GitHub profile, opens in a new tab)commented

      🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

      interruptState isn't seeded from initialResumeSnapshot, unlike resumeState.

      resumeState correctly bootstraps from options.initialResumeSnapshot?.resumeState (line 56), but interruptState is always initialized to empty arrays regardless of a supplied resume snapshot. It only gets corrected once the mount useEffect calls syncResumeState(client) (line 295), so the first render shows no pending interrupts even when one was supplied.

      Contrast with packages/ai-angular/tests/inject-chat.test.ts and packages/ai-svelte/tests/use-chat.test.ts (both in this PR): both assert interrupts reflects the staged/error interrupts from initialResumeSnapshot immediately, with no flush()/tick() beforehand — i.e., siblings project this state synchronously, this hook does not.

      Based on the Angular and Svelte test expectations for synchronous interrupt-state projection from initialResumeSnapshot (packages/ai-angular/tests/inject-chat.test.ts lines 23-51, packages/ai-svelte/tests/use-chat.test.ts lines 21-48), this hook should seed interruptState the same way, likely by deriving the initial value from the newly constructed client.getInterruptState() rather than a hardcoded empty default.

      🤖 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/ai-preact/src/use-chat.ts` around lines 58 - 65, Initialize
      interruptState from the initial resume snapshot synchronously, matching
      resumeState and the Angular/Svelte hooks. Update the useState initializer around
      interruptState to derive its value from the newly constructed client’s
      getInterruptState() rather than hardcoded empty arrays, while preserving the
      existing resuming and interrupt error state.
      @@ -138,0 +213,21 @@
      213+ name: 'confirm',
      214+ description: 'Confirm without schemas',
      215+ needsApproval: true,
      216+ }).client()
      217+ const lookup = toolDefinition({
      218+ name: 'lookup',
      219+ description: 'Lookup account',
      220+ outputSchema,
      221+ }).client(() => ({ accountId: 'account-1' }))
      222+ const tools = clientTools(transfer, confirm, lookup)
      223+ type Interrupt = CreateChatReturn<typeof tools>['interrupts'][number]
      224+ type Transfer = Extract<
      225+ Interrupt,
      226+ { kind: 'tool-approval'; toolName: 'transfer' }
      227+ >
      228+ type Confirm = Extract<
      229+ Interrupt,
      230+ { kind: 'tool-approval'; toolName: 'confirm' }
      231+ >
      232+ type Generic = Extract<Interrupt, { kind: 'generic' }>
      233+
      coderabbitai[bot](GitHub profile, opens in a new tab)commented

      🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

      Duplicate type Generic declaration — compile error.

      type Generic = Extract<Interrupt, { kind: 'generic' }> is declared twice in the same scope, which TypeScript rejects as a duplicate identifier and will fail typecheck.

      🐛 Proposed fix
           type Generic = Extract<Interrupt, { kind: 'generic' }>
      -    type Generic = Extract<Interrupt, { kind: 'generic' }>
      📝 Committable suggestion

      ‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

      Suggested change
      232- type Generic = Extract<Interrupt, { kind: 'generic' }>
      233-
      232+ type Generic = Extract<Interrupt, { kind: 'generic' }>
      🤖 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/ai-svelte/tests/create-chat-types.test.ts` around lines 232 - 233,
      Remove the duplicate Generic type alias declaration in the test scope, retaining
      a single `type Generic = Extract<Interrupt, { kind: 'generic' }>` definition so
      the file typechecks without changing its usage.
      @@ -0,0 +185,21 @@
      185+ const approvalCanonical = canonicalInterruptJson({
      186+ approve: approve?.jsonSchema ?? null,
      187+ reject: reject?.jsonSchema ?? null,
      188+ })
      189+
      190+ return {
      191+ branches: { approve, reject },
      192+ responseSchema,
      193+ responseSchemaHash: digestInterruptJson(responseCanonical),
      194+ approvalSchemaHash: digestInterruptJson(approvalCanonical),
      195+ }
      196+}
      197+
      198+export function hashSchemaInput(schema: SchemaInput | undefined): string {
      199+ if (schema === undefined) return digestInterruptJson('undefined')
      200+ const normalized = schemaToWire(schema)
      201+ const identity = normalized.jsonSchema ?? {
      202+ standardValidator: 'unserialized',
      203+ }
      204+ return digestInterruptJson(canonicalInterruptJson(identity))
      205+}
      coderabbitai[bot](GitHub profile, opens in a new tab)commented

      🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift

      hashSchemaInput collapses all non-JSON-convertible schemas to the same hash, defeating drift detection.

      When schemaToWire(schema).jsonSchema is undefined (a StandardSchemaV1 that doesn't implement the JSON Schema extension), the identity used for hashing falls back to the constant { standardValidator: 'unserialized' }. Every such schema — regardless of actual shape — hashes to the exact same sha256:... value.

      This is consumed in interrupt-resume.ts to detect schema drift: hashSchemaInput(tool.inputSchema) !== binding.inputSchemaHash (line 409) and hashSchemaInput(tool.outputSchema) !== binding.outputSchemaHash (line 377). For any tool whose input/output schema is a non-JSON-convertible standard schema, these checks can never fire — a tool's input/output schema could change entirely between the interrupt being issued and being resumed, and the "stale" detection would silently pass, letting resume proceed against a mismatched schema.

      🛡️ Suggested direction
       export function hashSchemaInput(schema: SchemaInput | undefined): string {
         if (schema === undefined) return digestInterruptJson('undefined')
         const normalized = schemaToWire(schema)
      -  const identity = normalized.jsonSchema ?? {
      -    standardValidator: 'unserialized',
      -  }
      +  if (normalized.jsonSchema === undefined) {
      +    throw new TypeError(
      +      'Schema drift detection requires a JSON-Schema-convertible SchemaInput.',
      +    )
      +  }
      +  const identity = normalized.jsonSchema
         return digestInterruptJson(canonicalInterruptJson(identity))
       }

      Alternatively, incorporate something schema-specific (e.g. vendor + a caller-supplied version/id) into the identity instead of throwing, if rejecting non-convertible schemas outright is too disruptive.

      📝 Committable suggestion

      ‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

      Suggested change
      198-export function hashSchemaInput(schema: SchemaInput | undefined): string {
      199- if (schema === undefined) return digestInterruptJson('undefined')
      200- const normalized = schemaToWire(schema)
      201- const identity = normalized.jsonSchema ?? {
      202- standardValidator: 'unserialized',
      203- }
      204- return digestInterruptJson(canonicalInterruptJson(identity))
      205-}
      198+export function hashSchemaInput(schema: SchemaInput | undefined): string {
      199+ if (schema === undefined) return digestInterruptJson('undefined')
      200+ const normalized = schemaToWire(schema)
      201+ if (normalized.jsonSchema === undefined) {
      202+ throw new TypeError(
      203+ 'Schema drift detection requires a JSON-Schema-convertible SchemaInput.',
      204+ )
      205+ }
      206+ const identity = normalized.jsonSchema
      207+ return digestInterruptJson(canonicalInterruptJson(identity))
      208+}
      🤖 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/ai/src/activities/chat/tools/approval-schema.ts` around lines 198 -
      205, Update hashSchemaInput so non-JSON-convertible schemas do not all use the
      constant standardValidator identity. Preserve the undefined-schema hash
      behavior, but for schemas where schemaToWire(schema).jsonSchema is absent,
      either reject hashing explicitly or derive the identity from schema-specific
      stable metadata such as vendor and a caller-supplied version/id, ensuring schema
      changes produce different hashes for interrupt resume drift checks.
      @@ -0,0 +118,21 @@
      118+ })
      119+ addFormats(ajv, { mode: 'full' })
      120+
      121+ let validate
      122+ try {
      123+ validate = ajv.compile(schema)
      124+ } catch (cause) {
      125+ throw new JsonSchemaCompilationError('Invalid Draft 2020-12 schema.', {
      126+ cause,
      127+ })
      128+ }
      129+
      130+ return (value) => {
      131+ if (validate(value)) return []
      132+ return (validate.errors ?? []).map((error) => ({
      133+ keyword: error.keyword,
      134+ message: error.message ?? 'Schema validation failed.',
      135+ path: issuePath(error),
      136+ }))
      137+ }
      138+}
      coderabbitai[bot](GitHub profile, opens in a new tab)commented

      🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win

      Reuse a single Ajv instance instead of constructing one per call.

      compileJsonSchema202012 builds a brand-new Ajv2020 and re-registers all formats (addFormats(..., { mode: 'full' })) on every invocation. This function sits in a hot path — validateInterruptResumeBatch calls it (via validateSchemaValue) up to several times per interrupt item (payload, edited args, tool output, approval envelope), and ai-client's canValidateGeneric calls it on every hydration attempt. Constructing a fresh Ajv instance each time is unnecessary overhead since Ajv instances safely compile multiple independent (anonymous) schemas.

      ⚡ Suggested fix
      +const ajv = new Ajv2020({
      +  allErrors: true,
      +  strict: true,
      +  strictRequired: false,
      +  allowUnionTypes: true,
      +  validateFormats: true,
      +  coerceTypes: false,
      +  useDefaults: false,
      +  removeAdditional: false,
      +})
      +addFormats(ajv, { mode: 'full' })
      +
       export function compileJsonSchema202012(
         schema: unknown,
       ): (value: unknown) => ReadonlyArray<JsonSchemaValidationIssue> {
         assertSupportedSchemaTree(schema)
      -  const ajv = new Ajv2020({
      -    allErrors: true,
      -    strict: true,
      -    strictRequired: false,
      -    allowUnionTypes: true,
      -    validateFormats: true,
      -    coerceTypes: false,
      -    useDefaults: false,
      -    removeAdditional: false,
      -  })
      -  addFormats(ajv, { mode: 'full' })
      -
         let validate
      📝 Committable suggestion

      ‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

      Suggested change
      105+const ajv = new Ajv2020({
      106+ allErrors: true,
      107+ strict: true,
      108+ strictRequired: false,
      109+ allowUnionTypes: true,
      110+ validateFormats: true,
      111+ coerceTypes: false,
      112+ useDefaults: false,
      113+ removeAdditional: false,
      114+})
      115+addFormats(ajv, { mode: 'full' })
      116+
      117+export function compileJsonSchema202012(
      118+ schema: unknown,
      119+): (value: unknown) => ReadonlyArray<JsonSchemaValidationIssue> {
      120+ assertSupportedSchemaTree(schema)
      121+
      122+ let validate
      123+ try {
      124+ validate = ajv.compile(schema)
      125+ } catch (cause) {
      126+ throw new JsonSchemaCompilationError('Invalid Draft 2020-12 schema.', {
      127+ cause,
      128+ })
      129+ }
      130+
      131+ return (value) => {
      132+ if (validate(value)) return []
      133+ return (validate.errors ?? []).map((error) => ({
      134+ keyword: error.keyword,
      135+ message: error.message ?? 'Schema validation failed.',
      136+ path: issuePath(error),
      137+ }))
      138+ }
      139+}
      🤖 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/ai/src/activities/chat/tools/json-schema-validator.ts` around lines
      105 - 138, Refactor compileJsonSchema202012 to reuse a module-scoped Ajv2020
      instance with the existing options and full-format registration, rather than
      constructing Ajv2020 and calling addFormats on every invocation. Keep schema
      compilation and JsonSchemaCompilationError handling within
      compileJsonSchema202012, using the shared instance to compile each independent
      schema.
    8. tombeckenham reviewed

      @@ -0,0 +30,21 @@
      30+This works **without persistence**. In the default ephemeral mode the server
      31+reconstructs and validates the expected batch from the submitted history and its
      32+current tool definitions. Durable persistence and authoritative recovery are an
      33+optional layer shipped separately with the persistence guides.
      34+
      35+## Kinds you resolve
      36+
      37+The bound `interrupts` array holds the pauses your app resolves:
      38+
      39+| `kind` | Meaning | Guide |
      40+| --- | --- | --- |
      41+| `tool-approval` | Approve or reject a tool call, optionally editing its args | [Tool Approval](./tool-approval) |
      42+| `generic` | Any application pause with a wire `responseSchema` | [Generic Interrupts](./generic) |
      43+
      44+**Client tools are not on this list.** Running a tool in the browser and
      45+returning its result is not something you resolve by hand — a tool with a
      46+`.client()` implementation runs automatically and reports its own result. See
      47+[Client Tools](../tools/client-tools). Approval is a separate axis: add
      48+`needsApproval: true` to any tool (server or client) and it pauses on a
      49+`tool-approval` interrupt first; a client tool then runs automatically once
      50+approved.
      tombeckenhamcommented

      Why aren't client tools included? That isn't explained here

    9. ♻️ Duplicate comments (1)
      docs/architecture/approval-flow-processing.md (1)

      139-139: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

      Use gpt-chat-latest in documentation examples instead of gpt-5.5.

      These documentation snippets use the superseded openaiText('gpt-5.5'). As per coding guidelines and previous reviews, switch them to the latest OpenAI chat model alias based on the adapter's model-meta.ts (e.g., gpt-chat-latest).

      • docs/architecture/approval-flow-processing.md#L139-L139: replace gpt-5.5 with gpt-chat-latest.
      • packages/ai/skills/ai-core/tool-calling/SKILL.md#L78-L78: replace gpt-5.5 with gpt-chat-latest.
      • packages/ai/skills/ai-core/tool-calling/SKILL.md#L681-L681: replace gpt-5.5 with gpt-chat-latest.
      🤖 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/architecture/approval-flow-processing.md` at line 139, Replace the
      superseded gpt-5.5 model name with gpt-chat-latest in the documentation examples
      at docs/architecture/approval-flow-processing.md:139-139,
      packages/ai/skills/ai-core/tool-calling/SKILL.md:78-78, and
      packages/ai/skills/ai-core/tool-calling/SKILL.md:681-681, preserving the
      existing adapter usage.

      Source: Coding guidelines

      🧹 Nitpick comments (1)
      testing/e2e/src/routes/tools-test.tsx (1)

      464-487: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

      Duplicate lookup/cast logic in Approve and Deny handlers.

      Both handlers repeat the exact same as ReadonlyArray<{...}> cast + .find() lookup for the matching tool-approval interrupt. The cast also erases whatever real (likely discriminated-union) type interrupts already has. Extract a shared helper using a type predicate instead of as so both call sites stay in sync and TypeScript actually narrows the result.

      ♻️ Proposed refactor
      +  function findApprovalInterrupt(toolCallId: string) {
      +    return interrupts.find(
      +      (item): item is Extract<typeof item, { kind: 'tool-approval' }> =>
      +        item.kind === 'tool-approval' && item.toolCallId === toolCallId,
      +    )
      +  }
      +
         onClick={() => {
           const approvalId = tc.approval?.id
           if (!approvalId || respondedApprovals.current.has(approvalId)) {
             return
           }
      -    const interrupt = (
      -      interrupts as ReadonlyArray<{
      -        kind: string
      -        toolCallId?: string
      -        resolveInterrupt: (approved: boolean) => void
      -      }>
      -    ).find(
      -      (item) => item.kind === 'tool-approval' && item.toolCallId === tc.id,
      -    )
      +    const interrupt = findApprovalInterrupt(tc.id)
           if (!interrupt) return
           ...

      (mirror the same change in the Deny handler at Line 511-522)

      Also applies to: 506-529

      🤖 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/src/routes/tools-test.tsx` around lines 464 - 487, Extract the
      repeated interrupt lookup from the Approve and Deny handlers into a shared
      helper near the surrounding tool-approval logic. Have the helper search
      interrupts for the matching toolCallId and tool-approval kind using a type
      predicate, preserving the existing narrowed interrupt type without an `as
      ReadonlyArray` cast; update both handlers to call this helper and retain their
      existing approval/denial behavior.
      🤖 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.
      
      Duplicate comments:
      In `@docs/architecture/approval-flow-processing.md`:
      - Line 139: Replace the superseded gpt-5.5 model name with gpt-chat-latest in
      the documentation examples at
      docs/architecture/approval-flow-processing.md:139-139,
      packages/ai/skills/ai-core/tool-calling/SKILL.md:78-78, and
      packages/ai/skills/ai-core/tool-calling/SKILL.md:681-681, preserving the
      existing adapter usage.
      
      ---
      
      Nitpick comments:
      In `@testing/e2e/src/routes/tools-test.tsx`:
      - Around line 464-487: Extract the repeated interrupt lookup from the Approve
      and Deny handlers into a shared helper near the surrounding tool-approval logic.
      Have the helper search interrupts for the matching toolCallId and tool-approval
      kind using a type predicate, preserving the existing narrowed interrupt type
      without an `as ReadonlyArray` cast; update both handlers to call this helper and
      retain their existing approval/denial behavior.

      ℹ️ Review info
      ⚙️ Run configuration

      Configuration used: defaults

      Review profile: CHILL

      Plan: Pro

      Run ID: ce8b6d71-6ade-4bec-a413-dc706126281f

      📥 Commits

      Reviewing files that changed from the base of the PR and between 8c4ef8347efc2f89ff863fcfa5447d97e4872e94 and 3f12314be8f0c1de39f1159b43cff659ef9dc92a.

      ⛔ Files ignored due to path filters (1)
      • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
      📒 Files selected for processing (23)
      • docs/architecture/approval-flow-processing.md
      • docs/config.json
      • docs/interrupts/generic.md
      • docs/interrupts/migration.md
      • docs/interrupts/multiple.md
      • docs/tools/client-tools.md
      • examples/ts-react-chat/src/components/Header.tsx
      • examples/ts-react-chat/src/lib/interrupt-lab/InterruptLabPage.tsx
      • examples/ts-react-chat/src/lib/interrupt-lab/scenarios.ts
      • examples/ts-react-chat/src/routes/index.tsx
      • packages/ai-client/src/chat-client.ts
      • packages/ai-client/src/interrupt-manager.ts
      • packages/ai-client/src/types.ts
      • packages/ai-client/tests/chat-client-interrupts.test.ts
      • packages/ai-client/tests/chat-client-resume.test.ts
      • packages/ai/skills/ai-core/tool-calling/SKILL.md
      • packages/ai/src/activities/chat/tools/tool-calls.ts
      • packages/ai/src/interrupt-resume.ts
      • packages/ai/src/interrupts.ts
      • packages/ai/tests/interrupt-resume.test.ts
      • testing/e2e/src/components/ChatUI.tsx
      • testing/e2e/src/routes/$provider/$feature.tsx
      • testing/e2e/src/routes/tools-test.tsx
      🚧 Files skipped from review as they are similar to previous changes (14)
      • docs/interrupts/multiple.md
      • docs/config.json
      • docs/tools/client-tools.md
      • docs/interrupts/migration.md
      • packages/ai/src/interrupts.ts
      • testing/e2e/src/routes/$provider/$feature.tsx
      • examples/ts-react-chat/src/lib/interrupt-lab/scenarios.ts
      • packages/ai-client/tests/chat-client-interrupts.test.ts
      • packages/ai-client/tests/chat-client-resume.test.ts
      • packages/ai-client/src/types.ts
      • packages/ai/src/interrupt-resume.ts
      • packages/ai/src/activities/chat/tools/tool-calls.ts
      • packages/ai-client/src/chat-client.ts
      • packages/ai-client/src/interrupt-manager.ts
    10. tombeckenham approved these changes

      I think this is looking good now. I've added a few nit pic comments, and had to fix a few things, but happy to approve

      @@ -0,0 +79,21 @@
      79+ tools: [transfer],
      80+ })
      81+ return toServerSentEventsResponse(stream)
      82+}
      83+```
      84+
      85+## Render and resolve it
      86+
      87+Pass the shared definition to `useChat` so `toolName`, `originalArgs`, edits, and
      88+branch payloads are inferred. Loop the pending `interrupts`, narrow on `kind`,
      89+and render each `transfer` approval — the same shape scales to a mixed queue
      90+(see [Multiple Interrupts](./multiple)):
      91+
      92+```tsx
      93+// app/transfer-approval.tsx
      94+import type { ItemInterruptError } from '@tanstack/ai'
      95+import { fetchServerSentEvents, useChat } from '@tanstack/ai-react'
      96+import { transferTool } from '../tools/transfer'
      97+
      98+export function TransferApprovals() {
      99+ const { interrupts, resuming } = useChat({
      tombeckenhamcommented

      You'd probably want to render the chat in this example the approval ui would appear alongside or in the same chat

      @@ -0,0 +35,21 @@
      35+function GenericInterruptForm({
      36+ interrupt,
      37+}: {
      38+ interrupt: GenericAGUIInterrupt
      39+}) {
      40+ const [value, setValue] = useState('')
      41+ const [errors, setErrors] = useState<ReadonlyArray<string>>([])
      42+
      43+ const submit = () => {
      44+ if (!interrupt.responseSchema) {
      45+ setErrors(['This interrupt has no response schema.'])
      46+ return
      47+ }
      48+ let candidate: unknown
      49+ try {
      50+ candidate = JSON.parse(value)
      51+ } catch {
      52+ setErrors(['Enter valid JSON.'])
      53+ return
      54+ }
      55+ const result = z.fromJSONSchema(interrupt.responseSchema).safeParse(candidate)
      tombeckenhamcommented

      Couldn't you pass value directly to safeParse?

      @@ -0,0 +89,21 @@
      89+ record['$schema'] !== draft202012
      90+ ) {
      91+ throw new JsonSchemaCompilationError('Only Draft 2020-12 is supported.')
      92+ }
      93+ if (typeof record['$ref'] === 'string' && !record['$ref'].startsWith('#')) {
      94+ throw new JsonSchemaCompilationError(
      95+ 'Only document-local $ref values are supported.',
      96+ )
      97+ }
      98+ Object.values(record).forEach(visit)
      99+ active.delete(value)
      100+ }
      101+
      102+ visit(schema)
      103+}
      104+
      105+export function compileJsonSchema202012(
      106+ schema: unknown,
      107+): (value: unknown) => ReadonlyArray<JsonSchemaValidationIssue> {
      108+ assertSupportedSchemaTree(schema)
      109+ const ajv = new Ajv2020({
      tombeckenhamcommented

      This might be an expensive operation. The alternative is to initialize at module level, or create a factory but I never love that either. Happy to leave it

      @@ -0,0 +1 @@
      1+import Ajv2020 from 'ajv/dist/2020.js'
      tombeckenhamcommented

      I wondered whether we could just use zod. Zod is a peer dependency, but to keep it that way you've added arv as a direct dependency. I'm happy to keep it as arv is smaller, but maybe consider if we could just use zod. Alem and I discussed and happy to keep arv

    11. jherr approved these changes

    12. tombeckenham reviewed

      Requesting changes until we resolve what @tannerlinsley raised regarding how interupts interact with durable workflows

      docs/interrupts/overview.md line 165Resolvedby tombeckenham
    13. AlemTuzlak merged this3301398

    14. AlemTuzlak closed this

Sign in to join this conversation.