[KongchangAI]
· 3 min read· 1,811 words

AI SDK Batch Release Breakdown: From Anthropic Streaming Fix to Google Prompt Caching Optimization

AI SDK Batch Release Breakdown: From Anthropic Streaming Fix to Google Prompt Caching Optimization

AI SDK large-scale synchronized release fixes streaming resume, prompt caching, and token billing accuracy

Vercel AI SDK completed a synchronized release covering dozens of packages, with the core ai package bumped to 7.1.1. Beneath the version bump, substantive changes center on the provider and workflow layers: Anthropic fixed streaming interruption when server-side tool results appear during session resume; Google supports mid-conversation system instruction injection while keeping prompt caching stable by fixing baseline instructions and tool definitions, and adds jailbreak and image safety categories; openai-compatible corrected cache write token attribution bias affecting cost accounting; the workflow layer delegates toUIMessageChunk to the core layer, eliminating parallel stream protocol implementations. Additionally, Mistral, TogetherAI, and others write discontinued models into catalog entries, making failures earlier and clearer. The overall signal is a shift in maintenance focus toward streaming completeness, billing accuracy, and metadata readability.

Vercel's AI SDK has completed another large-scale synchronized release covering dozens of packages. This release PR was auto-generated by Changesets, with the core ai package bumped to 7.1.1. Several fixes around the provider layer deserve a breakdown—they reflect the pitfalls Agent applications actually hit in production.

rss source: @ai-sdk/tool-bash@2.0.1: Version Packages (#25819)

One Release, the Entire Provider Matrix Affected

This release was automatically created as a PR via changesets/action, and after merging, each package was pushed directly to npm. On the surface, it's a routine version bump, but the dependency graph means changes propagate layer by layer: all downstream packages of the core ai package (@ai-sdk/react, @ai-sdk/vue, @ai-sdk/svelte, @ai-sdk/angular, @ai-sdk/rsc, @ai-sdk/otel, etc.) were bumped in sync due to the b039b9a commit.

The packages with substantive changes are several provider packages and the workflow layer. Many other packages were bumped passively simply because they depend on @ai-sdk/openai-compatible@3.0.100 or @ai-sdk/anthropic@4.0.115, such as Bedrock, Azure, Cerebras, Fireworks, Hugging Face, Tencent, Z.ai, and more.

Core Package: ToolLoopAgent Gains a Read-Only Settings Accessor

The only functional change in ai@7.1.1 is adding a read-only settings getter to ToolLoopAgent. It's a small API surface addition, but very useful for developers building Agent debugging tools, visualization panels, or runtime monitoring—you can read its configuration without intruding into the Agent's internal state, for display, logging, or consistency checks.

Meanwhile, @ai-sdk/gateway updated its model settings file twice (64f28b9, 31eea5b). Such chore commits usually mean the gateway side is following up on configuration for new models or parameters, and users calling the gateway indirectly get the latest support.

Anthropic: Fixing Streaming Interruption for Server-Side Tool Results

The issue fixed in @ai-sdk/anthropic@4.0.115 is quite typical: when a resumed Anthropic response carries server-side tool results in the message_start content, streaming output fails. The fix treats these results as independent content blocks, thereby preserving tool results and citation information.

This problem points to the "session resume" scenario. When a long Agent task resumes after interruption, or when integrating models with server-side tools (such as web search capabilities), the content structure returned by the server doesn't always follow the standard content block sequence. If the provider layer only parses in the conventional order, tool results get lost on the resume path. For teams building multi-turn Agents, this kind of fix matters more than new features.

What Are "Server-Side Tools"

In Anthropic's API, tool calls can be executed in two modes. One is client-side tools: the model returns a tool_use block, and the caller (your application) executes it and sends back a tool_result. The other is server-side tools: executed by Anthropic itself, such as built-in web search, code execution, and similar capabilities. Server-side tool results are not returned to the application first and then sent back; they are generated directly by the server in the stream and may appear in the initial content carried by the message_start event, rather than appearing one by one in the subsequent content_block_start sequence as usual.

This means that if an SDK's parsing logic assumes "all content blocks arrive one by one in the standard sequence," it will lose these pre-existing contents when resuming sessions or using server-side tools. This fix treats server-side tool results as independent content blocks in this scenario, ensuring tool results and citation information aren't dropped on the resume path.

Why Streaming Interruption Only Occurs in Resume Scenarios

Resume typically means: a long task stream ends due to network interruption, timeout, or user-initiated pause, and then the remaining content is pulled using a message id or cursor. At this point, the first event of the re-established stream is message_start, which may already contain previously generated content (including server-side tool results). In a normal first streaming call, message_start is usually empty, so conventional tests rarely expose the problem; only applications that actually do long task resumption will hit it. This is also why such bugs are more common in production Agents than in demos.

Google: Mid-Conversation System Instructions and Prompt Caching Stability

@ai-sdk/google@4.0.133 contains three changes, two of which relate to Agent engineering details.

The first (d48a06c) supports "mid-conversation system instructions" and function tool updates in the Google Interactions API, preserving the position of system messages via system_input steps while keeping baseline instructions and tool definitions stable to maintain prompt caching. The key is the second half: supporting mid-conversation system instruction injection easily breaks the cache prefix, causing every call to be re-billed. Keeping baseline instructions and tool definitions fixed is a trade-off between functionality and cost.

The second (dd11904) adds HARM_CATEGORY_JAILBREAK and the HARM_CATEGORY_IMAGE_* series to safetySettings[].category, allowing safety configuration to cover jailbreak and image-related risk categories.

The third (710c9e5) is a cross-provider unified approach: directly declaring discontinued models in their catalog entries, rather than maintaining separate model ID lists or comments, while preserving historical capabilities and ID compatibility. OpenAI and Mistral also adopted this approach simultaneously.

Prompt Caching and Cache Prefix

Major model services (Anthropic's prompt caching, Google's context caching, OpenAI's automatic caching) all cache at the "prefix" level: if the beginning token segment of the current request is identical to the previous one, the already-computed KV state can be reused, reducing latency and cost. Whether the cache hits depends on the prefix being byte-for-byte stable.

Therefore, once a system instruction is inserted mid-conversation, if the implementation places the new instruction at the very front of the request or disrupts the order of tool definitions, it changes the cache prefix, causing the entire context to be re-billed. The Google provider change uses system_input steps to record the position of system messages, placing mid-conversation instructions in their proper position while fixing the order of baseline instructions and tool definitions—the goal being to preserve cache prefix stability. This is a typical engineering trade-off between "functional correctness" and "inference cost," worth referencing for any team doing multi-turn system instruction injection.

Model Metadata Consistency Cleanup

@ai-sdk/mistral@4.0.95 and @ai-sdk/togetherai@3.0.103 made adjustments in the same direction: writing discontinued models directly into catalog entries, and aligning provider model capability and availability metadata with audit results, including unavailable model IDs and verified feature limitations.

The significance of such changes at the application layer is "fail earlier, fail more clearly"—you don't have to wait until runtime to infer from API errors that a model is no longer available; the type layer or configuration layer can give you a hint.

OpenAI Compatible Layer: Cache Write Token Accounting Fix

@ai-sdk/openai-compatible@3.0.100 fixed a usage statistics discrepancy: mapping prompt_tokens_details.cache_write_tokens to inputTokens.cacheWrite, and deducting the cache write portion from inputTokens.noCache.

For products that rely on token usage for cost accounting or quota control, this fix directly affects the accuracy of billing attribution. Cache writes and uncached inputs have different unit prices, and mixing them in statistics distorts cost analysis. Many third-party compatible services go through this layer, so the impact is broader than the package name suggests.

Pricing Differences Between Cache Write Tokens and Uncached Tokens

When using prompt caching, the input tokens of a request are typically split into three parts: cache hit (cache read), cache write, and no cache. Their unit prices are not the same—cache writes are often more expensive than regular uncached input (due to additional storage and computation), while cache hits are significantly cheaper. OpenAI's compatible interface provides these counts separately in prompt_tokens_details.

If the SDK counts all input tokens as noCache, the application's cost calculation attributes money to the wrong category: the total token count may be correct on the surface, but the cost derived by multiplying categories by different unit prices will systematically deviate. Mapping cache_write_tokens to inputTokens.cacheWrite and deducting it from noCache is precisely to make "category-based pricing" billing attribution accurate. For products doing quota control, per-team cost allocation, or cache ROI analysis, this kind of field-level alignment is more critical than new features.

Workflow: Delegating Stream Transform to the Core Layer

The change in @ai-sdk/workflow@2.0.123 delegates toUIMessageChunk to the AI SDK Core implementation, no longer maintaining a separate set of branch logic. As a result, provider custom parts (e.g., openai.compaction), tool result and error metadata (preliminary, providerExecuted, providerMetadata, toolMetadata, dynamic), reasoning-file, tool-approval-response, and citation information are all correctly preserved.

Additionally, error redaction and the default value of sendSources (false) are aligned with Core; toUIMessageChunk and createModelCallToUIChunkTransform now both accept and pass through sendReasoning, sendSources, onError, redactToolErrors. This is a typical "eliminate parallel implementation" refactor that, in the long run, reduces behavioral drift between the workflow layer and core layer on the stream protocol.

UI Message Chunk and Stream Protocol Drift

AI SDK defines a stream message chunk protocol (UI message chunk) at the core layer, and frontend hooks (@ai-sdk/react, @ai-sdk/vue, etc.) consume data according to this protocol. When upper-layer frameworks (such as workflow, RSC) maintain their own transform implementation, once the two codebases evolve out of sync, fields supported at the core layer get lost at the upper layer—for example, provider custom parts, preliminary/providerExecuted metadata of tool results, reasoning-file, approval responses, etc. Such problems often don't throw errors; they just manifest as missing reasoning process or citation sources in the UI.

Delegating toUIMessageChunk back to Core essentially makes the stream protocol have a single source of truth, so that error redaction, sendReasoning/sendSources and other switch default behaviors stay consistent across both layers. This is the typical benefit of eliminating parallel implementations: small short-term changes, long-term avoidance of protocol behavior drift across versions.

Signals from This Release

Looking at these changes together, AI SDK's maintenance focus is clearly on three things: first, the completeness of the streaming protocol in edge scenarios (session resume, server-side tools, custom parts); second, the accuracy of prompt caching and token billing; third, machine-readable model catalog metadata. These are all problems that must be solved when moving Agents from demo to production, rather than marketing features for new users.

Practical advice for users: if your application involves session resume, server-side tool calls, or cost accounting, this upgrade is worth following; if you only do basic text generation, most changes are transparent to you, and you can upgrade at your normal pace.

One-line Summary

AI SDK large-scale synchronized release fixes streaming resume, prompt caching, and token billing accuracy

Paragraph Summary

Vercel AI SDK completed a synchronized release covering dozens of packages, with the core ai package bumped to 7.1.1. On the surface it's a version bump, but substantive changes center on the provider layer and workflow layer: Anthropic fixed streaming interruption caused by server-side tool results during session resume; Google supports mid-conversation system instruction injection while maintaining prompt caching stability by fixing baseline instructions and tool definitions, and adds jailbreak and image safety categories; openai-compatible corrected cache write token attribution bias affecting cost accounting; the workflow layer delegates toUIMessageChunk to the core layer, eliminating parallel stream protocol implementations. Additionally, Mistral, TogetherAI, etc. write discontinued models into catalog entries, making failures earlier and clearer. The overall signal is a shift in maintenance focus toward streaming completeness, billing accuracy, and metadata readability.

#AI SDK#Anthropic#Google#prompt caching#token billing#streaming protocol#workflow#OpenAI compatible
Share:

Related articles