Skip to content

fix(ai): exclude client-side tool execution from streamText step/chunk timeouts - #19993

Open
Divyansh151005 wants to merge 2 commits into
vercel:mainfrom
Divyansh151005:fix/stream-text-timeout-exclude-tool-execution
Open

fix(ai): exclude client-side tool execution from streamText step/chunk timeouts#19993
Divyansh151005 wants to merge 2 commits into
vercel:mainfrom
Divyansh151005:fix/stream-text-timeout-exclude-tool-execution

Conversation

@Divyansh151005

@Divyansh151005 Divyansh151005 commented Aug 29, 2026

Copy link
Copy Markdown

Background

timeout.chunkMs / stepMs stay armed while client-side tools run. A healthy long-running tool can therefore abort the stream even though toolMs already owns that phase. This addresses #17310.

Summary

  • Clear per-step model timers (stepMs, firstChunkMs, chunkMs) on model-call-end, before pending client tool execution completes.
  • Keep totalMs and toolMs active during tools; re-arm fresh step/chunk timers on later model calls.
  • Document the streamText vs generateText stepMs difference.
  • Add regression coverage for tool-phase exclusion, total/tool timeouts remaining active, and timer re-arm after tools.

End-to-End Verification

Unit coverage with MockLanguageModelV4 (no live provider keys required). The issue reproduction (tool longer than chunkMs) now completes instead of aborting.

Checklist

  • All commits are signed (PRs with unsigned commits cannot be merged)
  • Tests have been added / updated (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features)
  • A patch changeset for relevant packages has been added (for bug fixes / features - run pnpm changeset in the project root)
  • I have reviewed this pull request (self-review)

Testing

$ pnpm -C packages/ai test:node src/generate-text/stream-text-timeout.test.ts

 Test Files  1 passed (1)
      Tests  17 passed (17)
Type Errors  no errors

Related Issues

Fixes #17310

…k timeouts

Clear per-step model timers on model-call-end so stepMs and chunkMs measure
model silence only. totalMs and toolMs remain active during tools.

Fixes vercel#17310
Add regression test for async generator tools whose preliminary tool-result
chunks do not reset chunkMs. Clarify which chunk types reset the timer in
docs and JSDoc, per production feedback on vercel#17310.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

timeout.chunkMs / stepMs count tool-execution time — unusable for tool-loop agents with long-running tools

1 participant