Thread id issue
i'm new to this but have frontend calling mastra server agents and trying to use thread creation feature. 
using cursor and after quite a few tries (upgrading to newer version of mastra) was prompted to raise a bug. 
Mastra Memory Thread Creation issue 
Summary:
When sending a message with only resourceId (no threadId) to agent.generate() with memory enabled, Mastra throws:
A resourceId must be provided when passing a threadId and using Memory.
Reproduction Steps:
Use the latest Mastra packages (@mastra/core, @mastra/memory, etc.).
Configure an agent with memory and generateTitle: true.
Send a message with only resourceId (no threadId) to the agent’s generate() method.
Observe the error.
Payload:
{
  "messages": [{ "role": "user", "content": "How hot is it in Sydney right now?" }],
  "resourceId": "user_test123"
}
Mastra generate options: { resourceId: 'user_test123' }
ERROR [2025-07-25 10:48:49.401 +1000] (Mastra): {"message":"A resourceId must be provided when passing a threadId and using Memory. Saw threadId undefined but resourceId is user_test123","details":{"message":"A resourceId must be provided when passing a threadId and using Memory. Saw threadId undefined but resourceId is user_test123","domain":"AGENT","category":"USER","details":{"agentName":"Weather Agent","threadId":"","resourceId":"user_test123"}},"code":"AGENT_MEMORY_MISSING_RESOURCE_ID"}
Error in /api/chat: Error: A resourceId must be provided when passing a threadId and using Memory. Saw threadId undefined but resourceId is user_test123
    at async POST (src/app/api/chat/route.ts:26:19)
  24 |
  25 |     // Generate response using Mastra with memory
28 | return Response.json(result); 29 | } catch (error) { { id: 'AGENT_MEMORY_MISSING_RESOURCE_ID', Expected behavior: A new thread should be created and a title generated automatically. Mastra version: @mastra/core: 0.11.1
26 | const result = await agent.generate(messages, options);| ^ 27 |
28 | return Response.json(result); 29 | } catch (error) { { id: 'AGENT_MEMORY_MISSING_RESOURCE_ID', Expected behavior: A new thread should be created and a title generated automatically. Mastra version: @mastra/core: 0.11.1
4 Replies
The error message is misleading here, you actually need to provide both the 
threadId and the resourceId 😉 (opened a PR to fix the error message: https://github.com/mastra-ai/mastra/pull/6295)Thank you! is there a sample request/code in the github that shows this ?
You can use it like this:
Thank you @Romain , merged the pr will go out on tuesday in the latest and will create an alpha today.