Skip to content
PluginStats

ai-sdk-heal weekly downloads statistics

By pontusab (2 listings) · npm · AI SDKs

Heal broken Vercel AI SDK message arrays before they hit the provider. Fixes orphaned tool calls, missing reasoning signatures, invalid tool names, and other provider rejections.

View on npm Fresh · Oct 18, 2026

ai-sdk-heal has 972 recorded weekly downloads on npm, a decrease of 30.3% over the past 30 days, ranking #1452 of 2,322 tracked listings.

Weekly downloads
972
Official API · Oct 18, 2026
7-day growth
-17.0%
-199 weekly downloads
30-day growth
-30.3%
-423 weekly downloads
90-day growth
+4.5%
+42 weekly downloads
Rank
#1452
Among tracked npm listings

About ai-sdk-heal

ai-sdk-heal

ai-sdk-heal

Keep your AI SDK conversations valid. ai-sdk-heal normalizes message arrays so they satisfy each provider's structural rules — pairing tool calls with results, coercing tool inputs to objects, preserving reasoning blocks correctly, and more.

One function. Pure. Idempotent. Safe on the hot path and on persisted history.

import { healMessages } from "ai-sdk-heal";

const { messages, repairs } = healMessages(rawMessages, { provider: "anthropic" });
await streamText({ model, messages });

What it does

Providers each have their own rules for what a valid message history looks like:

  • Anthropic requires every tool_use to be paired with a matching tool_result, reasoning blocks to carry a signature, and rejects assistant messages that contain only reasoning.
  • OpenAI's Responses API expects reasoning items to be followed by a same-flow item.
  • All of them require tool inputs to be objects and tool names to match ^[a-zA-Z0-9_-]{1,64}$.

Agents, retries, and persisted conversations make it easy to drift out of those rules — especially across long multi-turn flows with thinking models and parallel tool calls. ai-sdk-heal checks the whole history against the active provider's rules and returns a normalized copy, plus an audit trail of every change it made.

Rules

RuleWhat it does
orphan-tool-useAssistant tool-call with no matching tool-result: inserts a placeholder result (or drops the call) so the pairing invariant holds
orphan-tool-resulttool-result referencing a call that isn't in history: drops it
invalid-tool-inputTool input stored as a raw string because JSON parsing failed upstream: coerces to { raw: "…" } so subsequent turns stay usable
invalid-tool-nameTool names with characters outside ^[a-zA-Z0-9_-]{1,64}$: sanitizes while keeping the call/result pair linked
duplicate-tool-resultSame toolCallId appearing twice after a retry: dedupes
empty-assistant-messageAssistant message with no substantive content: drops it
orphan-reasoning-only-message (Anthropic)After pruning, an assistant message contains only reasoning blocks: drops it
missing-reasoning-signature (Anthropic)Reasoning block with no providerOptions.anthropic.signature: drops it (Anthropic won't accept thinking without the signature on replay)
reasoning-without-following-item (OpenAI)Trailing reasoning part with no following item in the Responses flow: drops it

Every change is captured in the repairs array so you can log it, alert on it, or surface it in admin tooling.

Each rule maps to a documented scenario tracked upstream: #8516, #9141, #11602, #13430, #13645, #14259, #8379, #7729, #12504.

Where this fits in the pipeline

ai-sdk-heal operates on ModelMessage[] — the array you pass to generateText / streamText. If you persist conversations as UIMessage[] (the React/UI shape) and call convertToModelMessages, that conversion sits before healMessages:

DB / state                       AI SDK                          ai-sdk-heal                provider
──────────                       ──────                          ───────────                ────────
UIMessage[] ──convertToModelMessages──> ModelMessage[] ──healMessages──> ModelMessage[] ──> Anthropic / OpenAI / …
                       │                                  │
                       └─ pass `ignoreIncompleteToolCalls: true`
                          to drop UI-level orphans during conversion

The two layers solve different problems:

  • convertToModelMessages({ ignoreIncompleteToolCalls: true }) filters state: "input-available" UI parts that haven't received a result yet. Use it for live UI message arrays where the user might have aborted mid-tool-call.
  • healMessages repairs anything that survives conversion or that lives only in ModelMessage[] form: missing reasoning signatures, invalid tool names, malformed tool inputs, duplicate tool results, OpenAI Responses ordering, persisted DB rows from older SDK versions, and the orphans that pruneMessages creates (#13430, #12504).

A defense-in-depth setup combines both:

const modelMessages = await convertToModelMessages(uiMessages, {
  ignoreIncompleteToolCalls: true,
});
const { messages } = healMessages(modelMessages, { provider: "anthropic" });
await streamText({ model, messages });

Install

npm install ai-sdk-heal

Peer dependency: ai >= 5.0.

Usage

Heal before the provider call
import { healMessages } from "ai-sdk-heal";
import { anthropic } from "@ai-sdk/anthropic";
import { streamText } from "ai";

const { messages, repairs } = healMessages(rawMessages, {
  provider: "anthropic",
  onRepair: (r) => logger.info({ repair: r }, "message-normalized"),
});

const result = streamText({
  model: anthropic("claude-sonnet-4-20250514"),
  messages,
});

If you want to hard-fail during development instead:

healMessages(rawMessages, { provider: "anthropic", throwOnRepair: true });
Wrap your model once with withHealing

If you'd rather not remember to call healMessages on every request, wrap the model itself. The wrapper heals the prompt as it passes through the AI SDK middleware layer:

import { withHealing } from "ai-sdk-heal";
import { anthropic } from "@ai-sdk/anthropic";…

Description from the npm listing.

  • ai
  • ai-sdk
  • vercel
  • anthropic
  • openai
  • gemini
  • tool-calls
  • messages
  • sanitize
  • repair
  • heal
  • middleware
  • llm
  • agent

README badge

Show your rank in a README or on your website. The badge updates automatically.

Charts

Images: 30d · 1y · all time · 1600×900 dark

Adoption over time

ai-sdk-heal weekly downloads on npm, last 90 days: 972 weekly downloads as of Oct 18, 2026, +4.5% over 90 days.ai-sdk-healWeekly downloads on npm · Last 90 days972downloads / week+4.5% over 90 days01K2K3K4K5KJul 20Aug 4Aug 19Sep 3Sep 18Oct 3Oct 18downloads / weekobservedarchived (Internet Archive)no observationsJul 22, 2026 – Oct 18, 2026 · 89 observations · Updated Oc…pluginstats.com
ai-sdk-heal weekly downloads on npm, last 90 days: 972 weekly downloads as of Oct 18, 2026, +4.5% over 90 days.

7/30/90-day growth

ai-sdk-heal weekly downloads growth on npm: -17.0% over 7 days, -30.3% over 30 days, +4.5% over 90 days.ai-sdk-healWeekly downloads growth on npm972downloads / week now7-day growth-199 weekly downloads-17.0%30-day growth-423 weekly downloads-30.3%90-day growth+42 weekly downloads+4.5%Growth vs. nearest observation to each baseline date · Updated Oct 18, 2026pluginstats.com
ai-sdk-heal weekly downloads growth on npm: -17.0% over 7 days, -30.3% over 30 days, +4.5% over 90 days.

Ranking history

ai-sdk-heal npm ranking history: currently #1452 (by weekly downloads).ai-sdk-healnpm ranking · by weekly downloads · Last 90 days#1452current rank#400#600#800#1000#1200#1400#1600Jul 22Aug 6Aug 21Sep 5Sep 20Oct 5Oct 20rankOct 17, 2026 – Oct 20, 2026 · 4 observations · Updated Oct 18, 2026pluginstats.com
ai-sdk-heal npm ranking history: currently #1452 (by weekly downloads).

Listing placement

All npm2,320 listings · 116 pages · 1,161 shown · page 73, #15 (overall #1,455)
All npm: every listing in weekly downloads order

Listing placement

AI SDKs259 listings · 13 pages · page 8, #1 (overall #141)
AI SDKs: every listing in weekly downloads order

Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.

Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.

Recent observations

Full history (544)
Recent weekly downloads observations for ai-sdk-heal
Date (UTC)Weekly downloadsChange vs. previous
972+313
659-56
715+218
497-397
894-275
1,1690
1,169-2
1,171-2
1,173+6
1,167+36
1,131+256
875+95
780-177
957—

Similar npm AI SDKs plugins

All 20 ai-sdk-heal alternatives

Data source

Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.

Listing: https://www.npmjs.com/package/ai-sdk-heal. First seen Oct 16, 2026; last successful collection Oct 20, 2026. See the methodology.