@mastra/mcp-docs-server 0.13.1 → 0.13.2-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +21 -0
- package/.docs/organized/changelogs/%40mastra%2Fagui.md +37 -0
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +48 -48
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +71 -71
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +62 -62
- package/.docs/organized/changelogs/%40mastra%2Fcloud.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +68 -68
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +37 -37
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +64 -64
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +37 -31
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +80 -80
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +77 -77
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +73 -73
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +94 -94
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +80 -41
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +36 -36
- package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +42 -42
- package/.docs/organized/changelogs/%40mastra%2Fgithub.md +36 -36
- package/.docs/organized/changelogs/%40mastra%2Flance.md +59 -0
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +62 -62
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +65 -65
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +56 -56
- package/.docs/organized/changelogs/%40mastra%2Fmem0.md +36 -36
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +58 -58
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +74 -74
- package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +47 -0
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +75 -75
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +107 -107
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +37 -37
- package/.docs/organized/changelogs/%40mastra%2Frag.md +41 -41
- package/.docs/organized/changelogs/%40mastra%2Fragie.md +36 -36
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +61 -61
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +37 -37
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +75 -75
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +24 -24
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +36 -36
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +36 -36
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +36 -36
- package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +34 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +36 -36
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +37 -37
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +36 -36
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +36 -36
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +36 -36
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +36 -36
- package/.docs/organized/changelogs/create-mastra.md +35 -35
- package/.docs/organized/changelogs/mastra.md +116 -116
- package/.docs/organized/code-examples/a2a.md +1 -1
- package/.docs/organized/code-examples/agent-network.md +125 -7
- package/.docs/organized/code-examples/agent.md +1 -1
- package/.docs/organized/code-examples/agui.md +4 -4
- package/.docs/organized/code-examples/ai-sdk-useChat.md +6 -6
- package/.docs/organized/code-examples/assistant-ui.md +5 -5
- package/.docs/organized/code-examples/bird-checker-with-express.md +1 -1
- package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +5 -5
- package/.docs/organized/code-examples/bird-checker-with-nextjs.md +5 -5
- package/.docs/organized/code-examples/client-side-tools.md +6 -6
- package/.docs/organized/code-examples/crypto-chatbot.md +4 -4
- package/.docs/organized/code-examples/experimental-auth-weather-agent.md +1 -1
- package/.docs/organized/code-examples/fireworks-r1.md +1 -1
- package/.docs/organized/code-examples/mcp-configuration.md +2 -2
- package/.docs/organized/code-examples/mcp-registry-registry.md +1 -1
- package/.docs/organized/code-examples/memory-per-resource-example.md +236 -0
- package/.docs/organized/code-examples/memory-with-mem0.md +1 -1
- package/.docs/organized/code-examples/memory-with-processors.md +1 -1
- package/.docs/organized/code-examples/openapi-spec-writer.md +5 -5
- package/.docs/organized/code-examples/quick-start.md +1 -1
- package/.docs/organized/code-examples/stock-price-tool.md +1 -1
- package/.docs/organized/code-examples/weather-agent.md +1 -1
- package/.docs/organized/code-examples/workflow-ai-recruiter.md +1 -1
- package/.docs/organized/code-examples/workflow-with-inline-steps.md +1 -1
- package/.docs/organized/code-examples/workflow-with-memory.md +1 -1
- package/.docs/organized/code-examples/workflow-with-separate-steps.md +1 -1
- package/.docs/raw/frameworks/agentic-uis/copilotkit.mdx +53 -10
- package/.docs/raw/local-dev/mastra-dev.mdx +103 -105
- package/.docs/raw/mastra-cloud/dashboard.mdx +100 -0
- package/.docs/raw/mastra-cloud/observability.mdx +24 -138
- package/.docs/raw/mastra-cloud/overview.mdx +50 -42
- package/.docs/raw/mastra-cloud/setting-up.mdx +51 -87
- package/.docs/raw/memory/overview.mdx +4 -0
- package/.docs/raw/memory/working-memory.mdx +88 -1
- package/.docs/raw/observability/nextjs-tracing.mdx +2 -2
- package/.docs/raw/reference/storage/libsql.mdx +1 -0
- package/.docs/raw/reference/tools/vector-query-tool.mdx +1 -0
- package/.docs/raw/reference/workflows/sleep.mdx +43 -0
- package/.docs/raw/reference/workflows/sleepUntil.mdx +43 -0
- package/.docs/raw/reference/workflows/waitForEvent.mdx +49 -0
- package/.docs/raw/storage/overview.mdx +50 -1
- package/.docs/raw/tools-mcp/mcp-overview.mdx +52 -0
- package/.docs/raw/workflows/inngest-workflow.mdx +1 -1
- package/.docs/raw/workflows/input-data-mapping.mdx +4 -4
- package/.docs/raw/workflows/pausing-execution.mdx +60 -0
- package/package.json +6 -6
- package/.docs/raw/local-dev/add-to-existing-project.mdx +0 -43
- package/.docs/raw/local-dev/creating-a-new-project.mdx +0 -53
- package/.docs/raw/mastra-cloud/deploying.mdx +0 -142
|
@@ -3,61 +3,69 @@ title: Mastra Cloud
|
|
|
3
3
|
description: Deployment and monitoring service for Mastra applications
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
+
import { MastraCloudCallout } from '@/components/mastra-cloud-callout'
|
|
7
|
+
import { FileTree } from "nextra/components";
|
|
8
|
+
|
|
6
9
|
# Mastra Cloud
|
|
7
10
|
|
|
8
|
-
Mastra Cloud is a
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
[Mastra Cloud](https://mastra.ai/cloud) is a platform for deploying, managing, monitoring, and debugging Mastra applications. When you [deploy](/docs/mastra-cloud/setting-up) your application, Mastra Cloud exposes your agents, tools, and workflows as REST API endpoints.
|
|
12
|
+
|
|
13
|
+
<MastraCloudCallout />
|
|
14
|
+
|
|
15
|
+
## Platform features
|
|
16
|
+
|
|
17
|
+
Deploy and manage your applications with automated builds, organized projects, and no additional configuration.
|
|
18
|
+
|
|
19
|
+

|
|
20
|
+
|
|
21
|
+
Key features:
|
|
22
|
+
|
|
23
|
+
Mastra Cloud supports zero-config deployment, continuous integration with GitHub, and atomic deployments that package agents, tools, and workflows together.
|
|
11
24
|
|
|
12
|
-
|
|
13
|
-
> Mastra Cloud is currently in **public beta**. Features, APIs, and UIs may
|
|
14
|
-
> change as development continues.
|
|
25
|
+
## Project Dashboard
|
|
15
26
|
|
|
16
|
-
|
|
27
|
+
Monitor and debug your applications with detailed output logs, deployment state, and interactive tools.
|
|
17
28
|
|
|
18
|
-
|
|
19
|
-
- **Project Organization** - Group agents and workflows into projects with assigned URLs
|
|
20
|
-
- **Environment Variables** - Store configuration securely by environment
|
|
21
|
-
- **Testing Console** - Send messages to agents through a web interface
|
|
22
|
-
- **Execution Tracing** - Record agent interactions and tool calls
|
|
23
|
-
- **Workflow Visualization** - Display workflow steps and execution paths
|
|
24
|
-
- **Logs** - Standard logging output for debugging
|
|
25
|
-
- **Platform Compatibility** - Uses the same infrastructure as Cloudflare, Vercel, and Netlify deployers
|
|
29
|
+

|
|
26
30
|
|
|
27
|
-
|
|
31
|
+
Key features:
|
|
28
32
|
|
|
29
|
-
The
|
|
33
|
+
The Project Dashboard gives you an overview of your application's status and deployments, with access to logs and a built-in playground for testing agents and workflows.
|
|
30
34
|
|
|
31
|
-
|
|
32
|
-
- **Project Details** - Deployments, environment variables, and access URLs
|
|
33
|
-
- **Deployment History** - Record of deployments with timestamps and status
|
|
34
|
-
- **Agent Inspector** - Agent configuration view showing models, tools, and system prompts
|
|
35
|
-
- **Testing Console** - Interface for sending messages to agents
|
|
36
|
-
- **Trace Explorer** - Records of tool calls, parameters, and responses
|
|
37
|
-
- **Workflow Viewer** - Diagram of workflow steps and connections
|
|
35
|
+
## Project structure
|
|
38
36
|
|
|
39
|
-
|
|
37
|
+
Use a standard Mastra project structure for proper detection and deployment.
|
|
40
38
|
|
|
41
|
-
|
|
39
|
+
<FileTree>
|
|
40
|
+
<FileTree.Folder name="src" defaultOpen>
|
|
41
|
+
<FileTree.Folder name="mastra" defaultOpen>
|
|
42
|
+
<FileTree.Folder name="agents" defaultOpen>
|
|
43
|
+
<FileTree.File name="agent-name.ts" />
|
|
44
|
+
</FileTree.Folder>
|
|
45
|
+
<FileTree.Folder name="tools" defaultOpen>
|
|
46
|
+
<FileTree.File name="tool-name.ts" />
|
|
47
|
+
</FileTree.Folder>
|
|
48
|
+
<FileTree.Folder name="workflows" defaultOpen>
|
|
49
|
+
<FileTree.File name="workflow-name.ts" />
|
|
50
|
+
</FileTree.Folder>
|
|
51
|
+
<FileTree.File name="index.ts" />
|
|
52
|
+
</FileTree.Folder>
|
|
53
|
+
</FileTree.Folder>
|
|
54
|
+
<FileTree.File name="package.json" />
|
|
55
|
+
</FileTree>
|
|
42
56
|
|
|
43
|
-
|
|
44
|
-
- **Dynamic Resource Allocation** - Adjusts compute resources based on traffic
|
|
45
|
-
- **Mastra-specific Runtime** - Runtime optimized for agent execution
|
|
46
|
-
- **Standard Deployment API** - Consistent deployment interface across environments
|
|
47
|
-
- **Tracing Infrastructure** - Records all agent and workflow execution steps
|
|
57
|
+
Mastra Cloud scans your repository for:
|
|
48
58
|
|
|
49
|
-
|
|
59
|
+
- **Agents**: Defined using: `new Agent({...})`
|
|
60
|
+
- **Tools**: Defined using: `createTool({...})`
|
|
61
|
+
- **Workflows**: Defined using: `createWorkflow({...})`
|
|
62
|
+
- **Steps**: Defined using: `createStep({...})`
|
|
63
|
+
- **Environment Variables**: API keys and configuration variables
|
|
50
64
|
|
|
51
|
-
|
|
65
|
+
## Technical implementation
|
|
52
66
|
|
|
53
|
-
-
|
|
54
|
-
- Maintaining staging and production environments
|
|
55
|
-
- Monitoring agent behavior across many requests
|
|
56
|
-
- Testing agent responses through a web interface
|
|
57
|
-
- Deploying to multiple regions
|
|
67
|
+
Mastra Cloud is purpose-built for Mastra agents, tools, and workflows. It handles long-running requests, records detailed traces for every execution, and includes built-in support for evals.
|
|
58
68
|
|
|
59
|
-
##
|
|
69
|
+
## Next steps
|
|
60
70
|
|
|
61
|
-
|
|
62
|
-
2. [Deploy code](/docs/mastra-cloud/deploying)
|
|
63
|
-
3. [View execution traces](/docs/mastra-cloud/observability)
|
|
71
|
+
- [Setting Up and Deploying](/docs/mastra-cloud/setting-up)
|
|
@@ -3,126 +3,90 @@ title: Setting Up a Project
|
|
|
3
3
|
description: Configuration steps for Mastra Cloud projects
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
import { MastraCloudCallout } from '@/components/mastra-cloud-callout'
|
|
7
|
+
import { Steps } from "nextra/components";
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
> Mastra Cloud is currently in **beta**.
|
|
9
|
+
# Setting Up and Deploying
|
|
10
10
|
|
|
11
|
-
This page
|
|
11
|
+
This page explains how to set up a project on [Mastra Cloud](https://mastra.ai/cloud) with automatic deployments using our GitHub integration.
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
- A Mastra Cloud account
|
|
16
|
-
- A GitHub account
|
|
17
|
-
- A GitHub repository containing a Mastra application
|
|
13
|
+
<MastraCloudCallout />
|
|
18
14
|
|
|
19
|
-
##
|
|
20
|
-
|
|
21
|
-
1. **Sign in to Mastra Cloud**
|
|
15
|
+
## Prerequisites
|
|
22
16
|
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
- A [Mastra Cloud](https://mastra.ai/cloud) account
|
|
18
|
+
- A GitHub account / repository containing a Mastra application
|
|
25
19
|
|
|
26
|
-
|
|
20
|
+
> See our [Getting started](/docs/getting-started/installation) guide to scaffold out a new Mastra project with sensible defaults.
|
|
27
21
|
|
|
28
|
-
|
|
29
|
-
- This opens the GitHub repository import dialog
|
|
22
|
+
## Setup and Deploy process
|
|
30
23
|
|
|
31
|
-
|
|
24
|
+
<Steps>
|
|
32
25
|
|
|
33
|
-
|
|
26
|
+
### Sign in to Mastra Cloud
|
|
34
27
|
|
|
35
|
-
|
|
36
|
-
- Click the "Import" button next to the repository you want to deploy
|
|
28
|
+
Head over to [https://cloud.mastra.ai/](https://cloud.mastra.ai) and sign in with either:
|
|
37
29
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
- **Repo Name**: The GitHub repository name (read-only)
|
|
41
|
-
- **Project Name**: Customize the project name (defaults to repo name)
|
|
42
|
-
- **Branch**: Select the branch to deploy (dropdown, defaults to `main`)
|
|
43
|
-
- **Project root**: Set the root directory of your project (defaults to `/`)
|
|
44
|
-
- **Mastra Directory**: Specify where Mastra files are located (defaults to `src/mastra`)
|
|
45
|
-
- **Build Command**: Optional command to run during build process
|
|
46
|
-
- **Store Settings**: Configure data storage options
|
|
47
|
-
- **Environment Variables**: Add key-value pairs for configuration (e.g., API keys)
|
|
30
|
+
- **GitHub**
|
|
31
|
+
- **Google**
|
|
48
32
|
|
|
49
|
-
|
|
33
|
+
### Install the Mastra GitHub app
|
|
50
34
|
|
|
51
|
-
|
|
35
|
+
When prompted, install the Mastra GitHub app.
|
|
52
36
|
|
|
53
|
-
|
|
54
|
-
- **Workflows**: Workflow step definitions (e.g., weather-workflow)
|
|
55
|
-
- **Environment Variables**: Required API keys and configuration variables
|
|
37
|
+

|
|
56
38
|
|
|
57
|
-
|
|
39
|
+
### Create a new project
|
|
58
40
|
|
|
59
|
-
|
|
41
|
+
Click the **Create new project** button to create a new project.
|
|
60
42
|
|
|
61
|
-
|
|
43
|
+

|
|
62
44
|
|
|
63
|
-
###
|
|
45
|
+
### Import a Git repository
|
|
64
46
|
|
|
65
|
-
|
|
66
|
-
- **Domains**: URLs for accessing your deployed application
|
|
67
|
-
- Format: `https://[project-name].mastra.cloud`
|
|
68
|
-
- Format: `https://[random-id].mastra.cloud`
|
|
69
|
-
- **Status**: Current deployment status (success or archived)
|
|
70
|
-
- **Branch**: The branch deployed (typically `main`)
|
|
71
|
-
- **Environment Variables**: Configured API keys and settings
|
|
72
|
-
- **Workflows**: List of detected workflows with step counts
|
|
73
|
-
- **Agents**: List of detected agents with models and tools
|
|
74
|
-
- **Database Usage**: Reads, writes, and storage statistics
|
|
47
|
+
Search for a repository, then click **Import**.
|
|
75
48
|
|
|
76
|
-
|
|
49
|
+

|
|
77
50
|
|
|
78
|
-
|
|
79
|
-
- Deployment ID (based on commit hash)
|
|
80
|
-
- Status (success/archived)
|
|
81
|
-
- Branch
|
|
82
|
-
- Commit hash
|
|
83
|
-
- Timestamp
|
|
51
|
+
### Configure the deployment
|
|
84
52
|
|
|
85
|
-
|
|
53
|
+
Mastra Cloud automatically detects the right build settings, but you can customize them using the options described below.
|
|
86
54
|
|
|
87
|
-
|
|
55
|
+

|
|
88
56
|
|
|
89
|
-
-
|
|
90
|
-
-
|
|
91
|
-
-
|
|
92
|
-
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
57
|
+
- **Importing from GitHub**: The GitHub repository name
|
|
58
|
+
- **Project name**: Customize the project name
|
|
59
|
+
- **Branch**: The branch to deploy from
|
|
60
|
+
- **Project root**: The root directory of your project
|
|
61
|
+
- **Mastra directory**: Where Mastra files are located
|
|
62
|
+
- **Environment variables**: Add environment variables used by the application
|
|
63
|
+
- **Build and Store settings**:
|
|
64
|
+
- **Install command**: Runs pre-build to install project dependencies
|
|
65
|
+
- **Project setup command**: Runs pre-build to prepare any external dependencies
|
|
66
|
+
- **Port**: The network port the server will use
|
|
67
|
+
- **Store settings**: Use Mastra Cloud's built-in [LibSQLStore](/docs/storage/overview) storage
|
|
68
|
+
- **Deploy Project**: Starts the deployment process
|
|
96
69
|
|
|
97
|
-
|
|
70
|
+
### Deploy project
|
|
98
71
|
|
|
99
|
-
|
|
72
|
+
Click **Deploy Project** to create and deploy your application using the configuration you’ve set.
|
|
100
73
|
|
|
101
|
-
|
|
102
|
-
- **Deployments**: Deployment history and details
|
|
103
|
-
- **Logs**: Application logs for debugging
|
|
104
|
-
- **Agents**: List and configuration of all agents
|
|
105
|
-
- **Workflows**: List and structure of all workflows
|
|
106
|
-
- **Settings**: Project configuration options
|
|
74
|
+
</Steps>
|
|
107
75
|
|
|
108
|
-
##
|
|
76
|
+
## Successful deployment
|
|
109
77
|
|
|
110
|
-
|
|
78
|
+
After a successful deployment you'll be shown the **Overview** screen where you can view your project's status, domains, latest deployments and connected agents and workflows.
|
|
111
79
|
|
|
112
|
-
|
|
113
|
-
2. Go to the "Environment Variables" section
|
|
114
|
-
3. Add or edit variables (such as `OPENAI_API_KEY`)
|
|
115
|
-
4. Save the configuration
|
|
80
|
+

|
|
116
81
|
|
|
117
|
-
|
|
82
|
+
## Continuous integration
|
|
118
83
|
|
|
119
|
-
|
|
84
|
+
Your project is now configured with automatic deployments which occur whenever you push to the configured branch of your GitHub repository.
|
|
120
85
|
|
|
121
|
-
|
|
86
|
+
## Testing your application
|
|
122
87
|
|
|
123
|
-
|
|
124
|
-
2. The dashboard interface for direct interaction with agents
|
|
88
|
+
After a successful deployment you can test your agents and workflows from the [Playground](/docs/mastra-cloud/dashboard#playground) in Mastra Cloud, or interact with them using our [Client SDK](/docs/client-js/overview).
|
|
125
89
|
|
|
126
|
-
## Next
|
|
90
|
+
## Next steps
|
|
127
91
|
|
|
128
|
-
|
|
92
|
+
- [Navigating the Dashboard](/docs/mastra-cloud/dashboard)
|
|
@@ -8,6 +8,8 @@ The context window is the total information visible to the language model at any
|
|
|
8
8
|
|
|
9
9
|
In Mastra, context is broken up into three parts: system instructions and information about the user ([working memory](./working-memory.mdx)), recent messages ([message history](#conversation-history)), and older messages that are relevant to the user’s query ([semantic recall](./semantic-recall.mdx)).
|
|
10
10
|
|
|
11
|
+
Working memory can persist at different scopes - either per conversation thread (default) or across all threads for the same user (resource-scoped), enabling persistent user profiles that remember context across conversations.
|
|
12
|
+
|
|
11
13
|
In addition, we provide [memory processors](./memory-processors.mdx) to trim context or remove information if the context is too long.
|
|
12
14
|
|
|
13
15
|
## Quick Start
|
|
@@ -69,6 +71,8 @@ Mastra organizes memory into threads, which are records that identify specific c
|
|
|
69
71
|
1. **`threadId`**: A specific conversation id (e.g., `support_123`).
|
|
70
72
|
2. **`resourceId`**: The user or entity id that owns each thread (e.g., `user_123`, `org_456`).
|
|
71
73
|
|
|
74
|
+
The `resourceId` is particularly important for [resource-scoped working memory](./working-memory.mdx#resource-scoped-memory), which allows memory to persist across all conversation threads for the same user.
|
|
75
|
+
|
|
72
76
|
```typescript {2,3}
|
|
73
77
|
const response = await myMemoryAgent.stream("Hello, my name is Alice.", {
|
|
74
78
|
resourceId: "user_alice",
|
|
@@ -2,12 +2,19 @@ import YouTube from "@/components/youtube";
|
|
|
2
2
|
|
|
3
3
|
# Working Memory
|
|
4
4
|
|
|
5
|
-
While [conversation history](/docs/memory/overview#conversation-history) and [semantic recall](./semantic-recall.mdx) help agents remember conversations, working memory allows them to maintain persistent information about users across interactions
|
|
5
|
+
While [conversation history](/docs/memory/overview#conversation-history) and [semantic recall](./semantic-recall.mdx) help agents remember conversations, working memory allows them to maintain persistent information about users across interactions.
|
|
6
6
|
|
|
7
7
|
Think of it as the agent's active thoughts or scratchpad – the key information they keep available about the user or task. It's similar to how a person would naturally remember someone's name, preferences, or important details during a conversation.
|
|
8
8
|
|
|
9
9
|
This is useful for maintaining ongoing state that's always relevant and should always be available to the agent.
|
|
10
10
|
|
|
11
|
+
Working memory can persist at two different scopes:
|
|
12
|
+
- **Thread-scoped** (default): Memory is isolated per conversation thread
|
|
13
|
+
- **Resource-scoped**: Memory persists across all conversation threads for the same user
|
|
14
|
+
|
|
15
|
+
**Important:** Switching between scopes means the agent won't see memory from the other scope - thread-scoped memory is completely separate from resource-scoped memory.
|
|
16
|
+
|
|
17
|
+
|
|
11
18
|
## Quick Start
|
|
12
19
|
|
|
13
20
|
Here's a minimal example of setting up an agent with working memory:
|
|
@@ -38,6 +45,85 @@ Working memory is a block of Markdown text that the agent is able to update over
|
|
|
38
45
|
|
|
39
46
|
<YouTube id="ik-ld_XA96s" />
|
|
40
47
|
|
|
48
|
+
## Memory Persistence Scopes
|
|
49
|
+
|
|
50
|
+
Working memory can operate in two different scopes, allowing you to choose how memory persists across conversations:
|
|
51
|
+
|
|
52
|
+
### Thread-Scoped Memory (Default)
|
|
53
|
+
|
|
54
|
+
By default, working memory is scoped to individual conversation threads. Each thread maintains its own isolated memory:
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
const memory = new Memory({
|
|
58
|
+
storage,
|
|
59
|
+
options: {
|
|
60
|
+
workingMemory: {
|
|
61
|
+
enabled: true,
|
|
62
|
+
scope: 'thread', // Default - memory is isolated per thread
|
|
63
|
+
template: `# User Profile
|
|
64
|
+
- **Name**:
|
|
65
|
+
- **Interests**:
|
|
66
|
+
- **Current Goal**:
|
|
67
|
+
`,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**Use cases:**
|
|
74
|
+
- Different conversations about separate topics
|
|
75
|
+
- Temporary or session-specific information
|
|
76
|
+
- Workflows where each thread needs working memory but threads are ephemeral and not related to each other
|
|
77
|
+
|
|
78
|
+
### Resource-Scoped Memory
|
|
79
|
+
|
|
80
|
+
Resource-scoped memory persists across all conversation threads for the same user (resourceId), enabling persistent user memory:
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
const memory = new Memory({
|
|
84
|
+
storage,
|
|
85
|
+
options: {
|
|
86
|
+
workingMemory: {
|
|
87
|
+
enabled: true,
|
|
88
|
+
scope: 'resource', // Memory persists across all user threads
|
|
89
|
+
template: `# User Profile
|
|
90
|
+
- **Name**:
|
|
91
|
+
- **Location**:
|
|
92
|
+
- **Interests**:
|
|
93
|
+
- **Preferences**:
|
|
94
|
+
- **Long-term Goals**:
|
|
95
|
+
`,
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Use cases:**
|
|
102
|
+
- Personal assistants that remember user preferences
|
|
103
|
+
- Customer service bots that maintain customer context
|
|
104
|
+
- Educational applications that track student progress
|
|
105
|
+
|
|
106
|
+
### Usage with Agents
|
|
107
|
+
|
|
108
|
+
When using resource-scoped memory, make sure to pass the `resourceId` parameter:
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
// Resource-scoped memory requires resourceId
|
|
112
|
+
const response = await agent.generate("Hello!", {
|
|
113
|
+
threadId: "conversation-123",
|
|
114
|
+
resourceId: "user-alice-456" // Same user across different threads
|
|
115
|
+
});
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Storage Adapter Support
|
|
119
|
+
|
|
120
|
+
Resource-scoped working memory requires specific storage adapters that support the `mastra_resources` table:
|
|
121
|
+
|
|
122
|
+
### ✅ Supported Storage Adapters
|
|
123
|
+
- **LibSQL** (`@mastra/libsql`)
|
|
124
|
+
- **PostgreSQL** (`@mastra/pg`)
|
|
125
|
+
- **Upstash** (`@mastra/upstash`)
|
|
126
|
+
|
|
41
127
|
## Custom Templates
|
|
42
128
|
|
|
43
129
|
Templates guide the agent on what information to track and update in working memory. While a default template is used if none is provided, you'll typically want to define a custom template tailored to your agent's specific use case to ensure it remembers the most relevant information.
|
|
@@ -161,3 +247,4 @@ instructions on _how_ and _when_ to use this template in your agent's `instructi
|
|
|
161
247
|
|
|
162
248
|
- [Streaming working memory](/examples/memory/streaming-working-memory)
|
|
163
249
|
- [Using a working memory template](/examples/memory/streaming-working-memory-advanced)
|
|
250
|
+
- [Per-resource working memory](https://github.com/mastra-ai/mastra/tree/main/examples/memory-per-resource-example) - Complete example showing resource-scoped memory persistence
|
|
@@ -59,7 +59,7 @@ npm install @opentelemetry/api langfuse-vercel
|
|
|
59
59
|
import {
|
|
60
60
|
NodeSDK,
|
|
61
61
|
ATTR_SERVICE_NAME,
|
|
62
|
-
|
|
62
|
+
resourceFromAttributes,
|
|
63
63
|
} from "@mastra/core/telemetry/otel-vendor";
|
|
64
64
|
import { LangfuseExporter } from "langfuse-vercel";
|
|
65
65
|
|
|
@@ -69,7 +69,7 @@ export function register() {
|
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
const sdk = new NodeSDK({
|
|
72
|
-
resource:
|
|
72
|
+
resource: resourceFromAttributes({
|
|
73
73
|
[ATTR_SERVICE_NAME]: "ai",
|
|
74
74
|
}),
|
|
75
75
|
traceExporter: exporter,
|
|
@@ -67,4 +67,5 @@ The storage implementation handles schema creation and updates automatically. It
|
|
|
67
67
|
|
|
68
68
|
- `threads`: Stores conversation threads
|
|
69
69
|
- `messages`: Stores individual messages
|
|
70
|
+
- `resources`: Stores user-specific data for resource-scoped working memory
|
|
70
71
|
- `metadata`: Stores additional metadata for threads and messages
|
|
@@ -539,6 +539,7 @@ runtimeContext.set("filter", { category: "docs" });
|
|
|
539
539
|
runtimeContext.set("databaseConfig", {
|
|
540
540
|
pinecone: { namespace: "runtime-namespace" }
|
|
541
541
|
});
|
|
542
|
+
runtimeContext.set("model", openai.embedding("text-embedding-3-small"));
|
|
542
543
|
|
|
543
544
|
const response = await agent.generate(
|
|
544
545
|
"Find documentation from the knowledge base.",
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Workflow.sleep() | Building Workflows | Mastra Docs"
|
|
3
|
+
description: Documentation for the `.sleep()` method in workflows, which pauses execution for a specified number of milliseconds.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Workflow.sleep()
|
|
7
|
+
|
|
8
|
+
The `.sleep()` method pauses execution for a specified number of milliseconds.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
workflow.sleep(1000);
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Parameters
|
|
17
|
+
|
|
18
|
+
<PropertiesTable
|
|
19
|
+
content={[
|
|
20
|
+
{
|
|
21
|
+
name: "milliseconds",
|
|
22
|
+
type: "number",
|
|
23
|
+
description: "The number of milliseconds to pause execution",
|
|
24
|
+
isOptional: false,
|
|
25
|
+
},
|
|
26
|
+
]}
|
|
27
|
+
/>
|
|
28
|
+
|
|
29
|
+
## Returns
|
|
30
|
+
|
|
31
|
+
<PropertiesTable
|
|
32
|
+
content={[
|
|
33
|
+
{
|
|
34
|
+
name: "workflow",
|
|
35
|
+
type: "Workflow",
|
|
36
|
+
description: "The workflow instance for method chaining",
|
|
37
|
+
},
|
|
38
|
+
]}
|
|
39
|
+
/>
|
|
40
|
+
|
|
41
|
+
## Related
|
|
42
|
+
|
|
43
|
+
- [Sleep & Events](../../docs/workflows/pausing-execution.mdx)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Workflow.sleepUntil() | Building Workflows | Mastra Docs"
|
|
3
|
+
description: Documentation for the `.sleepUntil()` method in workflows, which pauses execution until a specified date.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Workflow.sleepUntil()
|
|
7
|
+
|
|
8
|
+
The `.sleepUntil()` method pauses execution until a specified date.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
workflow.sleepUntil(new Date(Date.now() + 1000));
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Parameters
|
|
17
|
+
|
|
18
|
+
<PropertiesTable
|
|
19
|
+
content={[
|
|
20
|
+
{
|
|
21
|
+
name: "date",
|
|
22
|
+
type: "Date",
|
|
23
|
+
description: "The date until which to pause execution",
|
|
24
|
+
isOptional: false,
|
|
25
|
+
},
|
|
26
|
+
]}
|
|
27
|
+
/>
|
|
28
|
+
|
|
29
|
+
## Returns
|
|
30
|
+
|
|
31
|
+
<PropertiesTable
|
|
32
|
+
content={[
|
|
33
|
+
{
|
|
34
|
+
name: "workflow",
|
|
35
|
+
type: "Workflow",
|
|
36
|
+
description: "The workflow instance for method chaining",
|
|
37
|
+
},
|
|
38
|
+
]}
|
|
39
|
+
/>
|
|
40
|
+
|
|
41
|
+
## Related
|
|
42
|
+
|
|
43
|
+
- [Sleep & Events](../../docs/workflows/pausing-execution.mdx)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Workflow.waitForEvent() | Building Workflows | Mastra Docs"
|
|
3
|
+
description: Documentation for the `.waitForEvent()` method in workflows, which pauses execution until an event is received.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Workflow.waitForEvent()
|
|
7
|
+
|
|
8
|
+
The `.waitForEvent()` method pauses execution until an event is received.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
workflow.waitForEvent('my-event-name', step1);
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Parameters
|
|
17
|
+
|
|
18
|
+
<PropertiesTable
|
|
19
|
+
content={[
|
|
20
|
+
{
|
|
21
|
+
name: "eventName",
|
|
22
|
+
type: "string",
|
|
23
|
+
description: "The name of the event to wait for",
|
|
24
|
+
isOptional: false,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: "step",
|
|
28
|
+
type: "Step",
|
|
29
|
+
description: "The step to resume after the event is received",
|
|
30
|
+
isOptional: false,
|
|
31
|
+
},
|
|
32
|
+
]}
|
|
33
|
+
/>
|
|
34
|
+
|
|
35
|
+
## Returns
|
|
36
|
+
|
|
37
|
+
<PropertiesTable
|
|
38
|
+
content={[
|
|
39
|
+
{
|
|
40
|
+
name: "workflow",
|
|
41
|
+
type: "Workflow",
|
|
42
|
+
description: "The workflow instance for method chaining",
|
|
43
|
+
},
|
|
44
|
+
]}
|
|
45
|
+
/>
|
|
46
|
+
|
|
47
|
+
## Related
|
|
48
|
+
|
|
49
|
+
- [Sleep & Events](../../docs/workflows/pausing-execution.mdx)
|
|
@@ -55,7 +55,7 @@ Each tab includes detailed column information with types, constraints, and examp
|
|
|
55
55
|
The data types include Messages, Threads, Workflows, Eval Datasets, and Traces.
|
|
56
56
|
*/}
|
|
57
57
|
|
|
58
|
-
<Tabs items={['Messages', 'Threads', 'Workflows', 'Eval Datasets', 'Traces']}>
|
|
58
|
+
<Tabs items={['Messages', 'Threads', 'Resources', 'Workflows', 'Eval Datasets', 'Traces']}>
|
|
59
59
|
<Tabs.Tab>
|
|
60
60
|
Stores conversation messages and their metadata. Each message belongs to a thread and contains the actual content along with metadata about the sender role and message type.
|
|
61
61
|
|
|
@@ -212,6 +212,55 @@ Groups related messages together and associates them with a resource. Contains m
|
|
|
212
212
|
]}
|
|
213
213
|
/>
|
|
214
214
|
|
|
215
|
+
</Tabs.Tab>
|
|
216
|
+
<Tabs.Tab>
|
|
217
|
+
Stores user-specific data for resource-scoped working memory. Each resource represents a user or entity, allowing working memory to persist across all conversation threads for that user.
|
|
218
|
+
|
|
219
|
+
<br />
|
|
220
|
+
<SchemaTable
|
|
221
|
+
columns={[
|
|
222
|
+
{
|
|
223
|
+
name: "id",
|
|
224
|
+
type: "text",
|
|
225
|
+
description: "Resource identifier (user or entity ID) - same as resourceId used in threads and agent calls",
|
|
226
|
+
constraints: [
|
|
227
|
+
{ type: "primaryKey" },
|
|
228
|
+
{ type: "nullable", value: false }
|
|
229
|
+
]
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
name: "workingMemory",
|
|
233
|
+
type: "text",
|
|
234
|
+
description: "Persistent working memory data as Markdown text. Contains user profile, preferences, and contextual information that persists across conversation threads.",
|
|
235
|
+
constraints: [{ type: "nullable", value: true }]
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
name: "metadata",
|
|
239
|
+
type: "jsonb",
|
|
240
|
+
description: "Additional resource metadata as JSON. Example:",
|
|
241
|
+
example: {
|
|
242
|
+
preferences: { language: "en", timezone: "UTC" },
|
|
243
|
+
tags: ["premium", "beta-user"]
|
|
244
|
+
},
|
|
245
|
+
constraints: [{ type: "nullable", value: true }]
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
name: "createdAt",
|
|
249
|
+
type: "timestamp",
|
|
250
|
+
description: "When the resource record was first created",
|
|
251
|
+
constraints: [{ type: "nullable", value: false }]
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
name: "updatedAt",
|
|
255
|
+
type: "timestamp",
|
|
256
|
+
description: "When the working memory was last updated",
|
|
257
|
+
constraints: [{ type: "nullable", value: false }]
|
|
258
|
+
}
|
|
259
|
+
]}
|
|
260
|
+
/>
|
|
261
|
+
|
|
262
|
+
**Note**: This table is only created and used by storage adapters that support resource-scoped working memory (LibSQL, PostgreSQL, Upstash). Other storage adapters will provide helpful error messages if resource-scoped memory is attempted.
|
|
263
|
+
|
|
215
264
|
</Tabs.Tab>
|
|
216
265
|
<Tabs.Tab>
|
|
217
266
|
When `suspend` is called on a workflow, its state is saved in the following format. When `resume` is called, that state is rehydrated.
|