Skip to content

feat(ai): add stream callbacks to ToolLoopAgent#15867

Open
akkadaska wants to merge 1 commit into
vercel:mainfrom
akkadaska:main
Open

feat(ai): add stream callbacks to ToolLoopAgent#15867
akkadaska wants to merge 1 commit into
vercel:mainfrom
akkadaska:main

Conversation

@akkadaska
Copy link
Copy Markdown

Adds onError, onChunk, and onAbort support to ToolLoopAgent.stream.

Fixes #15864

Background

streamText supports onError, onChunk, and onAbort, but ToolLoopAgent.stream() did not expose or forward these callbacks.

In particular, applications using ToolLoopAgent could not replace streamText's default console.error handler with a structured logger.

Summary

  • Add onError, onChunk, and onAbort to AgentStreamParameters and ToolLoopAgentSettings.
  • Forward the callbacks to the internal streamText call.
  • Invoke both constructor-level and call-level callbacks when both are configured.
  • Preserve the existing streamText default error handler when no onError callback is configured.
  • Add runtime and type tests, API reference documentation, and a patch changeset.

Manual Verification

No external provider was used for manual verification. The behavior was verified with the ToolLoopAgent mock model tests, including chunk, error, abort, callback merging, and default error-handler behavior.

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

Fixes #15864

Adds onError, onChunk, and onAbort support to ToolLoopAgent.stream.

Fixes vercel#15864
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.

Add onError, onChunk, and onAbort support to ToolLoopAgent.stream

1 participant