AI SDK Batch Update: Z.ai Compatibility Layer Fixes and Google Caching Optimization

AI SDK ecosystem-wide patch release fixes cache billing, Google conversation instructions, and Anthropic streaming recovery.
The AI SDK maintained by Vercel released a large-scale patch covering dozens of packages, with core package `ai` moving to 7.1.1 and adding a read-only settings getter to ToolLoopAgent, while integration packages (React, Vue, Svelte, Angular, RSC, LangChain, LlamaIndex) and model providers sync dependencies. The production-critical fixes are at the provider layer: `@ai-sdk/openai-compatible` correctly maps cache_write_tokens to inputTokens.cacheWrite and deducts it from noCache, fixing cache token billing; Google Interactions API supports mid-conversation system instructions and tool updates while keeping prompt caching stable via system_input, and adds jailbreak and image safety categories; Anthropic fixes streaming failures when recovered responses carry server-side tool results in message_start; Workflow's toUIMessageChunk now delegates to AI SDK Core, preserving custom parts and tool metadata. The article closes with upgrade priority recommendations by use case.
One Release, Rippling Across the Entire Provider Ecosystem
The AI SDK maintained by Vercel has shipped a large-scale patch update covering dozens of packages. On the surface, it's just a routine release auto-generated by Changesets, but digging into each package's change log reveals several fixes that directly affect production stability: billing mapping for cache write tokens in the OpenAI compatibility layer, handling of system instruction placement in multi-turn conversations in the Google Interactions API, and a crash when Anthropic streaming responses carry tool results in message_start.
The core package ai moves to 7.1.1, adding a read-only settings getter to ToolLoopAgent. Around this core, virtually all framework integration packages (React, Vue, Svelte, Angular, RSC, LangChain, LlamaIndex) and every model provider have synced their dependencies. This "one core change, whole ecosystem follows" release pattern is normal for the AI SDK, but it also means any fix at the provider layer quickly propagates to all downstream projects.
@ai-sdk/zai@3.0.64 itself does only one thing: update its dependency on @ai-sdk/openai-compatible@3.0.100. The truly valuable changes are hidden in the latter.
Changesets is a tool in the JavaScript ecosystem for managing versions and changelogs in multi-package repositories, often used with pnpm workspaces or Turborepo. Developers submit a markdown file describing the change alongside their PR; at release time, Changesets aggregates these files, computes semantic version numbers, generates each package's CHANGELOG, and publishes everything to npm in one go. A monorepo like the AI SDK with dozens of interdependent packages is exactly the typical use case for Changesets: a minor or patch version bump in the core package ai automatically triggers minor or patch upgrades in all downstream integration packages via dependency ranges, producing the "whole ecosystem follows" release described here. Understanding this helps distinguish which packages in a given release contain genuine feature changes and which are merely mechanical dependency syncs.
Cache Write Token Billing Mapping Finally Lines Up
The fix in @ai-sdk/openai-compatible deserves its own section. It maps prompt_tokens_details.cache_write_tokens to inputTokens.cacheWrite and subtracts that value from inputTokens.noCache.
For teams using Providers that are compatible with the OpenAI protocol—such as Z.ai, Cerebras, DeepInfra, Fireworks, TogetherAI, and HuggingFace—the significance of this change lies in the accuracy of usage statistics. Previously, cache write tokens could be counted in both the cached and non-cached buckets, distorting cost attribution. Systems that rely on the AI SDK for internal billing or quota allocation will get more trustworthy input token breakdowns thanks to this patch.
Accompanying this are metadata corrections in @ai-sdk/mistral and @ai-sdk/togetherai, which write deprecated model IDs and capability restrictions directly into model catalog entries rather than maintaining separate lists. The benefit is that historical capabilities and model ID compatibility are preserved while callers are spared outdated capability declarations.
Prompt caching is a mechanism offered by mainstream LLM APIs to reduce the cost of repeated context: the server caches the stable prefix of a request (such as system instructions or long documents), and subsequent requests that hit the cache are billed at a discount. In the OpenAI-compatible protocol, prompt_tokens_details breaks down input token composition, with common fields including cached_tokens (cache-hit reads) and cache_write_tokens (tokens written to cache for the first time). Different providers don't use exactly the same naming and semantics for these two fields, and some count cache-write tokens in total input tokens as well—which is the origin of the "counted in both cached and non-cached buckets" issue described above. The AI SDK's inputTokens abstracts three buckets: cacheRead, cacheWrite, and noCache. Only when the mapping is correct will upper-layer per-bucket billing logic avoid double-charging.
Google Provider: Cache Hit Rates and Safety Categories Filled In
There are two notable improvements on the Google side. First, the Interactions API now supports inserting system instructions and function tool updates mid-way through multi-turn conversations: the SDK uses a system_input step to preserve the position of system messages while keeping baseline instructions and tool definitions stable, so prompt caching isn't broken.
For applications that dynamically adjust their tool set during long conversations, this means no longer having to sacrifice flexibility for cache hits. Second, safetySettings[].category adds HARM_CATEGORY_JAILBREAK and HARM_CATEGORY_IMAGE_* categories, filling in moderation dimensions that previously couldn't be configured through the SDK.
Google's safety settings are a set of configurations in the Gemini API for adjusting the strictness of content moderation. Each entry contains a category (such as hate speech, dangerous content, or sexually explicit content) and a threshold (blocking threshold). When model output is judged to hit a category, the API returns finishReason: SAFETY or the candidate is filtered. The newly added HARM_CATEGORY_JAILBREAK targets jailbreak prompt attacks, while the HARM_CATEGORY_IMAGE_* series covers corresponding risk categories in image inputs. Previously these dimensions were controlled by server-side default policies and couldn't be explicitly configured via the SDK; with this addition, products that need differentiated policies for image inputs or adversarial prompts can declare moderation strength at the request level rather than relying on account-level global settings.
Tool Result Loss During Anthropic Streaming Recovery
@ai-sdk/anthropic fixed a rather subtle issue: streaming fails when a recovered Anthropic response includes server-side tool results in message_start content. The new version treats these results as independent content blocks, preserving tool results and source citations.
The trigger conditions for this bug are fairly specific, typically appearing when a long-running task with server-side tools is interrupted and then resumed. When it hits, the symptom is a stream interruption rather than an error, making diagnosis costly. Teams relying on Anthropic server-side tools for retrieval or code execution will see fewer of these silent failures after upgrading.
Anthropic Messages API streaming responses are organized as event sequences. message_start is the first event, typically carrying only metadata such as message ID, role, and initial usage; content is then transmitted incrementally via content_block_start, content_block_delta, and content_block_stop. Server-side tool results (such as web search or code execution) generally appear as dedicated content blocks like server_tool_use and web_search_tool_result. When a request needs to be resumed after a timeout or network interruption, the SDK may rebuild existing message state from message_start; if message_start already contains server-side tool results at that point, the old parser would treat it as an invalid event order and interrupt the stream. The new version treats such results as independent content blocks precisely to accommodate this "atypical but legitimate" recovery path.
Workflow Package Unifies Streaming Conversion
The approach behind the @ai-sdk/workflow change is to move from "maintaining its own switch statements" to "delegating to AI SDK Core." toUIMessageChunk now hands standard stream chunks to the ai package for processing, so it preserves the provider's custom parts (e.g., openai.compaction), tool result and error metadata (preliminary, providerExecuted, providerMetadata, toolMetadata, dynamic), reasoning-file, tool-approval-response, and citation information.
Error redaction behavior and the default value of sendSources (false) are now aligned with the core package as well. Both functions now accept and forward the sendReasoning, sendSources, onError, and redactToolErrors parameters. For developers building multi-step Agents on top of Workflow, this eliminates a long-standing divergence in streaming semantics between the UI layer and the core layer.
Upgrade Recommendations
Projects that rely on openai-compatible for cost accounting should upgrade first—the billing correction will directly affect invoice reconciliation results. Teams using the Google Interactions API for long conversations can gain both cache stability and safety category configuration from this update. Anthropic server-side tool users should watch whether streaming recovery scenarios still exhibit anomalies. As for developers using only Z.ai, this upgrade is equivalent to inheriting the openai-compatible fix, so a routine dependency update suffices.
Related articles

Stanford CS336 Explained: The Five Pillars and Efficiency Laws of Building an LLM from Scratch
A deep dive into Stanford CS336 'Building an LLM from Scratch': the five-pillar curriculum, the efficiency equation, the memory wall and five types of parallelism, Chinchilla scaling laws, data refinement, and BPE tokenizer failure cases—revealing how small-scale training transfers to frontier scale.

World of Warcraft Infinite Open Beta Review: How Does Slow-Paced Design Satisfy Millions of Players?
World of Warcraft Infinite's open beta drew a million players. We analyze its slow-paced design philosophy, the new Skywing race's leveling advantages, and class changes.

Pstack: An Open-Source Skill Library That Makes AI Coding More Rigorous
Pstack is an MIT-licensed open-source agent skill library with 5,000+ GitHub stars, offering test-driven development, TypeScript best practices, and potato mode for more rigorous AI coding.