The resourceId and threadId for chatRoute and copilotkit integration should be able to contain authe
In the integration with the AI SDK, memory information is passed from the frontend. However, when using session authentication, it becomes possible to view other users' messages.
https://mastra.ai/docs/frameworks/agentic-uis/ai-sdk#streaming
With copilotkit's integration, the resourceId is fixed, so in applications used by multiple users, all users can view the same message history.
https://mastra.ai/docs/frameworks/agentic-uis/copilotkit
Integrate CopilotKit with Mastra | Frameworks | Mastra Docs
Learn how Mastra leverages the CopilotKit's AGUI library and how you can leverage it to build user experiences
Using Vercel AI SDK | Frameworks | Mastra Docs
Learn how Mastra leverages the Vercel AI SDK library and how you can leverage it further with Mastra
8 Replies
I specify resourceId and threadId using the following rules:
resourceId:
${agentId}-${c.get(βuserβ).id}
threadId: ${agentId}-${c.get(βuserβ).id}-${threadId}π Created GitHub issue: https://github.com/mastra-ai/mastra/issues/10214
π If you're experiencing an error, please provide a minimal reproducible example to help us resolve it quickly.
π Thank you @kosukeoya for helping us improve Mastra!
Hey @kosukeoya ! What copilotkit call the
resourceId it's actually the agentId, e.g. weatherAgent.
To pass a mastra resourceId and threadId you can use the runtimeContext like this:
Thanks @Romain .
I understand that runtimeContext can be passed, but when passing agent.stream in the copilotkit handler, are threadId and resourceId already referenced from runtimeContext?
https://github.com/ag-ui-protocol/ag-ui/blob/35e409b0390e8eb8eff233098caf58ea6811a7d7/integrations/mastra/typescript/src/mastra.ts#L280
GitHub
ag-ui/integrations/mastra/typescript/src/mastra.ts at 35e409b0390e8...
AG-UI: the Agent-User Interaction Protocol. Bring Agents into Frontend Applications. - ag-ui-protocol/ag-ui
Oh yeah, that seems wrong. Could you open a GH issue on the ag-ui repo?
GitHub
Rewrite the stream option in registerCopilotKit by Mastra according...
Current Situation The threadId is passed from RunAgentInput, and the resourceId becomes either a fixed agent ID or the threadId passed from RunAgentInput. In my use case, I want to include informat...
https://github.com/ag-ui-protocol/ag-ui/pull/715/files
I've written a simple sample code for what I want to achieve.
Thanks @kosukeoya for creating the issue on the ag-ui repo, I see it was closed as duplicate in favor of https://github.com/ag-ui-protocol/ag-ui/issues/307
I linked it to our issue π
GitHub
Mastra Integration: Enable passing agent stream options when using ...
I would like to be able to pass AgentStreamOptions when calling agent.stream. This is primarily for passing along telemetry metadata, such as a userid, but could be useful for other cases as well. ...