[KongchangAI]
· 1 min read· 877 words

@ai-sdk/workflow 2.0.106 Fixes Tool Approval Context Defects

@ai-sdk/workflow 2.0.106 Fixes Tool Approval Context Defects

@ai-sdk/workflow 2.0.106 fixes three context defects in the tool approval mechanism and syncs underlying dependencies.

@ai-sdk/workflow released patch 2.0.106, fixing three logic defects in WorkflowAgent's toolApproval mechanism. First, the approval function no longer receives the assistant reply containing tool calls, only the messages actually sent to the model in the current step, preventing pending or rejected sibling calls from polluting the context. Second, approval policies use the current step's runtimeContext returned by prepareStep instead of the initial context, ensuring progressive permission-tightening policies take effect and aligning with ToolLoopAgent. Third, server-side tools' metadata, dynamic flags, and titles are now passed through to approval policies, fixing erroneous approvals or blocks due to missing metadata. The patch also syncs dependencies like ai@7.0.174. Agent workflows with human approval steps are advised to upgrade soon.

rss source: @ai-sdk/workflow@2.0.106

In Vercel's AI SDK ecosystem, @ai-sdk/workflow is a package focused on multi-step workflow orchestration. It recently released patch version 2.0.106, with core changes centered on the tool approval (toolApproval) mechanism of WorkflowAgent. This release adds no new features, but it fixes logic defects of the kind that are "easy to overlook day to day, yet very hard to troubleshoot when they go wrong."

The approval function previously saw history it shouldn't have

The most critical fix is b3588dc. Before this change, WorkflowAgent would pass the assistant reply containing tool calls to the toolApproval approval function, causing the context seen by the approval logic to be polluted with pending, rejected, and invalid sibling calls treated as completed history messages. In other words, the approval function received more information than it should have.

The fixed behavior aligns with the documented contract of generateText and streamText: the approval function only receives the messages actually sent to the model in the current step, excluding system messages and excluding the current response. This makes the input to approval policies clean and controllable, avoiding misjudgments based on dirty context.

When progressively tightening permissions, approval must use the current step's runtime context

The second fix, f3d7a10, addresses the issue of stale runtime context. WorkflowAgent now passes the runtimeContext returned by prepareStep to that step's approval policy, instead of reusing the context from the start of the call.

This difference matters greatly in multi-step workflows: if a policy is designed to progressively tighten permissions, using old context would let subsequent steps still pass under the permissive initial permissions, rendering the restriction useless. The fixed behavior is consistent with ToolLoopAgent.

prepareStep is a hook in AI SDK's Agent workflows that lets developers dynamically adjust a step's configuration before each step executes, including model parameters, tool sets, and runtime context (runtimeContext). In WorkflowAgent, the return value of prepareStep applies to the current step, so the runtimeContext it carries reflects that step's specific permission or environment information. ToolLoopAgent is the underlying Agent in the AI SDK responsible for the tool-calling loop, and it likewise reads the context returned by prepareStep at each step, ensuring policies evolve step by step. This fix aligns WorkflowAgent's behavior with ToolLoopAgent, meaning developers can rely on prepareStep to implement progressive permission models such as "read-only in the first step, write allowed in the second."

Tool metadata, dynamic flags, and titles are now passed through

The third fix, 7655f47, fills in the metadata propagation path. WorkflowAgent now passes the tool metadata, dynamic flag, and title of server-side tool definitions to the toolApproval policy, whether for newly initiated tool calls or for calls re-approved during replay from message history.

The previous problem was: policies that rely on toolCall.toolMetadata to protect tools might let calls through outright, while policies that no longer require approval might still judge calls as pending approval. Both cases cause the approval policy to diverge from actual execution.

Tool metadata (toolMetadata) is arbitrary structured information attached to server-side tool definitions, commonly used to annotate a tool's sensitivity level, required permissions, or business category. The dynamic flag indicates whether a tool is generated dynamically at runtime rather than statically declared; the title is used for human-readable display. In toolApproval policies, these fields are important bases for deciding whether to allow a call or require manual approval. For example, a policy can enforce approval based on sensitivity: high in toolMetadata. If these fields are missing during approval, the policy might mistakenly let a sensitive tool through as an ordinary tool, or repeatedly block a tool that is clearly exempt from approval. Passing these fields through ensures semantic consistency between approval policies and tool definitions, whether a call is initiated for the first time or re-approved from message history.

Dependency sync updates

This patch also updates several underlying dependencies, including ai@7.0.174, @ai-sdk/provider@4.0.39, and @ai-sdk/provider-utils@5.0.82. For users, such updates usually require no additional changes, but if your project is sensitive to peer dependency versions, it's worth confirming them when upgrading.

Should you upgrade

If you're using @ai-sdk/workflow to build Agent workflows with human approval steps, this version is worth adopting soon—all three fixes directly relate to the input accuracy of approval logic and the reliability of permission boundaries. If your workflows don't use toolApproval, the upgrade has limited impact, and you can handle it as a routine patch update.

One-line Summary

@ai-sdk/workflow 2.0.106 fixes three context defects in the tool approval mechanism and syncs underlying dependencies.

Paragraph Summary

@ai-sdk/workflow released patch version 2.0.106, focusing on fixing three logic defects in WorkflowAgent's toolApproval mechanism. First, the approval function no longer receives the assistant reply containing tool calls, only the messages actually sent to the model in the current step, preventing pending or rejected sibling calls from polluting the context. Second, approval policies now use the current step's runtimeContext returned by prepareStep rather than the context from the start of the call, ensuring progressive permission-tightening policies actually take effect and aligning with ToolLoopAgent. Third, server-side tools' tool metadata, dynamic flags, and titles are now passed through to approval policies, fixing erroneous approvals or blocks caused by missing metadata. Additionally, the patch syncs underlying dependencies such as ai@7.0.174. Agent workflows with human approval steps are advised to upgrade soon.

#@ai-sdk/workflow#toolApproval#WorkflowAgent#AI SDK#prepareStep#runtimeContext#toolMetadata
Share:

Related articles