[ai] Expose totalUsage and finishReason on DurableAgent stream result#1863
[ai] Expose totalUsage and finishReason on DurableAgent stream result#1863VaguelySerious wants to merge 1 commit intomainfrom
Conversation
The DurableAgentStreamResult interface omitted totalUsage and finishReason, which were already computed and passed to the onFinish callback. This made them unreachable for callers that await stream() directly, and diverged from the AI SDK's GenerateTextResult/StreamTextResult shape. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 8e78f75 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
🧪 E2E Test Results❌ Some tests failed Summary
❌ Failed Tests💻 Local Development (2 failed)vite-stable (2 failed):
Details by Category✅ ▲ Vercel Production
❌ 💻 Local Development
✅ 📦 Local Production
✅ 🐘 Local Postgres
✅ 📋 Other
❌ Some E2E test jobs failed:
Check the workflow run for details. |
📊 Benchmark Results
workflow with no steps💻 Local Development
workflow with 1 step💻 Local Development
workflow with 10 sequential steps💻 Local Development
workflow with 25 sequential steps💻 Local Development
workflow with 50 sequential steps💻 Local Development
Promise.all with 10 concurrent steps💻 Local Development
Promise.all with 25 concurrent steps💻 Local Development
Promise.all with 50 concurrent steps💻 Local Development
Promise.race with 10 concurrent steps💻 Local Development
Promise.race with 25 concurrent steps💻 Local Development
Promise.race with 50 concurrent steps💻 Local Development
workflow with 10 sequential data payload steps (10KB)💻 Local Development
workflow with 25 sequential data payload steps (10KB)💻 Local Development
workflow with 50 sequential data payload steps (10KB)💻 Local Development
workflow with 10 concurrent data payload steps (10KB)💻 Local Development
workflow with 25 concurrent data payload steps (10KB)💻 Local Development
workflow with 50 concurrent data payload steps (10KB)💻 Local Development
Stream Benchmarks (includes TTFB metrics)workflow with stream💻 Local Development
stream pipeline with 5 transform steps (1MB)💻 Local Development
10 parallel streams (1MB each)💻 Local Development
fan-out fan-in 10 streams (1MB each)💻 Local Development
SummaryFastest Framework by WorldWinner determined by most benchmark wins
Fastest World by FrameworkWinner determined by most benchmark wins
Column Definitions
Worlds:
|
CI status (interim)Two failures, both pre-existing on main — not introduced by this PR:
12 E2E Postgres jobs still pending; will check back when they complete. |
CI status (final)88 pass, 5 skipping, 5 still-running benchmarks, 4 failures — none caused by this PR.
The 5 pending Marking the PR as ready for review when you take a look. |
Summary
DurableAgentStreamResult(the awaited return ofagent.stream()) is missingtotalUsageandfinishReason. Both fields are already computed in the runtime and passed to theonFinishcallback, so the omission from the result is asymmetric and diverges from the AI SDK'sGenerateTextResult/StreamTextResultwhich expose them directly.This adds them to the interface and to all three return sites (early-abort, paused-tools, and the final return), reusing the existing
aggregateUsage(steps)helper.See also vercel/ai#14786
Test plan
durable-agent-compat.test.tsassertsresult.totalUsageandresult.finishReasonafter a normal streampnpm buildinpackages/ai)🤖 Generated with Claude Code