Skip to content

@ag-ui/[email protected] still calls streamVNext, but Mastra client only exposes stream #486

@Shitaro

Description

@Shitaro

Summary

@ag-ui/[email protected] continues to invoke agent.streamVNext(...), but the current Mastra client (@mastra/[email protected]) renamed the method to stream. As a result, CopilotKit requests fail with:

Error: streamVNext has been renamed to stream. Please use stream instead.
    at Observable._trySubscribe (../../../src/internal/Observable.ts:244:19)
    ...

This issue has been reported at #384 (comment).

Environment

  • @ag-ui/mastra: 0.1.1
  • @mastra/client-js: 0.15.1
  • @copilotkit/runtime: 1.10.5
  • Next.js 15.5.4 / React 19.1.0

Steps to Reproduce

  1. Install the packages above in a Next.js app.
  2. Use MastraAgent.getRemoteAgents({ mastraClient }) as in the CopilotKit guide.
  3. Start the app and send a chat request (POST /copilotkit).
  4. Check the server logs.

Expected Behavior

MastraAgent should call the new agent.stream(...) (or fall back appropriately) so streaming works with the latest Mastra client.

Actual Behavior

MastraAgent.streamMastraAgent invokes this.agent.streamVNext(...), which throws the error above and prevents responses from streaming.

Workaround

Monkey-patch the returned agents:

Object.values(mastraAgents).forEach((wrapper: any) => {
  if (typeof wrapper?.stream === "function") {
    wrapper.streamVNext = wrapper.stream.bind(wrapper);
  }
  const inner = wrapper.agent ?? wrapper._agent;
  if (inner && typeof inner.stream === "function") {
    inner.streamVNext = inner.stream.bind(inner);
  }
});

Additional Context

PR #384 (feat: support mastra vNext streaming) already replaces the streamVNext call. Could you publish that change (e.g., in 0.1.2) so the workaround is no longer required? Oh, missunderstood

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions