Assemble Agents
Build intelligent agents that execute tasks, access knowledge bases, and maintain memory persistently within threads.
mastra/agent/index.ts
import { Agent } from '@mastra/core';
const chefAgent = new Agent({
name: 'Chef Agent',
instructions: 'You are Michel, a practical and experienced home chef who helps people cook great meals with whatever ingredients they have available. Your first priority is understanding what ingredients and equipment the user has access to, then suggesting achievable recipes. You explain cooking steps clearly and offer substitutions when needed, maintaining a friendly and encouraging tone throughout.',
model: {
provider: 'OPEN_AI',
name: 'gpt-4o',
toolChoice: 'auto',
},
});
Request
Trigger
Context
Knowledge Base
Memory
LLM
Agent
System Prompt
"You are a ..."
Tools
Workflows
Agency
Agent Coordination
Response
Action(S)
Build a knowledge base
Sync data from SaaS tools. Scrape the web. Pipe it into a vector store and RAG away.
mastra/tools/rag.ts
Retrieval pipeline
How can I use Mastra in my Next.JS app?
Prompt
Embed
Bm25 Cosine
Retrieve
Similarity search
Rerank
Install Mastra via npm install
Synthesize Response
Embedding pipeline
SCRAPERS
SaaS
Sync
Query
VECTOR DB
10 00 11 01
10 00 11 01
10 00 11 01
10 00 11 01
10 00 11 01
10 00 11 01
10 00 11 01
10 00 11 01
10 00 11 01
Embed
YOUR DB
mastra knowledge base
Execution flow
Start
scrapeDocs
generateSpec
generatePaths
createComponents
addMetadata
validateSpec
End
Telemetry
generateSpec
Input
Question: Scrape this {{ docs }}, for this {{ application }}
Output
Response: Generating spec based on {{ docs }}, for this {{ audience }}
Backed by founders