Skip to content

fix(workflow): Fix stepNumber on telemetry events#15151

Merged
gr2m merged 5 commits into
mainfrom
workflow-telemetry
May 12, 2026
Merged

fix(workflow): Fix stepNumber on telemetry events#15151
gr2m merged 5 commits into
mainfrom
workflow-telemetry

Conversation

@gr2m
Copy link
Copy Markdown
Collaborator

@gr2m gr2m commented May 10, 2026

Background

Follow-up fixes from testing WorkflowAgent telemetry with DevTools.

Manual Verification

Run Locally

Start DevTools from the example workspace:

cd packages/devtools
pnpm dev

Open http://localhost:4983 to inspect captured telemetry.

In a second terminal, run the Workflow example:

cd examples/next-workflow
pnpm dev

Open http://localhost:3000/telemetry and run the scenarios from the sidebar.

⚠️ Telemetry Hooks create steps

  • When running "Happy path" example with telemetry disabled, only 7 steps are created (doStreamStep x3, getWeather, calculate, writeToolResultsWithStepBoundary x2

    image
  • But with telemetry disabled, an additional step is added for each telemetry callback, resulting in ~70 steps

    image

Possible Fix

WorkflowAgent should keep telemetry overhead minimal by buffering telemetry events internally and flushing them in coarse, best-effort batches, e.g. once per AI step or once per run, instead of awaiting every integration callback individually. That would let users configure normal remote telemetry integrations without each telemetry event becoming its own durable workflow step.

gr2m added a commit that referenced this pull request May 11, 2026
## Background

Follow-up to #15151: `doStreamStep` creates the `StepResult`, so it
should receive the step number instead of relying on callers to patch
the result afterward.

## Summary

Adds a defaulted `stepNumber` option for workflow stream steps.

## Manual Verification

- `pnpm turbo build --filter=@ai-sdk/workflow...`
- `pnpm test:node src/stream-text-iterator.test.ts` from
`packages/workflow`
- `pnpm type-check` from `packages/workflow`

## 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)

## Related Issues

Follow-up to #15151.

Co-authored-by: Cursor <cursoragent@cursor.com>
@gr2m gr2m marked this pull request as ready for review May 12, 2026 04:53
@gr2m gr2m changed the title telemetry/example fixes from testing with devtools fix(workflow): Fix stepNumber on telemetry events May 12, 2026
@gr2m gr2m merged commit 81e68da into main May 12, 2026
19 checks passed
@gr2m gr2m deleted the workflow-telemetry branch May 12, 2026 05:19
@github-actions
Copy link
Copy Markdown
Contributor

🚀 Published in:

Package Version
ai 7.0.0-canary.132
@ai-sdk/amazon-bedrock 5.0.0-canary.59
@ai-sdk/angular 3.0.0-canary.132
@ai-sdk/anthropic 4.0.0-canary.52
@ai-sdk/google 4.0.0-canary.60
@ai-sdk/google-vertex 5.0.0-canary.79
@ai-sdk/langchain 3.0.0-canary.132
@ai-sdk/llamaindex 3.0.0-canary.132
@ai-sdk/otel 1.0.0-canary.78
@ai-sdk/react 4.0.0-canary.133
@ai-sdk/rsc 3.0.0-canary.133
@ai-sdk/svelte 5.0.0-canary.132
@ai-sdk/vue 4.0.0-canary.132
@ai-sdk/workflow 1.0.0-canary.49

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant