@mastra/mcp-docs-server 1.0.0-beta.10 → 1.0.0-beta.13
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/%40mastra%2Fagent-builder.md +12 -12
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +50 -50
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +109 -109
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +39 -39
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +39 -39
- package/.docs/organized/changelogs/%40mastra%2Fconvex.md +38 -0
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +264 -264
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +37 -37
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +39 -39
- package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Flance.md +39 -39
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +22 -22
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +13 -13
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +39 -39
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +39 -39
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +104 -104
- package/.docs/organized/changelogs/%40mastra%2Freact.md +66 -0
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +59 -59
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +39 -39
- package/.docs/organized/changelogs/create-mastra.md +31 -31
- package/.docs/organized/changelogs/mastra.md +49 -49
- package/.docs/organized/code-examples/quick-start.md +0 -4
- package/.docs/organized/code-examples/stock-price-tool.md +21 -2
- package/.docs/raw/agents/agent-approval.mdx +136 -2
- package/.docs/raw/agents/agent-memory.mdx +4 -4
- package/.docs/raw/agents/guardrails.mdx +44 -7
- package/.docs/raw/agents/networks.mdx +1 -1
- package/.docs/raw/agents/overview.mdx +2 -2
- package/.docs/raw/agents/processors.mdx +151 -0
- package/.docs/raw/agents/using-tools.mdx +1 -1
- package/.docs/raw/course/01-first-agent/07-creating-your-agent.md +1 -2
- package/.docs/raw/course/01-first-agent/12-connecting-tool-to-agent.md +1 -1
- package/.docs/raw/course/01-first-agent/16-adding-memory-to-agent.md +1 -2
- package/.docs/raw/course/02-agent-tools-mcp/05-updating-your-agent.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/10-updating-agent-instructions-zapier.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/16-updating-agent-instructions-github.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/21-updating-agent-instructions-hackernews.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/27-updating-agent-instructions-filesystem.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/31-enhancing-memory-configuration.md +2 -2
- package/.docs/raw/course/03-agent-memory/04-creating-basic-memory-agent.md +1 -2
- package/.docs/raw/course/03-agent-memory/08-configuring-conversation-history.md +1 -2
- package/.docs/raw/course/03-agent-memory/16-configuring-semantic-recall.md +3 -4
- package/.docs/raw/course/03-agent-memory/21-configuring-working-memory.md +2 -3
- package/.docs/raw/course/03-agent-memory/22-custom-working-memory-templates.md +2 -3
- package/.docs/raw/course/03-agent-memory/25-combining-memory-features.md +1 -2
- package/.docs/raw/course/03-agent-memory/27-creating-learning-assistant.md +2 -3
- package/.docs/raw/course/04-workflows/11-creating-an-ai-agent.md +2 -3
- package/.docs/raw/deployment/cloud-providers.mdx +20 -0
- package/.docs/raw/deployment/{building-mastra.mdx → mastra-server.mdx} +2 -2
- package/.docs/raw/deployment/monorepo.mdx +23 -44
- package/.docs/raw/deployment/overview.mdx +28 -53
- package/.docs/raw/deployment/web-framework.mdx +12 -14
- package/.docs/raw/getting-started/mcp-docs-server.mdx +57 -0
- package/.docs/raw/getting-started/start.mdx +10 -1
- package/.docs/raw/getting-started/studio.mdx +25 -2
- package/.docs/raw/guides/build-your-ui/ai-sdk-ui.mdx +1021 -67
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/aws-lambda.mdx +3 -6
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/azure-app-services.mdx +4 -6
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/cloudflare-deployer.mdx +4 -0
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/digital-ocean.mdx +3 -6
- package/.docs/raw/guides/deployment/index.mdx +32 -0
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/netlify-deployer.mdx +4 -0
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/vercel-deployer.mdx +4 -0
- package/.docs/raw/guides/getting-started/express.mdx +71 -152
- package/.docs/raw/guides/getting-started/hono.mdx +227 -0
- package/.docs/raw/guides/getting-started/next-js.mdx +173 -63
- package/.docs/raw/guides/getting-started/vite-react.mdx +307 -137
- package/.docs/raw/guides/guide/research-assistant.mdx +4 -4
- package/.docs/raw/guides/migrations/upgrade-to-v1/agent.mdx +70 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/client.mdx +17 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/overview.mdx +6 -0
- package/.docs/raw/index.mdx +1 -1
- package/.docs/raw/{deployment/mastra-cloud → mastra-cloud}/dashboard.mdx +2 -6
- package/.docs/raw/{deployment/mastra-cloud → mastra-cloud}/observability.mdx +1 -5
- package/.docs/raw/{deployment/mastra-cloud → mastra-cloud}/overview.mdx +2 -6
- package/.docs/raw/{deployment/mastra-cloud → mastra-cloud}/setting-up.mdx +3 -6
- package/.docs/raw/memory/overview.mdx +1 -1
- package/.docs/raw/memory/storage/memory-with-libsql.mdx +1 -1
- package/.docs/raw/memory/storage/memory-with-mongodb.mdx +1 -1
- package/.docs/raw/memory/storage/memory-with-pg.mdx +1 -1
- package/.docs/raw/memory/storage/memory-with-upstash.mdx +1 -1
- package/.docs/raw/{server-db/storage.mdx → memory/storage/overview.mdx} +2 -2
- package/.docs/raw/observability/logging.mdx +1 -1
- package/.docs/raw/observability/tracing/exporters/cloud.mdx +1 -1
- package/.docs/raw/observability/tracing/exporters/default.mdx +1 -1
- package/.docs/raw/rag/chunking-and-embedding.mdx +12 -25
- package/.docs/raw/rag/graph-rag.mdx +220 -0
- package/.docs/raw/rag/overview.mdx +1 -2
- package/.docs/raw/rag/retrieval.mdx +13 -29
- package/.docs/raw/rag/vector-databases.mdx +7 -3
- package/.docs/raw/reference/agents/agent.mdx +11 -4
- package/.docs/raw/reference/agents/getDefaultGenerateOptions.mdx +1 -1
- package/.docs/raw/reference/agents/getDefaultOptions.mdx +1 -1
- package/.docs/raw/reference/agents/getDefaultStreamOptions.mdx +1 -1
- package/.docs/raw/reference/agents/getInstructions.mdx +1 -1
- package/.docs/raw/reference/agents/getLLM.mdx +1 -1
- package/.docs/raw/reference/agents/getMemory.mdx +1 -1
- package/.docs/raw/reference/agents/getModel.mdx +1 -1
- package/.docs/raw/reference/agents/listScorers.mdx +1 -1
- package/.docs/raw/reference/ai-sdk/chat-route.mdx +1 -1
- package/.docs/raw/reference/ai-sdk/handle-chat-stream.mdx +1 -1
- package/.docs/raw/reference/ai-sdk/handle-network-stream.mdx +1 -1
- package/.docs/raw/reference/ai-sdk/handle-workflow-stream.mdx +1 -1
- package/.docs/raw/reference/ai-sdk/network-route.mdx +1 -1
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-v4-messages.mdx +127 -0
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-v5-messages.mdx +107 -0
- package/.docs/raw/reference/ai-sdk/workflow-route.mdx +1 -1
- package/.docs/raw/reference/auth/auth0.mdx +1 -1
- package/.docs/raw/reference/auth/clerk.mdx +1 -1
- package/.docs/raw/reference/auth/firebase.mdx +1 -1
- package/.docs/raw/reference/auth/jwt.mdx +1 -1
- package/.docs/raw/reference/auth/supabase.mdx +1 -1
- package/.docs/raw/reference/auth/workos.mdx +1 -1
- package/.docs/raw/reference/cli/mastra.mdx +1 -1
- package/.docs/raw/reference/client-js/mastra-client.mdx +1 -1
- package/.docs/raw/reference/client-js/workflows.mdx +20 -0
- package/.docs/raw/reference/core/getServer.mdx +3 -3
- package/.docs/raw/reference/core/getStorage.mdx +1 -1
- package/.docs/raw/reference/core/getStoredAgentById.mdx +1 -1
- package/.docs/raw/reference/core/listStoredAgents.mdx +1 -1
- package/.docs/raw/reference/core/setStorage.mdx +1 -1
- package/.docs/raw/reference/logging/pino-logger.mdx +1 -1
- package/.docs/raw/reference/processors/processor-interface.mdx +314 -13
- package/.docs/raw/reference/rag/database-config.mdx +1 -1
- package/.docs/raw/reference/server/create-route.mdx +1 -1
- package/.docs/raw/reference/server/express-adapter.mdx +4 -4
- package/.docs/raw/reference/server/hono-adapter.mdx +4 -4
- package/.docs/raw/reference/server/mastra-server.mdx +2 -2
- package/.docs/raw/reference/server/routes.mdx +28 -1
- package/.docs/raw/reference/streaming/ChunkType.mdx +23 -2
- package/.docs/raw/reference/streaming/agents/stream.mdx +38 -29
- package/.docs/raw/reference/streaming/workflows/stream.mdx +33 -20
- package/.docs/raw/reference/tools/create-tool.mdx +23 -1
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +3 -3
- package/.docs/raw/reference/tools/vector-query-tool.mdx +3 -3
- package/.docs/raw/reference/workflows/run-methods/startAsync.mdx +143 -0
- package/.docs/raw/reference/workflows/workflow-methods/create-run.mdx +35 -0
- package/.docs/raw/reference/workflows/workflow-methods/foreach.mdx +68 -3
- package/.docs/raw/reference/workflows/workflow.mdx +37 -0
- package/.docs/raw/{auth → server/auth}/auth0.mdx +1 -1
- package/.docs/raw/{auth → server/auth}/clerk.mdx +1 -1
- package/.docs/raw/{auth → server/auth}/firebase.mdx +1 -1
- package/.docs/raw/{auth → server/auth}/index.mdx +6 -6
- package/.docs/raw/{auth → server/auth}/jwt.mdx +1 -1
- package/.docs/raw/{auth → server/auth}/supabase.mdx +1 -1
- package/.docs/raw/{auth → server/auth}/workos.mdx +1 -1
- package/.docs/raw/{server-db → server}/custom-adapters.mdx +3 -3
- package/.docs/raw/{server-db → server}/custom-api-routes.mdx +1 -1
- package/.docs/raw/{server-db → server}/mastra-client.mdx +2 -2
- package/.docs/raw/{server-db → server}/mastra-server.mdx +12 -10
- package/.docs/raw/{server-db → server}/middleware.mdx +2 -2
- package/.docs/raw/{server-db → server}/request-context.mdx +3 -3
- package/.docs/raw/{server-db → server}/server-adapters.mdx +6 -6
- package/.docs/raw/tools-mcp/overview.mdx +2 -2
- package/.docs/raw/workflows/control-flow.mdx +348 -2
- package/.docs/raw/workflows/error-handling.mdx +162 -1
- package/.docs/raw/workflows/overview.mdx +2 -2
- package/CHANGELOG.md +21 -0
- package/package.json +5 -5
- package/.docs/organized/changelogs/%40internal%2Fai-sdk-v4.md +0 -1
- package/.docs/raw/deployment/cloud-providers/index.mdx +0 -55
- /package/.docs/raw/{deployment/cloud-providers → guides/deployment}/amazon-ec2.mdx +0 -0
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# @mastra/upstash
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Preserve error details when thrown from workflow steps ([#10992](https://github.com/mastra-ai/mastra/pull/10992))
|
|
8
|
+
|
|
9
|
+
Workflow errors now retain custom properties like `statusCode`, `responseHeaders`, and `cause` chains. This enables error-specific recovery logic in your applications.
|
|
10
|
+
|
|
11
|
+
**Before:**
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
const result = await workflow.execute({ input });
|
|
15
|
+
if (result.status === 'failed') {
|
|
16
|
+
// Custom error properties were lost
|
|
17
|
+
console.log(result.error); // "Step execution failed" (just a string)
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**After:**
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
const result = await workflow.execute({ input });
|
|
25
|
+
if (result.status === 'failed') {
|
|
26
|
+
// Custom properties are preserved
|
|
27
|
+
console.log(result.error.message); // "Step execution failed"
|
|
28
|
+
console.log(result.error.statusCode); // 429
|
|
29
|
+
console.log(result.error.cause?.name); // "RateLimitError"
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Type change:** `WorkflowState.error` and `WorkflowRunState.error` types changed from `string | Error` to `SerializedError`.
|
|
34
|
+
|
|
35
|
+
Other changes:
|
|
36
|
+
- Added `UpdateWorkflowStateOptions` type for workflow state updates
|
|
37
|
+
|
|
38
|
+
- Updated dependencies [[`d5ed981`](https://github.com/mastra-ai/mastra/commit/d5ed981c8701c1b8a27a5f35a9a2f7d9244e695f), [`9650cce`](https://github.com/mastra-ai/mastra/commit/9650cce52a1d917ff9114653398e2a0f5c3ba808), [`932d63d`](https://github.com/mastra-ai/mastra/commit/932d63dd51be9c8bf1e00e3671fe65606c6fb9cd), [`b760b73`](https://github.com/mastra-ai/mastra/commit/b760b731aca7c8a3f041f61d57a7f125ae9cb215), [`695a621`](https://github.com/mastra-ai/mastra/commit/695a621528bdabeb87f83c2277cf2bb084c7f2b4), [`2b459f4`](https://github.com/mastra-ai/mastra/commit/2b459f466fd91688eeb2a44801dc23f7f8a887ab), [`486352b`](https://github.com/mastra-ai/mastra/commit/486352b66c746602b68a95839f830de14c7fb8c0), [`09e4bae`](https://github.com/mastra-ai/mastra/commit/09e4bae18dd5357d2ae078a4a95a2af32168ab08), [`24b76d8`](https://github.com/mastra-ai/mastra/commit/24b76d8e17656269c8ed09a0c038adb9cc2ae95a), [`243a823`](https://github.com/mastra-ai/mastra/commit/243a8239c5906f5c94e4f78b54676793f7510ae3), [`486352b`](https://github.com/mastra-ai/mastra/commit/486352b66c746602b68a95839f830de14c7fb8c0), [`c61fac3`](https://github.com/mastra-ai/mastra/commit/c61fac3add96f0dcce0208c07415279e2537eb62), [`6f14f70`](https://github.com/mastra-ai/mastra/commit/6f14f706ccaaf81b69544b6c1b75ab66a41e5317), [`09e4bae`](https://github.com/mastra-ai/mastra/commit/09e4bae18dd5357d2ae078a4a95a2af32168ab08), [`4524734`](https://github.com/mastra-ai/mastra/commit/45247343e384717a7c8404296275c56201d6470f), [`2a53598`](https://github.com/mastra-ai/mastra/commit/2a53598c6d8cfeb904a7fc74e57e526d751c8fa6), [`c7cd3c7`](https://github.com/mastra-ai/mastra/commit/c7cd3c7a187d7aaf79e2ca139de328bf609a14b4), [`847c212`](https://github.com/mastra-ai/mastra/commit/847c212caba7df0d6f2fc756b494ac3c75c3720d), [`6f941c4`](https://github.com/mastra-ai/mastra/commit/6f941c438ca5f578619788acc7608fc2e23bd176)]:
|
|
39
|
+
- @mastra/core@1.0.0-beta.12
|
|
40
|
+
|
|
3
41
|
## 1.0.0-beta.6
|
|
4
42
|
|
|
5
43
|
### Patch Changes
|
|
@@ -460,43 +498,5 @@
|
|
|
460
498
|
|
|
461
499
|
## 0.15.1-alpha.0
|
|
462
500
|
|
|
463
|
-
### Patch Changes
|
|
464
|
-
|
|
465
|
-
- Add resource id to workflow run snapshots ([#7740](https://github.com/mastra-ai/mastra/pull/7740))
|
|
466
|
-
|
|
467
|
-
- Updated dependencies [[`547c621`](https://github.com/mastra-ai/mastra/commit/547c62104af3f7a551b3754e9cbdf0a3fbba15e4)]:
|
|
468
|
-
- @mastra/core@0.16.4-alpha.1
|
|
469
|
-
|
|
470
|
-
## 0.15.0
|
|
471
|
-
|
|
472
|
-
### Minor Changes
|
|
473
|
-
|
|
474
|
-
- 376913a: Update peerdeps of @mastra/core
|
|
475
|
-
|
|
476
|
-
### Patch Changes
|
|
477
|
-
|
|
478
|
-
- 6f5eb7a: Throw if an empty or whitespace-only threadId is passed when getting messages
|
|
479
|
-
- Updated dependencies [8fbf79e]
|
|
480
|
-
- Updated dependencies [fd83526]
|
|
481
|
-
- Updated dependencies [d0b90ab]
|
|
482
|
-
- Updated dependencies [6f5eb7a]
|
|
483
|
-
- Updated dependencies [a01cf14]
|
|
484
|
-
- Updated dependencies [a9e50ee]
|
|
485
|
-
- Updated dependencies [5397eb4]
|
|
486
|
-
- Updated dependencies [c9f4e4a]
|
|
487
|
-
- Updated dependencies [0acbc80]
|
|
488
|
-
- @mastra/core@0.16.0
|
|
489
|
-
|
|
490
|
-
## 0.15.0-alpha.1
|
|
491
|
-
|
|
492
|
-
### Minor Changes
|
|
493
|
-
|
|
494
|
-
- 376913a: Update peerdeps of @mastra/core
|
|
495
|
-
|
|
496
|
-
### Patch Changes
|
|
497
|
-
|
|
498
|
-
- Updated dependencies [8fbf79e]
|
|
499
|
-
- @mastra/core@0.16.0-alpha.1
|
|
500
|
-
|
|
501
501
|
|
|
502
|
-
...
|
|
502
|
+
... 2349 more lines hidden. See full changelog in package directory.
|
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# create-mastra
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Auto resume suspended tools if `autoResumeSuspendedTools: true` ([#11157](https://github.com/mastra-ai/mastra/pull/11157))
|
|
8
|
+
|
|
9
|
+
The flag can be added to `defaultAgentOptions` when creating the agent or to options in `agent.stream` or `agent.generate`
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
const agent = new Agent({
|
|
13
|
+
//...agent information,
|
|
14
|
+
defaultAgentOptions: {
|
|
15
|
+
autoResumeSuspendedTools: true,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
- Add `Run` instance to client-js. `workflow.createRun` returns the `Run` instance which can be used for the different run methods. ([#11207](https://github.com/mastra-ai/mastra/pull/11207))
|
|
21
|
+
With this change, run methods cannot be called directly on workflow instance anymore
|
|
22
|
+
|
|
23
|
+
```diff
|
|
24
|
+
- const result = await workflow.stream({ runId: '123', inputData: { ... } });
|
|
25
|
+
+ const run = await workflow.createRun({ runId: '123' });
|
|
26
|
+
+ const stream = await run.stream({ inputData: { ... } });
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
- fix isTopLevelSpan value definition on SpanScoring to properly recognize lack of span?.parentSpanId value (null or empty string) ([#11083](https://github.com/mastra-ai/mastra/pull/11083))
|
|
30
|
+
|
|
31
|
+
## 1.0.0-beta.9
|
|
32
|
+
|
|
3
33
|
## 1.0.0-beta.8
|
|
4
34
|
|
|
5
35
|
### Patch Changes
|
|
@@ -468,35 +498,5 @@
|
|
|
468
498
|
|
|
469
499
|
- fix minor playground stuff for observability ([#7765](https://github.com/mastra-ai/mastra/pull/7765))
|
|
470
500
|
|
|
471
|
-
- Handle zod intersections in dynamic form ([#7768](https://github.com/mastra-ai/mastra/pull/7768))
|
|
472
|
-
|
|
473
|
-
- Playground ui -pass runtimeContext to client SDK get methods ([#7767](https://github.com/mastra-ai/mastra/pull/7767))
|
|
474
|
-
|
|
475
|
-
## 0.12.3
|
|
476
|
-
|
|
477
|
-
### Patch Changes
|
|
478
|
-
|
|
479
|
-
- Client SDK Agents, Mastra server - support runtimeContext with GET requests ([#7734](https://github.com/mastra-ai/mastra/pull/7734))
|
|
480
|
-
|
|
481
|
-
## 0.12.3-alpha.1
|
|
482
|
-
|
|
483
|
-
### Patch Changes
|
|
484
|
-
|
|
485
|
-
- Client SDK Agents, Mastra server - support runtimeContext with GET requests ([#7734](https://github.com/mastra-ai/mastra/pull/7734))
|
|
486
|
-
|
|
487
|
-
## 0.12.3-alpha.0
|
|
488
|
-
|
|
489
|
-
## 0.12.2
|
|
490
|
-
|
|
491
|
-
## 0.12.2-alpha.0
|
|
492
|
-
|
|
493
|
-
## 0.12.1
|
|
494
|
-
|
|
495
|
-
### Patch Changes
|
|
496
|
-
|
|
497
|
-
- dependencies updates: ([#7544](https://github.com/mastra-ai/mastra/pull/7544))
|
|
498
|
-
- Updated dependency [`fs-extra@^11.3.1` ↗︎](https://www.npmjs.com/package/fs-extra/v/11.3.1) (from `^11.3.0`, in `dependencies`)
|
|
499
|
-
|
|
500
|
-
- add workflow streaming in agent thread ([#7506](https://github.com/mastra-ai/mastra/pull/7506))
|
|
501
501
|
|
|
502
|
-
...
|
|
502
|
+
... 1688 more lines hidden. See full changelog in package directory.
|
|
@@ -1,5 +1,53 @@
|
|
|
1
1
|
# mastra
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Auto resume suspended tools if `autoResumeSuspendedTools: true` ([#11157](https://github.com/mastra-ai/mastra/pull/11157))
|
|
8
|
+
|
|
9
|
+
The flag can be added to `defaultAgentOptions` when creating the agent or to options in `agent.stream` or `agent.generate`
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
const agent = new Agent({
|
|
13
|
+
//...agent information,
|
|
14
|
+
defaultAgentOptions: {
|
|
15
|
+
autoResumeSuspendedTools: true,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
- Add `Run` instance to client-js. `workflow.createRun` returns the `Run` instance which can be used for the different run methods. ([#11207](https://github.com/mastra-ai/mastra/pull/11207))
|
|
21
|
+
With this change, run methods cannot be called directly on workflow instance anymore
|
|
22
|
+
|
|
23
|
+
```diff
|
|
24
|
+
- const result = await workflow.stream({ runId: '123', inputData: { ... } });
|
|
25
|
+
+ const run = await workflow.createRun({ runId: '123' });
|
|
26
|
+
+ const stream = await run.stream({ inputData: { ... } });
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
- Fix the development experience of the studio. It was not able to resolve the running instance because the index.html variables were not replaced in the vite dev standalone config ([#11085](https://github.com/mastra-ai/mastra/pull/11085))
|
|
30
|
+
|
|
31
|
+
- fix isTopLevelSpan value definition on SpanScoring to properly recognize lack of span?.parentSpanId value (null or empty string) ([#11083](https://github.com/mastra-ai/mastra/pull/11083))
|
|
32
|
+
|
|
33
|
+
- Updated dependencies [[`d5ed981`](https://github.com/mastra-ai/mastra/commit/d5ed981c8701c1b8a27a5f35a9a2f7d9244e695f), [`9650cce`](https://github.com/mastra-ai/mastra/commit/9650cce52a1d917ff9114653398e2a0f5c3ba808), [`932d63d`](https://github.com/mastra-ai/mastra/commit/932d63dd51be9c8bf1e00e3671fe65606c6fb9cd), [`b760b73`](https://github.com/mastra-ai/mastra/commit/b760b731aca7c8a3f041f61d57a7f125ae9cb215), [`695a621`](https://github.com/mastra-ai/mastra/commit/695a621528bdabeb87f83c2277cf2bb084c7f2b4), [`2b459f4`](https://github.com/mastra-ai/mastra/commit/2b459f466fd91688eeb2a44801dc23f7f8a887ab), [`486352b`](https://github.com/mastra-ai/mastra/commit/486352b66c746602b68a95839f830de14c7fb8c0), [`09e4bae`](https://github.com/mastra-ai/mastra/commit/09e4bae18dd5357d2ae078a4a95a2af32168ab08), [`24b76d8`](https://github.com/mastra-ai/mastra/commit/24b76d8e17656269c8ed09a0c038adb9cc2ae95a), [`243a823`](https://github.com/mastra-ai/mastra/commit/243a8239c5906f5c94e4f78b54676793f7510ae3), [`486352b`](https://github.com/mastra-ai/mastra/commit/486352b66c746602b68a95839f830de14c7fb8c0), [`c61fac3`](https://github.com/mastra-ai/mastra/commit/c61fac3add96f0dcce0208c07415279e2537eb62), [`6f14f70`](https://github.com/mastra-ai/mastra/commit/6f14f706ccaaf81b69544b6c1b75ab66a41e5317), [`09e4bae`](https://github.com/mastra-ai/mastra/commit/09e4bae18dd5357d2ae078a4a95a2af32168ab08), [`6375f52`](https://github.com/mastra-ai/mastra/commit/6375f52c219305abef6f2026b4eaf8ac2fa5f1c0), [`4524734`](https://github.com/mastra-ai/mastra/commit/45247343e384717a7c8404296275c56201d6470f), [`2a53598`](https://github.com/mastra-ai/mastra/commit/2a53598c6d8cfeb904a7fc74e57e526d751c8fa6), [`c7cd3c7`](https://github.com/mastra-ai/mastra/commit/c7cd3c7a187d7aaf79e2ca139de328bf609a14b4), [`09e4bae`](https://github.com/mastra-ai/mastra/commit/09e4bae18dd5357d2ae078a4a95a2af32168ab08), [`847c212`](https://github.com/mastra-ai/mastra/commit/847c212caba7df0d6f2fc756b494ac3c75c3720d), [`6f941c4`](https://github.com/mastra-ai/mastra/commit/6f941c438ca5f578619788acc7608fc2e23bd176)]:
|
|
34
|
+
- @mastra/core@1.0.0-beta.12
|
|
35
|
+
- @mastra/deployer@1.0.0-beta.12
|
|
36
|
+
|
|
37
|
+
## 1.0.0-beta.9
|
|
38
|
+
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- Allow to run mastra studio from anywhere in the file system, and not necessarily inside a mastra project ([#11067](https://github.com/mastra-ai/mastra/pull/11067))
|
|
42
|
+
|
|
43
|
+
- Make sure to verify that a mastra instance is running on server.port OR 4111 by default ([#11066](https://github.com/mastra-ai/mastra/pull/11066))
|
|
44
|
+
|
|
45
|
+
- Internal changes to enable a custom base path for Mastra Studio ([#10441](https://github.com/mastra-ai/mastra/pull/10441))
|
|
46
|
+
|
|
47
|
+
- Updated dependencies [[`38380b6`](https://github.com/mastra-ai/mastra/commit/38380b60fca905824bdf6b43df307a58efb1aa15), [`798d0c7`](https://github.com/mastra-ai/mastra/commit/798d0c740232653b1d754870e6b43a55c364ffe2), [`ffe84d5`](https://github.com/mastra-ai/mastra/commit/ffe84d54f3b0f85167fe977efd027dba027eb998), [`2c212e7`](https://github.com/mastra-ai/mastra/commit/2c212e704c90e2db83d4109e62c03f0f6ebd2667), [`4ca4306`](https://github.com/mastra-ai/mastra/commit/4ca430614daa5fa04730205a302a43bf4accfe9f), [`2c212e7`](https://github.com/mastra-ai/mastra/commit/2c212e704c90e2db83d4109e62c03f0f6ebd2667), [`3bf6c5f`](https://github.com/mastra-ai/mastra/commit/3bf6c5f104c25226cd84e0c77f9dec15f2cac2db)]:
|
|
48
|
+
- @mastra/core@1.0.0-beta.11
|
|
49
|
+
- @mastra/deployer@1.0.0-beta.11
|
|
50
|
+
|
|
3
51
|
## 1.0.0-beta.8
|
|
4
52
|
|
|
5
53
|
### Minor Changes
|
|
@@ -450,53 +498,5 @@
|
|
|
450
498
|
|
|
451
499
|
- Update peer dependencies to match core package version bump (0.21.0) ([#8626](https://github.com/mastra-ai/mastra/pull/8626))
|
|
452
500
|
|
|
453
|
-
- Refactor EntryList component and Scorer and Observability pages ([#8652](https://github.com/mastra-ai/mastra/pull/8652))
|
|
454
|
-
|
|
455
|
-
- Update peer dependencies to match core package version bump (0.21.0) ([#8686](https://github.com/mastra-ai/mastra/pull/8686))
|
|
456
|
-
|
|
457
|
-
- Updated dependencies [[`0fb6616`](https://github.com/mastra-ai/mastra/commit/0fb66169600ed2a3dc1297b1bfa8a7693ebb6e3c), [`b5a66b7`](https://github.com/mastra-ai/mastra/commit/b5a66b748a14fc8b3f63b04642ddb9621fbcc9e0), [`1dbd76a`](https://github.com/mastra-ai/mastra/commit/1dbd76aff29cc764d3a1ac7bb01172fe59cb5992), [`2ddb851`](https://github.com/mastra-ai/mastra/commit/2ddb8519c4b6f1d31be10ffd33b41d2b649a04ff), [`7b1ef57`](https://github.com/mastra-ai/mastra/commit/7b1ef57fc071c2aa2a2e32905b18cd88719c5a39), [`7b1ef57`](https://github.com/mastra-ai/mastra/commit/7b1ef57fc071c2aa2a2e32905b18cd88719c5a39), [`228228b`](https://github.com/mastra-ai/mastra/commit/228228b0b1de9291cb8887587f5cea1a8757ebad), [`b5a66b7`](https://github.com/mastra-ai/mastra/commit/b5a66b748a14fc8b3f63b04642ddb9621fbcc9e0), [`ee68e82`](https://github.com/mastra-ai/mastra/commit/ee68e8289ea4408d29849e899bc6e78b3bd4e843), [`228228b`](https://github.com/mastra-ai/mastra/commit/228228b0b1de9291cb8887587f5cea1a8757ebad), [`ea33930`](https://github.com/mastra-ai/mastra/commit/ea339301e82d6318257720d811b043014ee44064), [`b5a66b7`](https://github.com/mastra-ai/mastra/commit/b5a66b748a14fc8b3f63b04642ddb9621fbcc9e0), [`7b1ef57`](https://github.com/mastra-ai/mastra/commit/7b1ef57fc071c2aa2a2e32905b18cd88719c5a39), [`135d6f2`](https://github.com/mastra-ai/mastra/commit/135d6f22a326ed1dffff858700669dff09d2c9eb), [`59d036d`](https://github.com/mastra-ai/mastra/commit/59d036d4c2706b430b0e3f1f1e0ee853ce16ca04)]:
|
|
458
|
-
- @mastra/deployer@0.21.0-alpha.0
|
|
459
|
-
- @mastra/core@0.21.0-alpha.0
|
|
460
|
-
- @mastra/loggers@0.10.16-alpha.0
|
|
461
|
-
- @mastra/mcp@0.13.5-alpha.0
|
|
462
|
-
|
|
463
|
-
## 0.15.1
|
|
464
|
-
|
|
465
|
-
### Patch Changes
|
|
466
|
-
|
|
467
|
-
- Marked telemetry as disabled in the default template, in preperation for the Nov 4th deprecation. ([#8618](https://github.com/mastra-ai/mastra/pull/8618))
|
|
468
|
-
|
|
469
|
-
- Improve the overall flow of the `create-mastra` CLI by first asking all questions and then creating the project structure. If you skip entering an API key during the wizard, the `your-api-key` placeholder will now be added to an `.env.example` file instead of `.env`. ([#8603](https://github.com/mastra-ai/mastra/pull/8603))
|
|
470
|
-
|
|
471
|
-
- Updated dependencies [[`07eaf25`](https://github.com/mastra-ai/mastra/commit/07eaf25aada9e42235dbf905854de53da4d8121b), [`0d71771`](https://github.com/mastra-ai/mastra/commit/0d71771f5711164c79f8e80919bc84d6bffeb6bc), [`0d6e55e`](https://github.com/mastra-ai/mastra/commit/0d6e55ecc5a2e689cd4fc9c86525e0eb54d82372), [`68b1111`](https://github.com/mastra-ai/mastra/commit/68b11118a1303f93e9c0c157850c0751309304c5)]:
|
|
472
|
-
- @mastra/core@0.20.2
|
|
473
|
-
- @mastra/deployer@0.20.2
|
|
474
|
-
|
|
475
|
-
## 0.15.1-alpha.1
|
|
476
|
-
|
|
477
|
-
### Patch Changes
|
|
478
|
-
|
|
479
|
-
- Marked telemetry as disabled in the default template, in preperation for the Nov 4th deprecation. ([#8618](https://github.com/mastra-ai/mastra/pull/8618))
|
|
480
|
-
|
|
481
|
-
## 0.15.1-alpha.0
|
|
482
|
-
|
|
483
|
-
### Patch Changes
|
|
484
|
-
|
|
485
|
-
- Improve the overall flow of the `create-mastra` CLI by first asking all questions and then creating the project structure. If you skip entering an API key during the wizard, the `your-api-key` placeholder will now be added to an `.env.example` file instead of `.env`. ([#8603](https://github.com/mastra-ai/mastra/pull/8603))
|
|
486
|
-
|
|
487
|
-
- Updated dependencies [[`0d71771`](https://github.com/mastra-ai/mastra/commit/0d71771f5711164c79f8e80919bc84d6bffeb6bc), [`0d6e55e`](https://github.com/mastra-ai/mastra/commit/0d6e55ecc5a2e689cd4fc9c86525e0eb54d82372)]:
|
|
488
|
-
- @mastra/core@0.20.2-alpha.0
|
|
489
|
-
- @mastra/deployer@0.20.2-alpha.0
|
|
490
|
-
|
|
491
|
-
## 0.15.0
|
|
492
|
-
|
|
493
|
-
### Minor Changes
|
|
494
|
-
|
|
495
|
-
- Update peer dependencies to match core package version bump (0.20.1) ([#8589](https://github.com/mastra-ai/mastra/pull/8589))
|
|
496
|
-
|
|
497
|
-
### Patch Changes
|
|
498
|
-
|
|
499
|
-
- workflow run thread more visible ([#8539](https://github.com/mastra-ai/mastra/pull/8539))
|
|
500
|
-
|
|
501
501
|
|
|
502
|
-
...
|
|
502
|
+
... 6404 more lines hidden. See full changelog in package directory.
|
|
@@ -75,14 +75,10 @@ export const catOne = new Agent({
|
|
|
75
75
|
import { Mastra } from '@mastra/core/mastra';
|
|
76
76
|
import { PinoLogger } from '@mastra/loggers';
|
|
77
77
|
import { catOne } from './agents/agent';
|
|
78
|
-
import { logCatWorkflow as legacy_catWorkflow } from './legacy-workflows';
|
|
79
78
|
import { logCatWorkflow } from './workflows';
|
|
80
79
|
|
|
81
80
|
export const mastra = new Mastra({
|
|
82
81
|
agents: { catOne },
|
|
83
|
-
legacy_workflows: {
|
|
84
|
-
legacy_catWorkflow,
|
|
85
|
-
},
|
|
86
82
|
workflows: {
|
|
87
83
|
logCatWorkflow,
|
|
88
84
|
},
|
|
@@ -70,7 +70,26 @@ import { createTool } from '@mastra/core/tools';
|
|
|
70
70
|
import { z } from 'zod';
|
|
71
71
|
|
|
72
72
|
export const getStockPrice = async (symbol: string) => {
|
|
73
|
-
const
|
|
73
|
+
const response = await fetch(`https://mastra-stock-data.vercel.app/api/stock-data?symbol=${symbol}`);
|
|
74
|
+
|
|
75
|
+
if (!response.ok) {
|
|
76
|
+
const errorText = await response.text();
|
|
77
|
+
throw new Error(`Failed to fetch stock price for ${symbol}: ${response.status} ${errorText}`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
let data;
|
|
81
|
+
try {
|
|
82
|
+
data = await response.json();
|
|
83
|
+
} catch (error) {
|
|
84
|
+
throw new Error(
|
|
85
|
+
`Failed to parse JSON response for ${symbol}: ${error instanceof Error ? error.message : String(error)}`,
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (!data.prices || !data.prices['4. close']) {
|
|
90
|
+
throw new Error(`Invalid response format for symbol ${symbol}: ${JSON.stringify(data)}`);
|
|
91
|
+
}
|
|
92
|
+
|
|
74
93
|
return data.prices['4. close'];
|
|
75
94
|
};
|
|
76
95
|
|
|
@@ -80,7 +99,7 @@ export const stockPrices = createTool({
|
|
|
80
99
|
symbol: z.string(),
|
|
81
100
|
}),
|
|
82
101
|
description: `Fetches the last day's closing stock price for a given symbol`,
|
|
83
|
-
execute: async
|
|
102
|
+
execute: async (inputData, context) => {
|
|
84
103
|
console.log('Using tool to fetch stock price for', inputData.symbol);
|
|
85
104
|
return {
|
|
86
105
|
symbol: inputData.symbol,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "Agent Approval | Agents"
|
|
3
|
-
description: Learn how to require approvals
|
|
3
|
+
description: Learn how to require approvals, suspend tool execution, and automatically resume suspended tools while keeping humans in control of agent workflows.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Agent Approval
|
|
@@ -180,10 +180,144 @@ const handleResume = async () => {
|
|
|
180
180
|
|
|
181
181
|
```
|
|
182
182
|
|
|
183
|
+
## Automatic tool resumption
|
|
184
|
+
|
|
185
|
+
When using tools that call `suspend()`, you can enable automatic resumption so the agent resumes suspended tools based on the user's next message. This creates a conversational flow where users provide the required information naturally, without your application needing to call `resumeStream()` explicitly.
|
|
186
|
+
|
|
187
|
+
### Enabling auto-resume
|
|
188
|
+
|
|
189
|
+
Set `autoResumeSuspendedTools` to `true` in the agent's default options or when calling `stream()`:
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
import { Agent } from "@mastra/core/agent";
|
|
193
|
+
import { Memory } from "@mastra/memory";
|
|
194
|
+
|
|
195
|
+
// Option 1: In agent configuration
|
|
196
|
+
const agent = new Agent({
|
|
197
|
+
id: "my-agent",
|
|
198
|
+
name: "My Agent",
|
|
199
|
+
instructions: "You are a helpful assistant",
|
|
200
|
+
model: "openai/gpt-4o-mini",
|
|
201
|
+
tools: { weatherTool },
|
|
202
|
+
memory: new Memory(),
|
|
203
|
+
defaultOptions: {
|
|
204
|
+
autoResumeSuspendedTools: true,
|
|
205
|
+
},
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
// Option 2: Per-request
|
|
209
|
+
const stream = await agent.stream("What's the weather?", {
|
|
210
|
+
autoResumeSuspendedTools: true,
|
|
211
|
+
});
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### How it works
|
|
215
|
+
|
|
216
|
+
When `autoResumeSuspendedTools` is enabled:
|
|
217
|
+
|
|
218
|
+
1. A tool suspends execution by calling `suspend()` with a payload (e.g., requesting more information)
|
|
219
|
+
2. The suspension is persisted to memory along with the conversation
|
|
220
|
+
3. When the user sends their next message on the same thread, the agent:
|
|
221
|
+
- Detects the suspended tool from conversation history
|
|
222
|
+
- Extracts `resumeData` from the user's message based on the tool's `resumeSchema`
|
|
223
|
+
- Automatically resumes the tool with the extracted data
|
|
224
|
+
|
|
225
|
+
### Example
|
|
226
|
+
|
|
227
|
+
```typescript
|
|
228
|
+
import { createTool } from "@mastra/core/tools";
|
|
229
|
+
import { z } from "zod";
|
|
230
|
+
|
|
231
|
+
export const weatherTool = createTool({
|
|
232
|
+
id: "weather-info",
|
|
233
|
+
description: "Fetches weather information for a city",
|
|
234
|
+
suspendSchema: z.object({
|
|
235
|
+
message: z.string(),
|
|
236
|
+
}),
|
|
237
|
+
resumeSchema: z.object({
|
|
238
|
+
city: z.string(),
|
|
239
|
+
}),
|
|
240
|
+
execute: async (_inputData, context) => {
|
|
241
|
+
// Check if this is a resume with data
|
|
242
|
+
if (!context?.agent?.resumeData) {
|
|
243
|
+
// First call - suspend and ask for the city
|
|
244
|
+
return context?.agent?.suspend({
|
|
245
|
+
message: "What city do you want to know the weather for?",
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// Resume call - city was extracted from user's message
|
|
250
|
+
const { city } = context.agent.resumeData;
|
|
251
|
+
const response = await fetch(`https://wttr.in/${city}?format=3`);
|
|
252
|
+
const weather = await response.text();
|
|
253
|
+
|
|
254
|
+
return { city, weather };
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
const agent = new Agent({
|
|
259
|
+
id: "my-agent",
|
|
260
|
+
name: "My Agent",
|
|
261
|
+
instructions: "You are a helpful assistant",
|
|
262
|
+
model: "openai/gpt-4o-mini",
|
|
263
|
+
tools: { weatherTool },
|
|
264
|
+
memory: new Memory(),
|
|
265
|
+
defaultOptions: {
|
|
266
|
+
autoResumeSuspendedTools: true,
|
|
267
|
+
},
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
const stream = await agent.stream("What's the weather like?");
|
|
271
|
+
|
|
272
|
+
for await (const chunk of stream.fullStream) {
|
|
273
|
+
if (chunk.type === "tool-call-suspended") {
|
|
274
|
+
console.log(chunk.payload.suspendPayload);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const handleResume = async () => {
|
|
279
|
+
const resumedStream = await agent.stream("San Francisco");
|
|
280
|
+
|
|
281
|
+
for await (const chunk of resumedStream.textStream) {
|
|
282
|
+
process.stdout.write(chunk);
|
|
283
|
+
}
|
|
284
|
+
process.stdout.write("\n");
|
|
285
|
+
};
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
**Conversation flow:**
|
|
289
|
+
|
|
290
|
+
```
|
|
291
|
+
User: "What's the weather like?"
|
|
292
|
+
Agent: "What city do you want to know the weather for?"
|
|
293
|
+
|
|
294
|
+
User: "San Francisco"
|
|
295
|
+
Agent: "The weather in San Francisco is: San Francisco: ☀️ +72°F"
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
The second message automatically resumes the suspended tool - the agent extracts `{ city: "San Francisco" }` from the user's message and passes it as `resumeData`.
|
|
299
|
+
|
|
300
|
+
### Requirements
|
|
301
|
+
|
|
302
|
+
For automatic tool resumption to work:
|
|
303
|
+
|
|
304
|
+
- **Memory configured**: The agent needs memory to track suspended tools across messages
|
|
305
|
+
- **Same thread**: The follow-up message must use the same memory thread and resource identifiers
|
|
306
|
+
- **`resumeSchema` defined**: The tool must define a `resumeSchema` so the agent knows what data structure to extract from the user's message
|
|
307
|
+
|
|
308
|
+
### Manual vs automatic resumption
|
|
309
|
+
|
|
310
|
+
| Approach | Use case |
|
|
311
|
+
|----------|----------|
|
|
312
|
+
| Manual (`resumeStream()`) | Programmatic control, webhooks, button clicks, external triggers |
|
|
313
|
+
| Automatic (`autoResumeSuspendedTools`) | Conversational flows where users provide resume data in natural language |
|
|
314
|
+
|
|
315
|
+
Both approaches work with the same tool definitions. Automatic resumption triggers only when suspended tools exist in the conversation history and the user sends a new message on the same thread.
|
|
316
|
+
|
|
183
317
|
## Related
|
|
184
318
|
|
|
185
319
|
- [Using Tools](./using-tools)
|
|
186
320
|
- [Agent Overview](./overview)
|
|
187
321
|
- [Tools Overview](../mcp/overview)
|
|
188
322
|
- [Agent Memory](./agent-memory)
|
|
189
|
-
- [Request Context](/docs/v1/server
|
|
323
|
+
- [Request Context](/docs/v1/server/request-context)
|
|
@@ -26,7 +26,7 @@ npm install @mastra/memory@beta @mastra/libsql@beta
|
|
|
26
26
|
|
|
27
27
|
## Storage providers
|
|
28
28
|
|
|
29
|
-
Memory requires a storage provider to persist conversation history, including user messages and agent responses. For more details on available providers and how storage works in Mastra, see the [Storage](/docs/v1/
|
|
29
|
+
Memory requires a storage provider to persist conversation history, including user messages and agent responses. For more details on available providers and how storage works in Mastra, see the [Storage](/docs/v1/memory/storage/overview) documentation.
|
|
30
30
|
|
|
31
31
|
## Configuring memory
|
|
32
32
|
|
|
@@ -141,7 +141,7 @@ To learn more about memory see the [Memory](../memory/overview) documentation.
|
|
|
141
141
|
|
|
142
142
|
## Using `RequestContext`
|
|
143
143
|
|
|
144
|
-
Use [RequestContext](/docs/v1/server
|
|
144
|
+
Use [RequestContext](/docs/v1/server/request-context) to access request-specific values. This lets you conditionally select different memory or storage configurations based on the context of the request.
|
|
145
145
|
|
|
146
146
|
```typescript title="src/mastra/agents/memory-agent.ts" showLineNumbers
|
|
147
147
|
export type UserTier = {
|
|
@@ -170,7 +170,7 @@ export const memoryAgent = new Agent({
|
|
|
170
170
|
|
|
171
171
|
:::note
|
|
172
172
|
|
|
173
|
-
See [Request Context](/docs/v1/server
|
|
173
|
+
See [Request Context](/docs/v1/server/request-context) docs for more information.
|
|
174
174
|
|
|
175
175
|
:::
|
|
176
176
|
|
|
@@ -179,4 +179,4 @@ See [Request Context](/docs/v1/server-db/request-context) docs for more informat
|
|
|
179
179
|
- [Working Memory](../memory/working-memory)
|
|
180
180
|
- [Semantic Recall](../memory/semantic-recall)
|
|
181
181
|
- [Threads and Resources](../memory/threads-and-resources)
|
|
182
|
-
- [Request Context](/docs/v1/server
|
|
182
|
+
- [Request Context](/docs/v1/server/request-context)
|
|
@@ -195,7 +195,7 @@ const scrubbedAgent = new Agent({
|
|
|
195
195
|
> See [SystemPromptScrubber](/reference/v1/processors/system-prompt-scrubber) for a full list of configuration options.
|
|
196
196
|
|
|
197
197
|
:::note
|
|
198
|
-
When streaming responses over HTTP, Mastra redacts sensitive request data (system prompts, tool definitions, API keys) from stream chunks at the server level by default. See [Stream data redaction](/docs/v1/server
|
|
198
|
+
When streaming responses over HTTP, Mastra redacts sensitive request data (system prompts, tool definitions, API keys) from stream chunks at the server level by default. See [Stream data redaction](/docs/v1/server/mastra-server#stream-data-redaction) for details.
|
|
199
199
|
:::
|
|
200
200
|
|
|
201
201
|
## Hybrid processors
|
|
@@ -327,9 +327,9 @@ export const privateAgent = new Agent({
|
|
|
327
327
|
|
|
328
328
|
### Handling blocked requests
|
|
329
329
|
|
|
330
|
-
When a processor blocks a request, the agent will still return successfully without throwing an error. To handle blocked requests, check for `tripwire`
|
|
330
|
+
When a processor blocks a request, the agent will still return successfully without throwing an error. To handle blocked requests, check for `tripwire` in the response.
|
|
331
331
|
|
|
332
|
-
For example, if an agent uses the `PIIDetector` with `strategy: "block"` and the request includes a credit card number, it will be blocked and the response will include
|
|
332
|
+
For example, if an agent uses the `PIIDetector` with `strategy: "block"` and the request includes a credit card number, it will be blocked and the response will include tripwire information.
|
|
333
333
|
|
|
334
334
|
#### `.generate()` example
|
|
335
335
|
|
|
@@ -338,8 +338,14 @@ const result = await agent.generate(
|
|
|
338
338
|
"Is this credit card number valid?: 4543 1374 5089 4332",
|
|
339
339
|
);
|
|
340
340
|
|
|
341
|
-
|
|
342
|
-
console.error(result.
|
|
341
|
+
if (result.tripwire) {
|
|
342
|
+
console.error("Blocked:", result.tripwire.reason);
|
|
343
|
+
console.error("Processor:", result.tripwire.processorId);
|
|
344
|
+
// Optional: check if retry was requested
|
|
345
|
+
console.error("Retry requested:", result.tripwire.retry);
|
|
346
|
+
// Optional: access additional metadata
|
|
347
|
+
console.error("Metadata:", result.tripwire.metadata);
|
|
348
|
+
}
|
|
343
349
|
```
|
|
344
350
|
|
|
345
351
|
#### `.stream()` example
|
|
@@ -351,17 +357,48 @@ const stream = await agent.stream(
|
|
|
351
357
|
|
|
352
358
|
for await (const chunk of stream.fullStream) {
|
|
353
359
|
if (chunk.type === "tripwire") {
|
|
354
|
-
console.error(chunk.payload.
|
|
360
|
+
console.error("Blocked:", chunk.payload.reason);
|
|
361
|
+
console.error("Processor:", chunk.payload.processorId);
|
|
355
362
|
}
|
|
356
363
|
}
|
|
357
364
|
```
|
|
358
365
|
|
|
359
|
-
In this case, the `
|
|
366
|
+
In this case, the `reason` indicates that a credit card number was detected:
|
|
360
367
|
|
|
361
368
|
```text
|
|
362
369
|
PII detected. Types: credit-card
|
|
363
370
|
```
|
|
364
371
|
|
|
372
|
+
### Requesting retries
|
|
373
|
+
|
|
374
|
+
Processors can request that the LLM retry its response with feedback. This is useful for implementing quality checks:
|
|
375
|
+
|
|
376
|
+
```typescript showLineNumbers
|
|
377
|
+
export class QualityChecker implements Processor {
|
|
378
|
+
id = "quality-checker";
|
|
379
|
+
|
|
380
|
+
async processOutputStep({ text, abort, retryCount }) {
|
|
381
|
+
const score = await evaluateQuality(text);
|
|
382
|
+
|
|
383
|
+
if (score < 0.7 && retryCount < 3) {
|
|
384
|
+
// Request retry with feedback for the LLM
|
|
385
|
+
abort("Response quality too low. Please be more specific.", {
|
|
386
|
+
retry: true,
|
|
387
|
+
metadata: { score },
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
return [];
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
The `abort()` function accepts an optional second parameter with:
|
|
397
|
+
- `retry: true` - Request the LLM retry the step
|
|
398
|
+
- `metadata: unknown` - Attach additional data for debugging/logging
|
|
399
|
+
|
|
400
|
+
Use `retryCount` to track retry attempts and prevent infinite loops.
|
|
401
|
+
|
|
365
402
|
## Custom processors
|
|
366
403
|
|
|
367
404
|
If the built-in processors don’t cover your needs, you can create your own by extending the `Processor` class.
|
|
@@ -239,5 +239,5 @@ network-execution-event-step-finish
|
|
|
239
239
|
|
|
240
240
|
- [Agent Memory](./agent-memory)
|
|
241
241
|
- [Workflows Overview](../workflows/overview)
|
|
242
|
-
- [Request Context](/docs/v1/server
|
|
242
|
+
- [Request Context](/docs/v1/server/request-context)
|
|
243
243
|
- [Supervisor example](https://github.com/mastra-ai/mastra/tree/main/examples/supervisor-agent)
|
|
@@ -306,7 +306,7 @@ export const testAgent = new Agent({
|
|
|
306
306
|
});
|
|
307
307
|
```
|
|
308
308
|
|
|
309
|
-
> See [Request Context](/docs/v1/server
|
|
309
|
+
> See [Request Context](/docs/v1/server/request-context) for more information.
|
|
310
310
|
|
|
311
311
|
## Testing with Studio
|
|
312
312
|
|
|
@@ -316,4 +316,4 @@ Use [Studio](/docs/v1/getting-started/studio) to test agents with different mess
|
|
|
316
316
|
|
|
317
317
|
- [Using Tools](/docs/v1/agents/using-tools)
|
|
318
318
|
- [Agent Memory](/docs/v1/agents/agent-memory)
|
|
319
|
-
- [Request Context](/docs/v1/server
|
|
319
|
+
- [Request Context](/docs/v1/server/request-context)
|