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 · Dec 6, 2026

ai-sdk-heal has 1,849 recorded weekly downloads on npm, a decrease of 51.0% over the past 30 days, ranking #1911 of 3,247 tracked listings.

Weekly downloads
1,849
Official API · Dec 5, 2026
7-day growth
+21.6%
+329 weekly downloads
30-day growth
-51.0%
-1.9K weekly downloads
90-day growth
-36.6%
-1.1K weekly downloads
Rank
#1911
▼ 43 in 7 days

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: 1,849 weekly downloads as of Dec 5, 2026, -36.6% over 90 days.ai-sdk-healWeekly downloads on npm · Last 90 days1,849downloads / week-36.6% over 90 days01K2K3K4KSep 6Sep 21Oct 6Oct 21Nov 5Nov 20Dec 5downloads / weekobservedarchived (Internet Archive)no observationsSep 7, 2026 – Dec 5, 2026 · 90 observations · Updated Dec …pluginstats.com
ai-sdk-heal weekly downloads on npm, last 90 days: 1,849 weekly downloads as of Dec 5, 2026, -36.6% over 90 days.

7/30/90-day growth

ai-sdk-heal weekly downloads growth on npm: +21.6% over 7 days, -51.0% over 30 days, -36.6% over 90 days.ai-sdk-healWeekly downloads growth on npm1,849downloads / week now7-day growth+329 weekly downloads+21.6%30-day growth-1,928 weekly downloads-51.0%90-day growth-1,068 weekly downloads-36.6%Growth vs. nearest observation to each baseline date · Updated Dec 5, 2026pluginstats.com
ai-sdk-heal weekly downloads growth on npm: +21.6% over 7 days, -51.0% over 30 days, -36.6% over 90 days.

Ranking history

ai-sdk-heal npm ranking history: currently #1911 (by weekly downloads).ai-sdk-healnpm ranking · by weekly downloads · Last 90 days#1911current rank#400#600#800#1000#1200#1400#1600#1800#2000#2200Sep 7Sep 22Oct 7Oct 22Nov 6Nov 21Dec 6rankOct 17, 2026 – Dec 6, 2026 · 45 observations · Updated Dec 5, 2026pluginstats.com
ai-sdk-heal npm ranking history: currently #1911 (by weekly downloads).

Listing placement

All npm3,247 listings · 163 pages · 1,084 shown · page 96, #11 (overall #1,911)
All npm: every listing in weekly downloads order

Listing placement

AI SDKs378 listings · 19 pages · page 10, #3 (overall #183)
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 (592)
Recent weekly downloads observations for ai-sdk-heal
Date (UTC)Weekly downloadsChange vs. previous
1,849+190
1,659+55
1,604-38
1,642+113
1,529+89
1,440-72
1,512-8
1,5200
1,520+88
1,432+252
1,180+62
1,118-253
1,371-120
1,491—

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 Dec 6, 2026. See the methodology.