Skip to content

Conversation

tylerslaton
Copy link
Contributor

@tylerslaton tylerslaton commented Sep 16, 2025

We now support the latest AI SDK models and Mastra versions. With this will be a new release, 0.1.0 of the package.

@tylerslaton
Copy link
Contributor Author

Continuing work from #330

@xmlking
Copy link

xmlking commented Sep 19, 2025

just want to share that AgentNetwork API also changed with latest mastra release. current state is react/nextjs project with copilitkit builds are failing

console:build:    ▲ Next.js 15.5.3 (Turbopack)
console:build:    - Experiments (use with caution):
console:build:      ✓ authInterrupts
console:build: 
console:build:    Creating an optimized production build ...
console:build:  ✓ Finished writing to disk in 1855ms
console:build:  ✓ Compiled successfully in 20.1s
console:build:    Skipping validation of types
console:build:  ✓ Linting 
 ⚠ Using edge runtime on a page currently disables static generation for that page
console:build: ⚠️  DEPRECATION WARNING: AgentNetwork vNext will be deprecated on September 23rd, 2025 and will be removed in a future version. Please use agent.network() instead.
console:build: Error: 
console:build:     at R.init (.next/server/chunks/[root-of-the-server]__3ff243e8._.js:527:2586) {
console:build:   id: 'MASTRA_STORAGE_POSTGRES_STORE_INIT_FAILED',
console:build:   domain: 'STORAGE',
console:build:   category: 'THIRD_PARTY',
console:build:   details: {},
console:build:   [cause]: Error: 
console:build:       at E.createTable (.next/server/chunks/[root-of-the-server]__3ff243e8._.js:461:114)
console:build:       at async R.init (.next/server/chunks/[root-of-the-server]__3ff243e8._.js:316:17677)
console:build:       at async R.init (.next/server/chunks/[root-of-the-server]__3ff243e8._.js:527:2441) {
console:build:     id: 'MASTRA_STORAGE_PG_STORE_CREATE_TABLE_FAILED',
console:build:     domain: 'STORAGE',
console:build:     category: 'THIRD_PARTY',
console:build:     details: { tableName: 'mastra_workflow_snapshot' },
console:build:     [cause]: [AggregateError: ] { code: 'ECONNREFUSED' }
console:build:   }
console:build: }
console:build: Error: 
console:build:     at R.init (.next/server/chunks/[root-of-the-server]__3ff243e8._.js:527:2586) {
console:build:   id: 'MASTRA_STORAGE_POSTGRES_STORE_INIT_FAILED',
console:build:   domain: 'STORAGE',
console:build:   category: 'THIRD_PARTY',
console:build:   details: {},
console:build:   [cause]: Error: 
console:build:       at E.createTable (.next/server/chunks/[root-of-the-server]__3ff243e8._.js:461:114)
console:build:       at async R.init (.next/server/chunks/[root-of-the-server]__3ff243e8._.js:316:17677)
console:build:       at async R.init (.next/server/chunks/[root-of-the-server]__3ff243e8._.js:527:2441) {
console:build:     id: 'MASTRA_STORAGE_PG_STORE_CREATE_TABLE_FAILED',
console:build:     domain: 'STORAGE',
console:build:     category: 'THIRD_PARTY',
console:build:     details: { tableName: 'mastra_workflow_snapshot' },
console:build:     [cause]: [AggregateError: ] { code: 'ECONNREFUSED' }
console:build:   }
console:build: }
console:build: ⚠️  DEPRECATION WARNING: AgentNetwork vNext will be deprecated on September 23rd, 2025 and will be removed in a future version. Please use agent.network() instead.
console:build: TypeError: e.getNetworks is not a function
console:build:     at <unknown> (.next/server/chunks/_e0cf6f7a._.js:4:25898)
console:build:     at r8.getLocalAgents (.next/server/chunks/_e0cf6f7a._.js:4:26139)
console:build:     at <unknown> (.next/server/chunks/_e0cf6f7a._.js:4:26769)

> Build error occurred
[Error: Failed to collect page data for /api/mastra] { type: 'Error' }
console:build: error: script "build" exited with code 1

@monobyte
Copy link

Hey Tyler,
I appreciate that this PR is still in progress, but I tested it on my project and whilst the running workflow with streamVNext seems to work as expected, it seems like suspend/resume a workflow for HITL is still missing.

Is that planned in this PR or is that being tracked elsewhere?

@tylerslaton
Copy link
Contributor Author

Hi @xmlking!

just want to share that AgentNetwork API also changed with latest mastra release. current state is react/nextjs project with copilitkit builds are failing

Yes, I believe that the mastra team is going to be editing how networks are defined more broadly soon. In the interim PR here uses the vnext_workflows call to ensure there is compatibility.

I appreciate that this PR is still in progress, but I tested it on my project and whilst the running workflow with streamVNext seems to work as expected, it seems like suspend/resume a workflow for HITL is still missing.

This will require some spec changes to AG-UI that haven't quite yet solidified. With that being said, yes we will be adding that directly following this work.

@tylerslaton
Copy link
Contributor Author

Hi everyone!

Just wanted to say that this integration is pretty much ready, we're just waiting on some final touches. That being said, we do want the community to have the ability to start using this.

As such, we've created a new pre-release version of @ag-ui/mastra you can start using.

Please feel free to use streamVNext with the next stream of releases for the ag-ui integration.

npm i @ag-ui/mastra@next

@eDubrovsky
Copy link

I got the error with "@ag-ui/mastra": "^0.1.0-next.0"

ERROR [2025-09-24 22:05:42.155 +0200] (Mastra CLI): The requested module '@ag-ui/mastra' does not provide an export named 'registerCopilotKit'

export const mastra = new Mastra({
	agents: { weatherAgent },
	server: {
		cors: {
			origin: '*',
			allowMethods: ['*'],
			allowHeaders: ['*']
		},
		apiRoutes: [
			registerCopilotKit<WeatherRuntimeContext>({
				path: '/filmustage_dude',
				resourceId: 'weatherAgent',
				setContext: (c, runtimeContext) => {
					runtimeContext.set('user-id', c.req.header('X-User-ID') || 'anonymous')
					runtimeContext.set('temperature-scale', 'celsius')
				}
			})
		]
	},
	logger: new PinoLogger({
		name: 'Mastra',
		level: 'debug'
	})
})

@monobyte
Copy link

@tylerslaton Will these changes support suspend/resume for workflows? I tried that recently and it didn't seem to trigger any useCopilotkitActions like expected.

@tylerslaton
Copy link
Contributor Author

@eDubrovsky the import for registerCopilotKit changed to be from@ag-ui/mastra/copilotkit.

I just released a new pre-release which accounts for an issue where this wasn't reflected here. Please upgrade via the same command (npm i @ag-ui/mastra@latest) and give it another try.

To explain, we moved it to a sub-package so not everyone consuming the ag-ui integration of mastra needs to install the Copilot Runtime with it.

@tylerslaton
Copy link
Contributor Author

@monobyte This is not reflected in this PR still, mentioned in the previous comment but to bring it down here as well - that will require:

  1. Some spec changes to AG-UI to support interrupts, you can see our proposal draft change here.
  2. Some work with Mastra to ensure the correct events during suspension are emitted via AG-UI.

@eDubrovsky
Copy link

@tylerslaton Hey!

I just tested @copilotkit 1.10.5-next.10 with the latest @ag_ui/mastra 0.1.0-next.1.
I set the context in my frontend using useCopilotReadable.

However, in Mastra, runtimeContext.get('ag-ui') is always empty:

registerCopilotKit({
  path: '/filmustage_ai_dude',
  resourceId: 'filmustageAIDude',
  setContext: async (c, runtimeContext) => {
  	const aguiContext = runtimeContext.get('ag-ui')
  
  	console.debug('aguiContext', aguiContext)
  }
})

Is there something wrong with my setup, or is this a bug?

@tylerslaton
Copy link
Contributor Author

Hey @eDubrovsky! I'll look into this - it should work but could you help me know what version of Mastra you are using?

@eDubrovsky
Copy link

Hey @eDubrovsky! I'll look into this - it should work but could you help me know what version of Mastra you are using?

@tylerslaton sure!

"devDependencies": {
    "@mastra/mcp-docs-server": "0.13.24",
    "@types/node": "24.5.2",
    "mastra": "0.13.2",
    "tsx": "4.20.5",
    "typescript": "5.9.2"
  },
  "dependencies": {
    "@ag-ui/mastra": "0.1.0-next.1",
    "@ai-sdk/azure": "2.0.35",
    "@ai-sdk/openai": "2.0.35",
    "@copilotkit/runtime": "1.10.5-next.10",
    "@mastra/auth-auth0": "0.10.5",
    "@mastra/core": "0.18.0",
    "@mastra/fastembed": "^0.10.5",
    "@mastra/libsql": "0.14.3",
    "@mastra/memory": "0.15.3",
    "zod": "4.1.11"

@eDubrovsky
Copy link

@tylerslaton, also, I found a new bug with Mastra memory: mastra-ai/mastra#8255.
Better to create a new issue about this?

@tylerslaton
Copy link
Contributor Author

Hi @eDubrovsky, yes please that'd be ideal.

@tylerslaton tylerslaton changed the title Mastra v next feat: support Mastra vNext streaming Oct 1, 2025
@tylerslaton tylerslaton changed the title feat: support Mastra vNext streaming feat: support mastra vNext streaming Oct 1, 2025
abhiaiyer91 and others added 2 commits October 1, 2025 09:45
- Adds a streamVNext workflow example
- Supports all of the streamVNext events
- Latest model support from the AI SDK as well

Signed-off-by: Tyler Slaton <[email protected]>
@tylerslaton tylerslaton force-pushed the mastra-vNext branch 2 times, most recently from 23401e7 to 61ad9d8 Compare October 1, 2025 15:10
@tylerslaton tylerslaton merged commit d0ff5f4 into main Oct 1, 2025
14 of 17 checks passed
@tylerslaton tylerslaton deleted the mastra-vNext branch October 1, 2025 17:00
@tylerslaton
Copy link
Contributor Author

We've officially released version 0.1.0 of the @ag-ui/mastra integration.

Please give it a try and let us know what you think - you'll be able to use all of the latest and greatest from Mastra now.

@machester4
Copy link

Hi @tylerslaton I get the following error when using a remote agent. Error: streamVNext has been renamed to stream. Please use stream instead.

"@mastra/client-js": "^0.15.0"
"@ag-ui/mastra": "^0.1.1"
"@ai-sdk/openai": "^2.0.42"
"@mastra/core": "^0.20.0"

@monobyte
Copy link

monobyte commented Oct 6, 2025

Hi @tylerslaton I get the following error when using a remote agent. Error: streamVNext has been renamed to stream. Please use stream instead.

"@mastra/client-js": "^0.15.0" "@ag-ui/mastra": "^0.1.1" "@ai-sdk/openai": "^2.0.42" "@mastra/core": "^0.20.0"

They literally deprecated streamVNext this weekend. It's so hard to keep up with these libraries moving targets.

@tylerslaton
Copy link
Contributor Author

I'll fix this ASAP, thanks for the pings here all. Busy week :)

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.

6 participants