@mastra/core 1.24.0-alpha.1 → 1.24.1-alpha.0
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/CHANGELOG.md +81 -0
- package/dist/agent/index.cjs +8 -8
- package/dist/agent/index.js +1 -1
- package/dist/browser/index.cjs +2 -2
- package/dist/browser/index.js +1 -1
- package/dist/channels/index.cjs +4 -4
- package/dist/channels/index.js +1 -1
- package/dist/{chunk-BFOZOAU2.cjs → chunk-4636ENMP.cjs} +56 -108
- package/dist/chunk-4636ENMP.cjs.map +1 -0
- package/dist/{chunk-MK5IF24D.js → chunk-5CPRW7GV.js} +3 -3
- package/dist/{chunk-MK5IF24D.js.map → chunk-5CPRW7GV.js.map} +1 -1
- package/dist/{chunk-EJ62D3QH.js → chunk-6TQZIQ23.js} +6 -6
- package/dist/{chunk-EJ62D3QH.js.map → chunk-6TQZIQ23.js.map} +1 -1
- package/dist/{chunk-L73KZFX6.cjs → chunk-AX3PKXOT.cjs} +6 -6
- package/dist/{chunk-L73KZFX6.cjs.map → chunk-AX3PKXOT.cjs.map} +1 -1
- package/dist/{chunk-365PDOQ4.cjs → chunk-CNCOPROQ.cjs} +9 -9
- package/dist/{chunk-365PDOQ4.cjs.map → chunk-CNCOPROQ.cjs.map} +1 -1
- package/dist/{chunk-CY4AMNDV.cjs → chunk-H2SFI3RZ.cjs} +7 -7
- package/dist/{chunk-CY4AMNDV.cjs.map → chunk-H2SFI3RZ.cjs.map} +1 -1
- package/dist/{chunk-D64ZY3NT.cjs → chunk-HAF2U4ON.cjs} +17 -17
- package/dist/{chunk-D64ZY3NT.cjs.map → chunk-HAF2U4ON.cjs.map} +1 -1
- package/dist/{chunk-GAW7WFCY.js → chunk-IWMYLZQ6.js} +3 -3
- package/dist/{chunk-GAW7WFCY.js.map → chunk-IWMYLZQ6.js.map} +1 -1
- package/dist/{chunk-PCHML5XO.js → chunk-JG7M2F2C.js} +4 -4
- package/dist/{chunk-PCHML5XO.js.map → chunk-JG7M2F2C.js.map} +1 -1
- package/dist/{chunk-JBFAGOAG.js → chunk-JRTGAEET.js} +9 -9
- package/dist/{chunk-JBFAGOAG.js.map → chunk-JRTGAEET.js.map} +1 -1
- package/dist/{chunk-SYH64AGV.cjs → chunk-K2NJIVZ5.cjs} +14 -14
- package/dist/{chunk-SYH64AGV.cjs.map → chunk-K2NJIVZ5.cjs.map} +1 -1
- package/dist/{chunk-IKUMKFM4.js → chunk-KQABOPAK.js} +4 -4
- package/dist/{chunk-IKUMKFM4.js.map → chunk-KQABOPAK.js.map} +1 -1
- package/dist/{chunk-3RI7ILBW.js → chunk-MYYPIBLR.js} +3 -3
- package/dist/{chunk-3RI7ILBW.js.map → chunk-MYYPIBLR.js.map} +1 -1
- package/dist/{chunk-SUEVJYTA.cjs → chunk-NC3NDZWM.cjs} +185 -185
- package/dist/{chunk-SUEVJYTA.cjs.map → chunk-NC3NDZWM.cjs.map} +1 -1
- package/dist/{chunk-EAQQP6OK.cjs → chunk-NWGH6OSA.cjs} +48 -48
- package/dist/{chunk-EAQQP6OK.cjs.map → chunk-NWGH6OSA.cjs.map} +1 -1
- package/dist/{chunk-V657RNGK.js → chunk-Q55SOMNM.js} +44 -96
- package/dist/chunk-Q55SOMNM.js.map +1 -0
- package/dist/{chunk-LUEXY2QV.js → chunk-QBUDLHGF.js} +3 -3
- package/dist/{chunk-LUEXY2QV.js.map → chunk-QBUDLHGF.js.map} +1 -1
- package/dist/{chunk-CN6AFOVV.js → chunk-RKBY3V7R.js} +4 -4
- package/dist/{chunk-CN6AFOVV.js.map → chunk-RKBY3V7R.js.map} +1 -1
- package/dist/{chunk-XEDVYHBK.cjs → chunk-W7JPJ5VP.cjs} +3 -3
- package/dist/{chunk-XEDVYHBK.cjs.map → chunk-W7JPJ5VP.cjs.map} +1 -1
- package/dist/{chunk-B2FQ6L2I.cjs → chunk-XCFSSKCI.cjs} +5 -5
- package/dist/{chunk-B2FQ6L2I.cjs.map → chunk-XCFSSKCI.cjs.map} +1 -1
- package/dist/{chunk-PQKSETS5.js → chunk-XOJF3SNB.js} +3 -3
- package/dist/{chunk-PQKSETS5.js.map → chunk-XOJF3SNB.js.map} +1 -1
- package/dist/{chunk-FCW225T4.cjs → chunk-Y6I7BKY3.cjs} +77 -77
- package/dist/{chunk-FCW225T4.cjs.map → chunk-Y6I7BKY3.cjs.map} +1 -1
- package/dist/datasets/index.cjs +11 -11
- package/dist/datasets/index.js +1 -1
- package/dist/docs/SKILL.md +6 -1
- package/dist/docs/assets/SOURCE_MAP.json +133 -133
- package/dist/docs/references/docs-editor-overview.md +221 -0
- package/dist/docs/references/docs-editor-prompts.md +134 -0
- package/dist/docs/references/docs-editor-tools.md +152 -0
- package/dist/docs/references/docs-studio-overview.md +2 -0
- package/dist/docs/references/reference-client-js-agents.md +136 -0
- package/dist/docs/references/reference-core-getEditor.md +35 -0
- package/dist/docs/references/reference-editor-mastra-editor.md +168 -0
- package/dist/docs/references/reference.md +3 -0
- package/dist/evals/index.cjs +5 -5
- package/dist/evals/index.js +2 -2
- package/dist/evals/scoreTraces/index.cjs +3 -3
- package/dist/evals/scoreTraces/index.js +1 -1
- package/dist/harness/index.cjs +7 -7
- package/dist/harness/index.js +5 -5
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/llm/index.cjs +20 -20
- package/dist/llm/index.js +5 -5
- package/dist/llm/model/provider-types.generated.d.ts +15 -40
- package/dist/loop/index.cjs +14 -14
- package/dist/loop/index.js +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.js +1 -1
- package/dist/mastra-KYZOJWVP.cjs +12 -0
- package/dist/{mastra-7CFH7DGM.cjs.map → mastra-KYZOJWVP.cjs.map} +1 -1
- package/dist/mastra-THXHB2YW.js +3 -0
- package/dist/{mastra-5YHFXAJO.js.map → mastra-THXHB2YW.js.map} +1 -1
- package/dist/memory/index.cjs +19 -19
- package/dist/memory/index.js +1 -1
- package/dist/models-dev-JNR72RHW.cjs +12 -0
- package/dist/{models-dev-X2MWNPAU.cjs.map → models-dev-JNR72RHW.cjs.map} +1 -1
- package/dist/models-dev-Y4N5GCLA.js +3 -0
- package/dist/{models-dev-ZXC3IYLG.js.map → models-dev-Y4N5GCLA.js.map} +1 -1
- package/dist/netlify-C25NVF5O.cjs +12 -0
- package/dist/{netlify-GOILLTQO.cjs.map → netlify-C25NVF5O.cjs.map} +1 -1
- package/dist/netlify-IGYUFSZG.js +3 -0
- package/dist/{netlify-HJL7EXHY.js.map → netlify-IGYUFSZG.js.map} +1 -1
- package/dist/processor-provider/index.cjs +10 -10
- package/dist/processor-provider/index.js +1 -1
- package/dist/processors/index.cjs +44 -44
- package/dist/processors/index.js +1 -1
- package/dist/provider-registry-3HZNLU3V.js +3 -0
- package/dist/{provider-registry-UWTCPEFF.js.map → provider-registry-3HZNLU3V.js.map} +1 -1
- package/dist/provider-registry-PKUEVZXH.cjs +44 -0
- package/dist/{provider-registry-25ELOB67.cjs.map → provider-registry-PKUEVZXH.cjs.map} +1 -1
- package/dist/provider-registry.json +36 -88
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/stream/index.cjs +8 -8
- package/dist/stream/index.js +1 -1
- package/dist/tool-loop-agent/index.cjs +4 -4
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/index.cjs +24 -24
- package/dist/workflows/index.js +1 -1
- package/package.json +9 -9
- package/src/llm/model/provider-types.generated.d.ts +15 -40
- package/dist/chunk-BFOZOAU2.cjs.map +0 -1
- package/dist/chunk-V657RNGK.js.map +0 -1
- package/dist/mastra-5YHFXAJO.js +0 -3
- package/dist/mastra-7CFH7DGM.cjs +0 -12
- package/dist/models-dev-X2MWNPAU.cjs +0 -12
- package/dist/models-dev-ZXC3IYLG.js +0 -3
- package/dist/netlify-GOILLTQO.cjs +0 -12
- package/dist/netlify-HJL7EXHY.js +0 -3
- package/dist/provider-registry-25ELOB67.cjs +0 -44
- package/dist/provider-registry-UWTCPEFF.js +0 -3
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
# Editor overview
|
|
2
|
+
|
|
3
|
+
The editor is a CMS-style system that separates agent configuration from code. Subject-matter experts, prompt engineers, and product teams can iterate on agents directly while developers keep the codebase stable.
|
|
4
|
+
|
|
5
|
+
The editor manages two types of resources alongside agents:
|
|
6
|
+
|
|
7
|
+
- [**Prompts**](https://mastra.ai/docs/editor/prompts): Reusable, versioned instruction templates with template variables and display conditions.
|
|
8
|
+
- [**Tools**](https://mastra.ai/docs/editor/tools): Add tools from integration providers, MCP servers, and override tool descriptions at runtime.
|
|
9
|
+
|
|
10
|
+
## When to use the editor
|
|
11
|
+
|
|
12
|
+
Use the editor when you want to:
|
|
13
|
+
|
|
14
|
+
- **Let non-developers iterate**: Give subject-matter experts and prompt engineers a way to tune agent behavior without touching code or waiting for deploys.
|
|
15
|
+
- **Version everything**: Every save creates a snapshot so you can compare changes, roll back instantly, and audit what changed and when.
|
|
16
|
+
- **Run experiments**: Route different users or requests to different agent versions for A/B testing, canary rollouts, or prompt experimentation.
|
|
17
|
+
- **Target specific versions**: Pin a version per request, per user, or per environment so production stays stable while new versions are tested.
|
|
18
|
+
- **Manage tools at runtime**: Add integration tools from Composio or Arcade, or connect MCP servers, without updating code.
|
|
19
|
+
- **Override code agents**: Change the instructions, tools, or variables of a code-defined agent while keeping the original code as the baseline.
|
|
20
|
+
|
|
21
|
+
For building agents entirely in code, see the [Agents overview](https://mastra.ai/docs/agents/overview).
|
|
22
|
+
|
|
23
|
+
## Quickstart
|
|
24
|
+
|
|
25
|
+
Add `@mastra/editor` to your project:
|
|
26
|
+
|
|
27
|
+
**npm**:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install @mastra/editor
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**pnpm**:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pnpm add @mastra/editor
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Yarn**:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
yarn add @mastra/editor
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Bun**:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
bun add @mastra/editor
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Pass a `MastraEditor` instance to your Mastra configuration with your existing agents:
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
import { Mastra } from '@mastra/core'
|
|
55
|
+
import { MastraEditor } from '@mastra/editor'
|
|
56
|
+
|
|
57
|
+
export const mastra = new Mastra({
|
|
58
|
+
agents: {
|
|
59
|
+
/* your existing agents */
|
|
60
|
+
},
|
|
61
|
+
editor: new MastraEditor(),
|
|
62
|
+
})
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Once registered, you can manage agents through [Studio](https://mastra.ai/docs/studio/overview) or programmatically through the server API and Client SDK.
|
|
66
|
+
|
|
67
|
+
> **Note:** See the [MastraEditor reference](https://mastra.ai/reference/editor/mastra-editor) for all configuration options.
|
|
68
|
+
|
|
69
|
+
## Studio
|
|
70
|
+
|
|
71
|
+
Go to the **Agents** tab in Studio and select an agent to edit. Select the **Editor** tab. You'll be taken to the editor interface, where you can modify the agent's instructions, tools, and variables.
|
|
72
|
+
|
|
73
|
+
Modify the system prompt and save a new draft version. Afterwards, publish the draft to make it the active version.
|
|
74
|
+
|
|
75
|
+
## Programmatic control
|
|
76
|
+
|
|
77
|
+
Everything you can do in Studio is also available programmatically through [`mastra.getEditor()`](https://mastra.ai/reference/core/getEditor). This is useful for scripting bulk updates, seeding stored configurations from code, or building automation that tunes agents based on evaluation results.
|
|
78
|
+
|
|
79
|
+
Call `mastra.getEditor()` from anywhere you have access to the `Mastra` instance. It returns the `MastraEditor` instance you registered, with namespaces for each resource type:
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import { mastra } from '../mastra'
|
|
83
|
+
|
|
84
|
+
const editor = mastra.getEditor()
|
|
85
|
+
if (!editor) throw new Error('Editor is not registered on Mastra')
|
|
86
|
+
|
|
87
|
+
// Create a stored agent override for an existing code-defined agent
|
|
88
|
+
await editor.agent.create({
|
|
89
|
+
id: 'support-agent',
|
|
90
|
+
instructions: 'You are a friendly support agent for Acme Inc.',
|
|
91
|
+
tools: {
|
|
92
|
+
search_kb: { description: 'Search the Acme knowledge base' },
|
|
93
|
+
},
|
|
94
|
+
})
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Use `editor.agent.update()` to change an existing stored configuration. Every update creates a new draft version automatically:
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
import { mastra } from '../mastra'
|
|
101
|
+
|
|
102
|
+
const editor = mastra.getEditor()!
|
|
103
|
+
|
|
104
|
+
await editor.agent.update({
|
|
105
|
+
id: 'support-agent',
|
|
106
|
+
instructions:
|
|
107
|
+
"You are a friendly support agent for Acme Inc. Always respond in the user's language.",
|
|
108
|
+
})
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
The `editor.agent` namespace also exposes `getById`, `list`, `listResolved`, and `delete`. The `editor.prompt` namespace exposes the same CRUD methods for prompt blocks. See [Prompts](https://mastra.ai/docs/editor/prompts) for examples.
|
|
112
|
+
|
|
113
|
+
### Server endpoints
|
|
114
|
+
|
|
115
|
+
The same operations are available over HTTP through the Mastra server. Use these when you want to manage stored agents from a separate service or from a non-TypeScript client:
|
|
116
|
+
|
|
117
|
+
| Method | Path | Description |
|
|
118
|
+
| -------- | ------------------------------- | ------------------------- |
|
|
119
|
+
| `GET` | `/stored/agents` | List all stored agents. |
|
|
120
|
+
| `POST` | `/stored/agents` | Create a stored agent. |
|
|
121
|
+
| `GET` | `/stored/agents/:storedAgentId` | Get a stored agent by ID. |
|
|
122
|
+
| `PATCH` | `/stored/agents/:storedAgentId` | Update a stored agent. |
|
|
123
|
+
| `DELETE` | `/stored/agents/:storedAgentId` | Delete a stored agent. |
|
|
124
|
+
|
|
125
|
+
The Client SDK wraps these endpoints with `client.listStoredAgents()`, `client.createStoredAgent()`, and `client.getStoredAgent()`. Version management endpoints live under `/stored/agents/:storedAgentId/versions`, see [version management](https://mastra.ai/reference/client-js/agents) for the full list.
|
|
126
|
+
|
|
127
|
+
### Automated experimentation
|
|
128
|
+
|
|
129
|
+
Because stored agents are just data, you can build automation loops that tune agents without human involvement. A common pattern is to pair the editor API with [datasets](https://mastra.ai/docs/evals/datasets/overview) and [experiments](https://mastra.ai/docs/evals/datasets/running-experiments):
|
|
130
|
+
|
|
131
|
+
- Run a dataset through the current version of an agent and score the results.
|
|
132
|
+
- Have another agent read the failing cases and propose changes to the instructions or tools.
|
|
133
|
+
- Apply those changes with `editor.agent.update()` to create a new draft.
|
|
134
|
+
- Re-run the experiment against the draft and compare scores to the baseline.
|
|
135
|
+
- Promote the draft to the published version when the scores improve.
|
|
136
|
+
|
|
137
|
+
This turns agent tuning into a closed feedback loop. One agent owns the production configuration, another agent iterates on it, and every change is versioned so you can roll back if a round of automated edits makes things worse. Combine this with [version targeting](#version-targeting-and-experimentation) to keep production traffic on the published version while the draft is being tested.
|
|
138
|
+
|
|
139
|
+
> **Note:** See the [MastraEditor reference](https://mastra.ai/reference/editor/mastra-editor) for the full namespace API.
|
|
140
|
+
|
|
141
|
+
## What can be overridden
|
|
142
|
+
|
|
143
|
+
When you edit a code-defined agent through the editor, only specific fields can be changed:
|
|
144
|
+
|
|
145
|
+
| Field | Description |
|
|
146
|
+
| ------------ | ------------------------------------------------------------------------------------------------------------- |
|
|
147
|
+
| Instructions | Replace or extend the agent's system prompt using [prompt blocks](https://mastra.ai/docs/editor/prompts). |
|
|
148
|
+
| Tools | Add tools from the tool registry, integration providers, or MCP clients. Code-defined tools remain available. |
|
|
149
|
+
|
|
150
|
+
Fields like the agent's `id`, `name`, and `model` come from your code and can't be changed through the editor for code-defined agents. The variables are also read-only.
|
|
151
|
+
|
|
152
|
+
## Versioning
|
|
153
|
+
|
|
154
|
+
Every time you save changes to an agent or prompt block, a new version snapshot is created. Versions give you a full history of your agent's configuration. You can roll back to any previous state, compare what changed between two snapshots, and target specific versions per request for A/B testing or gradual rollouts.
|
|
155
|
+
|
|
156
|
+
Version management is available through the server Studio, REST API, the Client SDK, and the React SDK. See the [Client SDK agents reference](https://mastra.ai/reference/client-js/agents) for endpoints, SDK methods, and code examples.
|
|
157
|
+
|
|
158
|
+
### Version lifecycle
|
|
159
|
+
|
|
160
|
+
Each version has one of three statuses:
|
|
161
|
+
|
|
162
|
+
| Status | Description |
|
|
163
|
+
| --------- | ----------------------------------------------------------------------------------- |
|
|
164
|
+
| Draft | The latest working copy. Every save creates a new draft version. |
|
|
165
|
+
| Published | The active version used in production. Only one version can be published at a time. |
|
|
166
|
+
| Archived | A previous version that is no longer active. You can restore any archived version. |
|
|
167
|
+
|
|
168
|
+
The typical flow is: Edit the draft, test it, then activate it to make it the published version. The previously published version becomes archived so you can restore it if needed. You can do this through Studio or programmatically through the API.
|
|
169
|
+
|
|
170
|
+
This lifecycle makes it safe to experiment. Non-technical team members can iterate on a draft without affecting production traffic, then publish when ready. If something goes wrong, restoring a previous version is a single API call.
|
|
171
|
+
|
|
172
|
+
### Version targeting and experimentation
|
|
173
|
+
|
|
174
|
+
Because every version has a unique ID, you can route different requests to different agent configurations. This opens up several patterns:
|
|
175
|
+
|
|
176
|
+
- **A/B testing**: Split traffic between two published versions and compare performance metrics.
|
|
177
|
+
- **Canary rollouts**: Send a small percentage of requests to a new version before promoting it.
|
|
178
|
+
- **Per-user targeting**: Pin specific users or accounts to a version while others use the default.
|
|
179
|
+
- **Environment separation**: Use the draft version in staging and the published version in production.
|
|
180
|
+
|
|
181
|
+
Pass a `versionId` or `status` when calling the agent through the Client SDK, server query parameters, or React SDK `requestContext`, and the correct version is loaded automatically.
|
|
182
|
+
|
|
183
|
+
### Version selection
|
|
184
|
+
|
|
185
|
+
By default, [`mastra.getAgentById()`](https://mastra.ai/reference/core/getAgentById) loads the published (active) version of the stored override. You can request a specific version, which is useful for testing a draft before publishing, running A/B experiments, or pinning a user to a known-good configuration:
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
// Load the published version (default)
|
|
189
|
+
const agent = mastra.getAgentById('support-agent')
|
|
190
|
+
|
|
191
|
+
// Load the latest draft
|
|
192
|
+
const agent = mastra.getAgentById('support-agent', {
|
|
193
|
+
status: 'draft',
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
// Load a specific version
|
|
197
|
+
const agent = mastra.getAgentById('support-agent', {
|
|
198
|
+
versionId: 'abc-123',
|
|
199
|
+
})
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
When calling the agent through the Mastra server, pass version parameters as query strings:
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
# Published version (default)
|
|
206
|
+
curl http://localhost:4111/agents/support-agent
|
|
207
|
+
|
|
208
|
+
# Latest draft
|
|
209
|
+
curl http://localhost:4111/agents/support-agent?status=draft
|
|
210
|
+
|
|
211
|
+
# Specific version
|
|
212
|
+
curl http://localhost:4111/agents/support-agent?versionId=abc-123
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
See the [Client SDK agents reference](https://mastra.ai/reference/client-js/agents) for API methods.
|
|
216
|
+
|
|
217
|
+
## Next steps
|
|
218
|
+
|
|
219
|
+
- Set up [prompts](https://mastra.ai/docs/editor/prompts) to build reusable instruction templates.
|
|
220
|
+
- Add [tools](https://mastra.ai/docs/editor/tools) from integration providers and MCP servers.
|
|
221
|
+
- Explore the [MastraEditor reference](https://mastra.ai/reference/editor/mastra-editor) for all configuration options.
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# Prompts
|
|
2
|
+
|
|
3
|
+
Prompt blocks are reusable instruction templates that you compose into an agent's system prompt. Each block can contain plain text, template variables, and display conditions. Non-technical team members can edit prompt content, test different phrasings, and publish changes. Every edit is versioned, so you can compare prompt variations, roll back, and track what changed over time. You can create and manage prompt blocks through the Studio UI or programmatically through the server API, then reference them across multiple agents.
|
|
4
|
+
|
|
5
|
+
## Quickstart
|
|
6
|
+
|
|
7
|
+
1. Go to the **Prompts** tab in Studio.
|
|
8
|
+
2. Select **Create prompt** and enter a name and your instruction text.
|
|
9
|
+
3. Save the prompt block and publish it.
|
|
10
|
+
4. Open an agent's **Instructions** section and select **Add block**.
|
|
11
|
+
5. Pick the saved prompt block from the block picker dialog.
|
|
12
|
+
|
|
13
|
+
The block appears as a reference in the agent's instruction list. Changes to the original prompt block update every agent that references it.
|
|
14
|
+
|
|
15
|
+
## Block types
|
|
16
|
+
|
|
17
|
+
An agent's instructions are made up of an ordered list of blocks. Each block is one of three types:
|
|
18
|
+
|
|
19
|
+
| Type | Description |
|
|
20
|
+
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
|
|
21
|
+
| Inline text | Free-form text written directly in the agent's instruction list. Lives only on that agent. |
|
|
22
|
+
| Prompt block | A standalone block with its own content, stored in the agent snapshot. You can save an inline block as a prompt block to reuse it. |
|
|
23
|
+
| Prompt block reference | A pointer to a saved prompt block. The content is resolved at runtime from the referenced block. |
|
|
24
|
+
|
|
25
|
+
To turn an inline block into a reusable prompt block, open the block's menu and select **Save as prompt block**. To reference an existing prompt block, select **Add block** and pick one from the dialog.
|
|
26
|
+
|
|
27
|
+
## Template variables
|
|
28
|
+
|
|
29
|
+
Prompt blocks support `{{variable}}` syntax for dynamic content. Variables are resolved at runtime from the agent's variables and request context.
|
|
30
|
+
|
|
31
|
+
```text
|
|
32
|
+
You are helping {{userName}} with their {{task || 'request'}}.
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
| Syntax | Behavior |
|
|
36
|
+
| ----------------------------- | ------------------------------------------------------------------------------------------- |
|
|
37
|
+
| `{{variableName}}` | Replaced with the variable value. Left as-is if not found. |
|
|
38
|
+
| `{{nested.path.value}}` | Resolves dot-notation paths in the context object. |
|
|
39
|
+
| `{{variable \|\| 'default'}}` | Uses the fallback value when the variable is missing. Single or double quotes are accepted. |
|
|
40
|
+
|
|
41
|
+
Variables are passed through the agent's `variables` configuration or through [request context](https://mastra.ai/docs/server/request-context).
|
|
42
|
+
|
|
43
|
+
## Display conditions
|
|
44
|
+
|
|
45
|
+
Each block can have a **display condition**. A rule group that controls whether the block is included in the final prompt. Conditions are evaluated at runtime against the agent's variables and request context.
|
|
46
|
+
|
|
47
|
+
A rule group uses **AND** or **OR** logic with one or more conditions. Each condition checks a context field against a value using an operator:
|
|
48
|
+
|
|
49
|
+
| Operator | Description |
|
|
50
|
+
| ---------------------------------------------- | ------------------------------------- |
|
|
51
|
+
| `equals` / `not_equals` | Exact match comparison. |
|
|
52
|
+
| `contains` / `not_contains` | String inclusion or array membership. |
|
|
53
|
+
| `greater_than` / `less_than` | Numeric comparison. |
|
|
54
|
+
| `greater_than_or_equal` / `less_than_or_equal` | Numeric comparison with equality. |
|
|
55
|
+
| `in` / `not_in` | Checks if a value is in an array. |
|
|
56
|
+
| `exists` / `not_exists` | Checks if the field is present. |
|
|
57
|
+
|
|
58
|
+
Rule groups can be nested, so you can combine AND and OR conditions for complex logic.
|
|
59
|
+
|
|
60
|
+
In the Studio, open a block's **Display conditions** panel to set up rules visually. You can also configure conditions programmatically through the API. Blocks without conditions are always included.
|
|
61
|
+
|
|
62
|
+
## Programmatic control
|
|
63
|
+
|
|
64
|
+
Prompt blocks can be managed from code through [`mastra.getEditor().prompt`](https://mastra.ai/reference/editor/mastra-editor). This is useful for seeding a set of starter prompts, syncing blocks between environments, or generating prompt variants from a script.
|
|
65
|
+
|
|
66
|
+
Create a new prompt block with `editor.prompt.create()`:
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import { mastra } from '../mastra'
|
|
70
|
+
|
|
71
|
+
const editor = mastra.getEditor()!
|
|
72
|
+
|
|
73
|
+
await editor.prompt.create({
|
|
74
|
+
id: 'brand-voice',
|
|
75
|
+
name: 'Brand voice',
|
|
76
|
+
description: 'Acme Inc. tone and style guidelines',
|
|
77
|
+
content:
|
|
78
|
+
'You write in a friendly, concise tone. Always address the user as {{userName || "there"}}.',
|
|
79
|
+
})
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Update an existing block with `editor.prompt.update()`. Each update creates a new draft version:
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
import { mastra } from '../mastra'
|
|
86
|
+
|
|
87
|
+
const editor = mastra.getEditor()!
|
|
88
|
+
|
|
89
|
+
await editor.prompt.update({
|
|
90
|
+
id: 'brand-voice',
|
|
91
|
+
content: 'You write in a friendly, concise tone. Always greet the user by name when available.',
|
|
92
|
+
})
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Use `editor.prompt.list()` to paginate through stored blocks or `editor.prompt.getById()` to fetch a specific block. To preview an agent's full instructions with a set of prompt blocks applied, call `editor.prompt.preview()` with the draft content.
|
|
96
|
+
|
|
97
|
+
The same operations are available over HTTP through the Mastra server:
|
|
98
|
+
|
|
99
|
+
| Method | Path | Description |
|
|
100
|
+
| -------- | -------------------------------------------- | -------------------------------- |
|
|
101
|
+
| `GET` | `/stored/prompt-blocks` | List all stored prompt blocks. |
|
|
102
|
+
| `POST` | `/stored/prompt-blocks` | Create a stored prompt block. |
|
|
103
|
+
| `GET` | `/stored/prompt-blocks/:storedPromptBlockId` | Get a stored prompt block by ID. |
|
|
104
|
+
| `PATCH` | `/stored/prompt-blocks/:storedPromptBlockId` | Update a stored prompt block. |
|
|
105
|
+
| `DELETE` | `/stored/prompt-blocks/:storedPromptBlockId` | Delete a stored prompt block. |
|
|
106
|
+
|
|
107
|
+
Once a prompt block is created, reference it from an agent's `instructions` field as a `prompt_block_ref`:
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
import { mastra } from '../mastra'
|
|
111
|
+
|
|
112
|
+
const editor = mastra.getEditor()!
|
|
113
|
+
|
|
114
|
+
await editor.agent.update({
|
|
115
|
+
id: 'support-agent',
|
|
116
|
+
instructions: [
|
|
117
|
+
{ type: 'prompt_block_ref', id: 'brand-voice' },
|
|
118
|
+
{ type: 'text', content: 'Answer only questions about Acme products.' },
|
|
119
|
+
],
|
|
120
|
+
})
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
> **Note:** See the [MastraEditor reference](https://mastra.ai/reference/editor/mastra-editor) for the full `editor.prompt` API.
|
|
124
|
+
|
|
125
|
+
## Versioning
|
|
126
|
+
|
|
127
|
+
Prompt blocks follow the same [versioning lifecycle](https://mastra.ai/docs/editor/overview) as agents. Each prompt block has a draft that you can edit and publish as a versioned snapshot. This means prompt content can be versioned and rolled back independently from the agent that uses it.
|
|
128
|
+
|
|
129
|
+
When an agent references a prompt block, the resolved content comes from the block's active published version by default. During editing, draft content is used for previews. This separation makes it safe for non-technical team members to experiment with prompt wording. The published version stays stable until they explicitly activate a new one.
|
|
130
|
+
|
|
131
|
+
## Related
|
|
132
|
+
|
|
133
|
+
- [Editor overview](https://mastra.ai/docs/editor/overview): Setup and versioning.
|
|
134
|
+
- [MastraEditor reference](https://mastra.ai/reference/editor/mastra-editor): Full configuration options for the editor.
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# Tools
|
|
2
|
+
|
|
3
|
+
The editor gives you three ways to add tools to agents:
|
|
4
|
+
|
|
5
|
+
- **Code tools**: Tools already registered in your Mastra instance.
|
|
6
|
+
- **Integration providers**: Third-party tool platforms like Composio and Arcade.
|
|
7
|
+
- **MCP clients**: Tools from MCP servers, configured as reusable client definitions.
|
|
8
|
+
|
|
9
|
+
You can manage all three sources through the Studio UI or programmatically through the server API. Non-technical team members can browse tool catalogs, add tools to agents, and test different tool combinations without code changes. Tool configurations are versioned alongside the rest of the agent, so you can roll back tool changes, compare versions, and experiment safely.
|
|
10
|
+
|
|
11
|
+
## Description overrides
|
|
12
|
+
|
|
13
|
+
Every tool, regardless of source, can have its description overridden at the agent level. This changes the description the agent sees during tool selection without modifying the original tool definition.
|
|
14
|
+
|
|
15
|
+
This is useful when you want to:
|
|
16
|
+
|
|
17
|
+
- Tailor a generic tool's purpose for a specific agent's context.
|
|
18
|
+
- Add instructions about when or how to use a tool.
|
|
19
|
+
- Clarify ambiguous tool descriptions.
|
|
20
|
+
|
|
21
|
+
In the Studio, select a tool in the agent's tool list and edit the **Description** field. The override applies only to that agent.
|
|
22
|
+
|
|
23
|
+
## Display conditions
|
|
24
|
+
|
|
25
|
+
Each tool in an agent can have display conditions — rule groups that control whether the tool is available at runtime. This uses the same rule system as [prompt blocks](https://mastra.ai/docs/editor/prompts).
|
|
26
|
+
|
|
27
|
+
When a request comes in, the editor evaluates each tool's rules against the current context (agent variables and request context). Tools whose conditions are not met are excluded from that run.
|
|
28
|
+
|
|
29
|
+
Use display conditions to:
|
|
30
|
+
|
|
31
|
+
- Restrict expensive tools to specific users or roles.
|
|
32
|
+
- Enable tools based on feature flags or environment variables.
|
|
33
|
+
- Conditionally include tools based on the conversation context.
|
|
34
|
+
|
|
35
|
+
Tools without display conditions are always available.
|
|
36
|
+
|
|
37
|
+
## Studio
|
|
38
|
+
|
|
39
|
+
Go to the **Agents** tab in Studio and select an agent to edit. Select the **Editor** tab. Scroll to the **Tools** section.
|
|
40
|
+
|
|
41
|
+
Here you are able to add tools and configure MCP clients.
|
|
42
|
+
|
|
43
|
+
Once you've made the changes, be sure to save the agent configuration.
|
|
44
|
+
|
|
45
|
+
## Integration providers
|
|
46
|
+
|
|
47
|
+
Integration providers connect external tool platforms to the editor. Once registered, you can browse available tools in the Studio and add them to any agent.
|
|
48
|
+
|
|
49
|
+
### Composio
|
|
50
|
+
|
|
51
|
+
[Composio](https://composio.dev) gives access to hundreds of integration tools organized into toolkits (GitHub, Slack, Gmail, and others).
|
|
52
|
+
|
|
53
|
+
1. Get an API key from your Composio dashboard.
|
|
54
|
+
|
|
55
|
+
2. Register the provider in your Editor configuration:
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import { Mastra } from '@mastra/core'
|
|
59
|
+
import { MastraEditor } from '@mastra/editor'
|
|
60
|
+
import { ComposioToolProvider } from '@mastra/editor/composio'
|
|
61
|
+
|
|
62
|
+
export const mastra = new Mastra({
|
|
63
|
+
agents: {
|
|
64
|
+
/* your agents */
|
|
65
|
+
},
|
|
66
|
+
editor: new MastraEditor({
|
|
67
|
+
toolProviders: {
|
|
68
|
+
composio: new ComposioToolProvider({
|
|
69
|
+
apiKey: process.env.COMPOSIO_API_KEY!,
|
|
70
|
+
}),
|
|
71
|
+
},
|
|
72
|
+
}),
|
|
73
|
+
})
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Composio tool slugs use a format like `GITHUB_CREATE_ISSUE`. Tool calls are scoped to a `userId` passed through request context for per-user authentication.
|
|
77
|
+
|
|
78
|
+
### Arcade
|
|
79
|
+
|
|
80
|
+
[Arcade](https://arcade.dev) provides a curated catalog of tools with built-in authentication handling.
|
|
81
|
+
|
|
82
|
+
1. Get an API key from your Arcade dashboard.
|
|
83
|
+
|
|
84
|
+
2. Register the provider in your Editor configuration:
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
import { Mastra } from '@mastra/core'
|
|
88
|
+
import { MastraEditor } from '@mastra/editor'
|
|
89
|
+
import { ArcadeToolProvider } from '@mastra/editor/arcade'
|
|
90
|
+
|
|
91
|
+
export const mastra = new Mastra({
|
|
92
|
+
agents: {
|
|
93
|
+
/* your agents */
|
|
94
|
+
},
|
|
95
|
+
editor: new MastraEditor({
|
|
96
|
+
toolProviders: {
|
|
97
|
+
arcade: new ArcadeToolProvider({
|
|
98
|
+
apiKey: process.env.ARCADE_API_KEY!,
|
|
99
|
+
}),
|
|
100
|
+
},
|
|
101
|
+
}),
|
|
102
|
+
})
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Arcade tools use a `Toolkit.ToolName` format (for example, `Github.GetRepository`). The provider pre-seeds common toolkits to reduce API calls during browsing.
|
|
106
|
+
|
|
107
|
+
## MCP clients
|
|
108
|
+
|
|
109
|
+
The editor lets you create stored MCP client configurations that connect to MCP servers. Once created, you can reference these clients in any agent to give it access to the server's tools.
|
|
110
|
+
|
|
111
|
+
### Transport types
|
|
112
|
+
|
|
113
|
+
Stored MCP clients support two transport types:
|
|
114
|
+
|
|
115
|
+
| Transport | Description |
|
|
116
|
+
| --------- | ----------------------------------------------------------------------------------------------------------------- |
|
|
117
|
+
| **stdio** | Launches a local process and communicates over standard I/O. Specify the `command` and optional `args` and `env`. |
|
|
118
|
+
| **HTTP** | Connects to a remote MCP server over HTTP. Specify the server `url` and optional `headers`. |
|
|
119
|
+
|
|
120
|
+
### Tool filtering
|
|
121
|
+
|
|
122
|
+
You can filter MCP tools at two levels:
|
|
123
|
+
|
|
124
|
+
1. **Client level**: On the MCP client itself, specify which tools from the server to include or exclude. This applies to every agent that references the client.
|
|
125
|
+
2. **Agent level**: On the agent's MCP client reference, further limit which tools are available. This lets you use the same MCP client in multiple agents while exposing different tool subsets.
|
|
126
|
+
|
|
127
|
+
### Tool namespacing
|
|
128
|
+
|
|
129
|
+
Tools from MCP servers are namespaced as `serverName_toolName` to avoid conflicts. For example, a tool called `search` from a server named `docs` becomes `docs_search`.
|
|
130
|
+
|
|
131
|
+
### Conditional activation
|
|
132
|
+
|
|
133
|
+
MCP client references in an agent can have display conditions, just like [prompt blocks](https://mastra.ai/docs/editor/prompts). This lets you conditionally include MCP tools based on request context or agent variables.
|
|
134
|
+
|
|
135
|
+
## How tools are merged
|
|
136
|
+
|
|
137
|
+
When an agent runs, tools from all sources are merged in this order:
|
|
138
|
+
|
|
139
|
+
1. Code tools
|
|
140
|
+
2. Integration tools
|
|
141
|
+
3. MCP tools
|
|
142
|
+
|
|
143
|
+
If a tool ID exists in multiple sources, later sources take precedence. Description overrides set at the agent level always take priority over the original tool description.
|
|
144
|
+
|
|
145
|
+
> **Note:** See the [ToolProvider reference](https://mastra.ai/reference/editor/tool-provider) for the full provider API.
|
|
146
|
+
|
|
147
|
+
## Related
|
|
148
|
+
|
|
149
|
+
- [Editor overview](https://mastra.ai/docs/editor/overview): Setup and versioning.
|
|
150
|
+
- [Prompts](https://mastra.ai/docs/editor/prompts): Display conditions reference for prompt blocks.
|
|
151
|
+
- [ToolProvider reference](https://mastra.ai/reference/editor/tool-provider): Composio and Arcade API details.
|
|
152
|
+
- [MCP overview](https://mastra.ai/docs/mcp/overview): General MCP documentation.
|
|
@@ -49,6 +49,8 @@ Chat with your agent directly, dynamically switch [models](https://mastra.ai/mod
|
|
|
49
49
|
|
|
50
50
|
When you interact with your agent, you can follow each step of its reasoning, view tool call outputs, and [observe](#observability) traces and logs to see how responses are generated. You can also attach [scorers](#scorers) to measure and compare response quality over time.
|
|
51
51
|
|
|
52
|
+
Use [Editor](https://mastra.ai/docs/editor/overview) to let non-technical team members iterate on agents, version every change, and run experiments without redeploying.
|
|
53
|
+
|
|
52
54
|
### Workflows
|
|
53
55
|
|
|
54
56
|
Visualize your workflow as a graph and run it step by step with a custom input. During execution, the interface updates in real time to show the active step and the path taken.
|
|
@@ -439,4 +439,140 @@ Delete a stored agent:
|
|
|
439
439
|
```typescript
|
|
440
440
|
const result = await storedAgent.delete()
|
|
441
441
|
console.log(result.success) // true
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
## Version management
|
|
445
|
+
|
|
446
|
+
Both `Agent` (code-defined) and `StoredAgent` instances have methods for managing configuration versions. See the [Editor overview](https://mastra.ai/docs/editor/overview) for an introduction to version management.
|
|
447
|
+
|
|
448
|
+
### Server endpoints
|
|
449
|
+
|
|
450
|
+
Version management is also available through the stored agents REST API:
|
|
451
|
+
|
|
452
|
+
| Method | Endpoint | Description |
|
|
453
|
+
| -------- | ------------------------------------------------------------ | --------------------------------------- |
|
|
454
|
+
| `GET` | `/stored/agents/:agentId/versions` | List all versions. |
|
|
455
|
+
| `POST` | `/stored/agents/:agentId/versions` | Create a new version. |
|
|
456
|
+
| `GET` | `/stored/agents/:agentId/versions/:versionId` | Get a specific version. |
|
|
457
|
+
| `POST` | `/stored/agents/:agentId/versions/:versionId/activate` | Set the active version. |
|
|
458
|
+
| `POST` | `/stored/agents/:agentId/versions/:versionId/restore` | Restore a version (creates a new copy). |
|
|
459
|
+
| `DELETE` | `/stored/agents/:agentId/versions/:versionId` | Delete a version. |
|
|
460
|
+
| `GET` | `/stored/agents/:agentId/versions/compare?from=<id>&to=<id>` | Compare two versions. |
|
|
461
|
+
|
|
462
|
+
### Getting an agent with a specific version
|
|
463
|
+
|
|
464
|
+
Pass a version identifier when getting an agent:
|
|
465
|
+
|
|
466
|
+
```typescript
|
|
467
|
+
// Load the published version (default)
|
|
468
|
+
const agent = mastraClient.getAgent('support-agent')
|
|
469
|
+
|
|
470
|
+
// Load the latest draft
|
|
471
|
+
const draftAgent = mastraClient.getAgent('support-agent', { status: 'draft' })
|
|
472
|
+
|
|
473
|
+
// Load a specific version
|
|
474
|
+
const versionedAgent = mastraClient.getAgent('support-agent', { versionId: 'abc-123' })
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
For stored agents, pass a status option to `details()`:
|
|
478
|
+
|
|
479
|
+
```typescript
|
|
480
|
+
const storedAgent = mastraClient.getStoredAgent('my-agent')
|
|
481
|
+
const draft = await storedAgent.details(undefined, { status: 'draft' })
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
### `listVersions()`
|
|
485
|
+
|
|
486
|
+
List all versions for an agent:
|
|
487
|
+
|
|
488
|
+
```typescript
|
|
489
|
+
const versions = await agent.listVersions()
|
|
490
|
+
console.log(versions.items) // Array of version snapshots
|
|
491
|
+
console.log(versions.total)
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
With pagination and sorting:
|
|
495
|
+
|
|
496
|
+
```typescript
|
|
497
|
+
const versions = await agent.listVersions({
|
|
498
|
+
page: 0,
|
|
499
|
+
perPage: 10,
|
|
500
|
+
orderBy: {
|
|
501
|
+
field: 'createdAt',
|
|
502
|
+
direction: 'DESC',
|
|
503
|
+
},
|
|
504
|
+
})
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
### `createVersion()`
|
|
508
|
+
|
|
509
|
+
Create a new version snapshot:
|
|
510
|
+
|
|
511
|
+
```typescript
|
|
512
|
+
const version = await agent.createVersion({
|
|
513
|
+
changeMessage: 'Updated tone to be more friendly',
|
|
514
|
+
})
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
### `getVersion()`
|
|
518
|
+
|
|
519
|
+
Get a specific version by ID:
|
|
520
|
+
|
|
521
|
+
```typescript
|
|
522
|
+
const version = await agent.getVersion('version-123')
|
|
523
|
+
console.log(version.versionNumber)
|
|
524
|
+
console.log(version.changedFields)
|
|
525
|
+
console.log(version.createdAt)
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
### `activateVersion()`
|
|
529
|
+
|
|
530
|
+
Set a version as the active published version:
|
|
531
|
+
|
|
532
|
+
```typescript
|
|
533
|
+
await agent.activateVersion('version-123')
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
### `restoreVersion()`
|
|
537
|
+
|
|
538
|
+
Restore a previous version by creating a new version with the same configuration:
|
|
539
|
+
|
|
540
|
+
```typescript
|
|
541
|
+
await agent.restoreVersion('version-456')
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
### `deleteVersion()`
|
|
545
|
+
|
|
546
|
+
Delete a version:
|
|
547
|
+
|
|
548
|
+
```typescript
|
|
549
|
+
await agent.deleteVersion('version-789')
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
### `compareVersions()`
|
|
553
|
+
|
|
554
|
+
Compare two versions and return their differences:
|
|
555
|
+
|
|
556
|
+
```typescript
|
|
557
|
+
const diff = await agent.compareVersions('version-123', 'version-456')
|
|
558
|
+
console.log(diff.changes) // Fields that changed between versions
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
### React SDK
|
|
562
|
+
|
|
563
|
+
In the React SDK, pass an `agentVersionId` through `requestContext` when using the `useChat` hook:
|
|
564
|
+
|
|
565
|
+
```typescript
|
|
566
|
+
import { useChat } from '@mastra/react'
|
|
567
|
+
|
|
568
|
+
function Chat() {
|
|
569
|
+
const { messages, input, handleInputChange, handleSubmit } = useChat({
|
|
570
|
+
agentId: 'support-agent',
|
|
571
|
+
requestContext: {
|
|
572
|
+
agentVersionId: 'abc-123',
|
|
573
|
+
},
|
|
574
|
+
})
|
|
575
|
+
|
|
576
|
+
// ... render chat UI
|
|
577
|
+
}
|
|
442
578
|
```
|