@mastra/mcp-docs-server 0.0.0-commonjs-20250414101718
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%2Fastra.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +161 -0
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +110 -0
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fgithub.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +26 -0
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fmem0.md +196 -0
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Frag.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fragie.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-azure.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-deepgram.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-elevenlabs.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-google.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-ibm.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-murf.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-openai.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-playai.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-replicate.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-speechify.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +250 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +250 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +302 -0
- package/.docs/organized/changelogs/create-mastra.md +302 -0
- package/.docs/organized/changelogs/mastra.md +302 -0
- package/.docs/organized/code-examples/agent-network.md +282 -0
- package/.docs/organized/code-examples/agent.md +388 -0
- package/.docs/organized/code-examples/ai-sdk-useChat.md +378 -0
- package/.docs/organized/code-examples/assistant-ui.md +37 -0
- package/.docs/organized/code-examples/bird-checker-with-express.md +235 -0
- package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +360 -0
- package/.docs/organized/code-examples/bird-checker-with-nextjs.md +250 -0
- package/.docs/organized/code-examples/client-side-tools.md +69 -0
- package/.docs/organized/code-examples/crypto-chatbot.md +96 -0
- package/.docs/organized/code-examples/fireworks-r1.md +159 -0
- package/.docs/organized/code-examples/mcp-registry-registry.md +63 -0
- package/.docs/organized/code-examples/memory-todo-agent.md +164 -0
- package/.docs/organized/code-examples/memory-with-context.md +167 -0
- package/.docs/organized/code-examples/memory-with-libsql.md +204 -0
- package/.docs/organized/code-examples/memory-with-mem0.md +121 -0
- package/.docs/organized/code-examples/memory-with-pg.md +224 -0
- package/.docs/organized/code-examples/memory-with-upstash.md +268 -0
- package/.docs/organized/code-examples/quick-start.md +129 -0
- package/.docs/organized/code-examples/stock-price-tool.md +124 -0
- package/.docs/organized/code-examples/weather-agent.md +353 -0
- package/.docs/organized/code-examples/workflow-ai-recruiter.md +159 -0
- package/.docs/organized/code-examples/workflow-with-inline-steps.md +111 -0
- package/.docs/organized/code-examples/workflow-with-memory.md +393 -0
- package/.docs/organized/code-examples/workflow-with-separate-steps.md +131 -0
- package/.docs/raw/agents/adding-tools.mdx +317 -0
- package/.docs/raw/agents/adding-voice.mdx +175 -0
- package/.docs/raw/agents/agent-memory.mdx +62 -0
- package/.docs/raw/agents/mcp-guide.mdx +215 -0
- package/.docs/raw/agents/overview.mdx +303 -0
- package/.docs/raw/community/discord.mdx +12 -0
- package/.docs/raw/community/licensing.mdx +63 -0
- package/.docs/raw/deployment/client.mdx +120 -0
- package/.docs/raw/deployment/deployment.mdx +127 -0
- package/.docs/raw/deployment/server.mdx +282 -0
- package/.docs/raw/evals/custom-eval.mdx +22 -0
- package/.docs/raw/evals/overview.mdx +95 -0
- package/.docs/raw/evals/running-in-ci.mdx +81 -0
- package/.docs/raw/evals/textual-evals.mdx +54 -0
- package/.docs/raw/faq/index.mdx +63 -0
- package/.docs/raw/frameworks/ai-sdk.mdx +296 -0
- package/.docs/raw/frameworks/next-js.mdx +238 -0
- package/.docs/raw/getting-started/installation.mdx +442 -0
- package/.docs/raw/getting-started/mcp-docs-server.mdx +141 -0
- package/.docs/raw/getting-started/project-structure.mdx +80 -0
- package/.docs/raw/index.mdx +22 -0
- package/.docs/raw/integrations/index.mdx +213 -0
- package/.docs/raw/local-dev/add-to-existing-project.mdx +48 -0
- package/.docs/raw/local-dev/creating-a-new-project.mdx +54 -0
- package/.docs/raw/local-dev/mastra-dev.mdx +108 -0
- package/.docs/raw/memory/memory-processors.mdx +131 -0
- package/.docs/raw/memory/overview.mdx +119 -0
- package/.docs/raw/memory/semantic-recall.mdx +122 -0
- package/.docs/raw/memory/working-memory.mdx +87 -0
- package/.docs/raw/observability/logging.mdx +38 -0
- package/.docs/raw/observability/nextjs-tracing.mdx +108 -0
- package/.docs/raw/observability/tracing.mdx +115 -0
- package/.docs/raw/rag/chunking-and-embedding.mdx +156 -0
- package/.docs/raw/rag/overview.mdx +85 -0
- package/.docs/raw/rag/retrieval.mdx +365 -0
- package/.docs/raw/rag/vector-databases.mdx +340 -0
- package/.docs/raw/reference/agents/createTool.mdx +229 -0
- package/.docs/raw/reference/agents/generate.mdx +334 -0
- package/.docs/raw/reference/agents/getAgent.mdx +54 -0
- package/.docs/raw/reference/agents/stream.mdx +369 -0
- package/.docs/raw/reference/cli/build.mdx +55 -0
- package/.docs/raw/reference/cli/dev.mdx +134 -0
- package/.docs/raw/reference/cli/init.mdx +43 -0
- package/.docs/raw/reference/client-js/agents.mdx +107 -0
- package/.docs/raw/reference/client-js/error-handling.mdx +38 -0
- package/.docs/raw/reference/client-js/logs.mdx +24 -0
- package/.docs/raw/reference/client-js/memory.mdx +97 -0
- package/.docs/raw/reference/client-js/telemetry.mdx +20 -0
- package/.docs/raw/reference/client-js/tools.mdx +44 -0
- package/.docs/raw/reference/client-js/vectors.mdx +79 -0
- package/.docs/raw/reference/client-js/workflows.mdx +136 -0
- package/.docs/raw/reference/core/mastra-class.mdx +232 -0
- package/.docs/raw/reference/deployer/cloudflare.mdx +207 -0
- package/.docs/raw/reference/deployer/deployer.mdx +159 -0
- package/.docs/raw/reference/deployer/netlify.mdx +109 -0
- package/.docs/raw/reference/deployer/vercel.mdx +117 -0
- package/.docs/raw/reference/evals/answer-relevancy.mdx +186 -0
- package/.docs/raw/reference/evals/bias.mdx +186 -0
- package/.docs/raw/reference/evals/completeness.mdx +174 -0
- package/.docs/raw/reference/evals/content-similarity.mdx +183 -0
- package/.docs/raw/reference/evals/context-position.mdx +190 -0
- package/.docs/raw/reference/evals/context-precision.mdx +189 -0
- package/.docs/raw/reference/evals/context-relevancy.mdx +188 -0
- package/.docs/raw/reference/evals/contextual-recall.mdx +191 -0
- package/.docs/raw/reference/evals/faithfulness.mdx +193 -0
- package/.docs/raw/reference/evals/hallucination.mdx +219 -0
- package/.docs/raw/reference/evals/keyword-coverage.mdx +176 -0
- package/.docs/raw/reference/evals/prompt-alignment.mdx +238 -0
- package/.docs/raw/reference/evals/summarization.mdx +205 -0
- package/.docs/raw/reference/evals/textual-difference.mdx +161 -0
- package/.docs/raw/reference/evals/tone-consistency.mdx +181 -0
- package/.docs/raw/reference/evals/toxicity.mdx +165 -0
- package/.docs/raw/reference/index.mdx +12 -0
- package/.docs/raw/reference/memory/Memory.mdx +212 -0
- package/.docs/raw/reference/memory/createThread.mdx +95 -0
- package/.docs/raw/reference/memory/getThreadById.mdx +46 -0
- package/.docs/raw/reference/memory/getThreadsByResourceId.mdx +48 -0
- package/.docs/raw/reference/memory/query.mdx +167 -0
- package/.docs/raw/reference/networks/agent-network.mdx +159 -0
- package/.docs/raw/reference/observability/create-logger.mdx +106 -0
- package/.docs/raw/reference/observability/logger.mdx +55 -0
- package/.docs/raw/reference/observability/otel-config.mdx +120 -0
- package/.docs/raw/reference/observability/providers/braintrust.mdx +40 -0
- package/.docs/raw/reference/observability/providers/dash0.mdx +40 -0
- package/.docs/raw/reference/observability/providers/index.mdx +16 -0
- package/.docs/raw/reference/observability/providers/laminar.mdx +41 -0
- package/.docs/raw/reference/observability/providers/langfuse.mdx +51 -0
- package/.docs/raw/reference/observability/providers/langsmith.mdx +48 -0
- package/.docs/raw/reference/observability/providers/langwatch.mdx +45 -0
- package/.docs/raw/reference/observability/providers/new-relic.mdx +40 -0
- package/.docs/raw/reference/observability/providers/signoz.mdx +40 -0
- package/.docs/raw/reference/observability/providers/traceloop.mdx +40 -0
- package/.docs/raw/reference/rag/astra.mdx +258 -0
- package/.docs/raw/reference/rag/chroma.mdx +281 -0
- package/.docs/raw/reference/rag/chunk.mdx +235 -0
- package/.docs/raw/reference/rag/document.mdx +127 -0
- package/.docs/raw/reference/rag/embeddings.mdx +160 -0
- package/.docs/raw/reference/rag/extract-params.mdx +226 -0
- package/.docs/raw/reference/rag/graph-rag.mdx +182 -0
- package/.docs/raw/reference/rag/libsql.mdx +357 -0
- package/.docs/raw/reference/rag/metadata-filters.mdx +298 -0
- package/.docs/raw/reference/rag/pg.mdx +477 -0
- package/.docs/raw/reference/rag/pinecone.mdx +281 -0
- package/.docs/raw/reference/rag/qdrant.mdx +236 -0
- package/.docs/raw/reference/rag/rerank.mdx +212 -0
- package/.docs/raw/reference/rag/turbopuffer.mdx +249 -0
- package/.docs/raw/reference/rag/upstash.mdx +247 -0
- package/.docs/raw/reference/rag/vectorize.mdx +298 -0
- package/.docs/raw/reference/storage/libsql.mdx +74 -0
- package/.docs/raw/reference/storage/postgresql.mdx +48 -0
- package/.docs/raw/reference/storage/upstash.mdx +86 -0
- package/.docs/raw/reference/tools/client.mdx +207 -0
- package/.docs/raw/reference/tools/document-chunker-tool.mdx +141 -0
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +154 -0
- package/.docs/raw/reference/tools/mcp-configuration.mdx +206 -0
- package/.docs/raw/reference/tools/vector-query-tool.mdx +212 -0
- package/.docs/raw/reference/voice/composite-voice.mdx +140 -0
- package/.docs/raw/reference/voice/deepgram.mdx +164 -0
- package/.docs/raw/reference/voice/elevenlabs.mdx +216 -0
- package/.docs/raw/reference/voice/google.mdx +198 -0
- package/.docs/raw/reference/voice/mastra-voice.mdx +394 -0
- package/.docs/raw/reference/voice/murf.mdx +251 -0
- package/.docs/raw/reference/voice/openai-realtime.mdx +431 -0
- package/.docs/raw/reference/voice/openai.mdx +168 -0
- package/.docs/raw/reference/voice/playai.mdx +159 -0
- package/.docs/raw/reference/voice/sarvam.mdx +260 -0
- package/.docs/raw/reference/voice/speechify.mdx +145 -0
- package/.docs/raw/reference/voice/voice.answer.mdx +122 -0
- package/.docs/raw/reference/voice/voice.connect.mdx +124 -0
- package/.docs/raw/reference/voice/voice.listen.mdx +195 -0
- package/.docs/raw/reference/voice/voice.on.mdx +189 -0
- package/.docs/raw/reference/voice/voice.send.mdx +118 -0
- package/.docs/raw/reference/voice/voice.speak.mdx +203 -0
- package/.docs/raw/reference/workflows/after.mdx +88 -0
- package/.docs/raw/reference/workflows/afterEvent.mdx +76 -0
- package/.docs/raw/reference/workflows/commit.mdx +37 -0
- package/.docs/raw/reference/workflows/createRun.mdx +77 -0
- package/.docs/raw/reference/workflows/else.mdx +72 -0
- package/.docs/raw/reference/workflows/events.mdx +305 -0
- package/.docs/raw/reference/workflows/execute.mdx +110 -0
- package/.docs/raw/reference/workflows/if.mdx +107 -0
- package/.docs/raw/reference/workflows/resume.mdx +155 -0
- package/.docs/raw/reference/workflows/resumeWithEvent.mdx +133 -0
- package/.docs/raw/reference/workflows/snapshots.mdx +207 -0
- package/.docs/raw/reference/workflows/start.mdx +84 -0
- package/.docs/raw/reference/workflows/step-class.mdx +100 -0
- package/.docs/raw/reference/workflows/step-condition.mdx +134 -0
- package/.docs/raw/reference/workflows/step-function.mdx +92 -0
- package/.docs/raw/reference/workflows/step-options.mdx +69 -0
- package/.docs/raw/reference/workflows/step-retries.mdx +203 -0
- package/.docs/raw/reference/workflows/suspend.mdx +70 -0
- package/.docs/raw/reference/workflows/then.mdx +74 -0
- package/.docs/raw/reference/workflows/until.mdx +165 -0
- package/.docs/raw/reference/workflows/watch.mdx +118 -0
- package/.docs/raw/reference/workflows/while.mdx +168 -0
- package/.docs/raw/reference/workflows/workflow.mdx +233 -0
- package/.docs/raw/storage/overview.mdx +378 -0
- package/.docs/raw/voice/overview.mdx +135 -0
- package/.docs/raw/voice/speech-to-text.mdx +45 -0
- package/.docs/raw/voice/text-to-speech.mdx +52 -0
- package/.docs/raw/voice/voice-to-voice.mdx +310 -0
- package/.docs/raw/workflows/control-flow.mdx +778 -0
- package/.docs/raw/workflows/dynamic-workflows.mdx +236 -0
- package/.docs/raw/workflows/error-handling.mdx +183 -0
- package/.docs/raw/workflows/nested-workflows.mdx +352 -0
- package/.docs/raw/workflows/overview.mdx +203 -0
- package/.docs/raw/workflows/steps.mdx +108 -0
- package/.docs/raw/workflows/suspend-and-resume.mdx +404 -0
- package/.docs/raw/workflows/variables.mdx +313 -0
- package/LICENSE.md +46 -0
- package/README.md +129 -0
- package/dist/_tsup-dts-rollup.d.ts +149 -0
- package/dist/chunk-QWYMT5LP.js +194 -0
- package/dist/prepare-docs/prepare.d.ts +1 -0
- package/dist/prepare-docs/prepare.js +1 -0
- package/dist/stdio.d.ts +1 -0
- package/dist/stdio.js +518 -0
- package/package.json +60 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 'AgentNetwork (Experimental)'
|
|
3
|
+
description: 'Reference documentation for the AgentNetwork class'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# AgentNetwork (Experimental)
|
|
7
|
+
|
|
8
|
+
> **Note:** The AgentNetwork feature is experimental and may change in future releases.
|
|
9
|
+
|
|
10
|
+
The `AgentNetwork` class provides a way to create a network of specialized agents that can collaborate to solve complex tasks. Unlike Workflows, which require explicit control over execution paths, AgentNetwork uses an LLM-based router to dynamically determine which agent to call next.
|
|
11
|
+
|
|
12
|
+
## Key Concepts
|
|
13
|
+
|
|
14
|
+
- **LLM-based Routing**: AgentNetwork exclusively uses an LLM to figure out the best way to use your agents
|
|
15
|
+
- **Agent Collaboration**: Multiple specialized agents can work together to solve complex tasks
|
|
16
|
+
- **Dynamic Decision Making**: The router decides which agent to call based on the task requirements
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
import { AgentNetwork } from '@mastra/core/network';
|
|
22
|
+
import { openai } from '@mastra/openai';
|
|
23
|
+
|
|
24
|
+
// Create specialized agents
|
|
25
|
+
const webSearchAgent = new Agent({
|
|
26
|
+
name: 'Web Search Agent',
|
|
27
|
+
instructions: 'You search the web for information.',
|
|
28
|
+
model: openai('gpt-4o'),
|
|
29
|
+
tools: { /* web search tools */ },
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const dataAnalysisAgent = new Agent({
|
|
33
|
+
name: 'Data Analysis Agent',
|
|
34
|
+
instructions: 'You analyze data and provide insights.',
|
|
35
|
+
model: openai('gpt-4o'),
|
|
36
|
+
tools: { /* data analysis tools */ },
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Create the network
|
|
40
|
+
const researchNetwork = new AgentNetwork({
|
|
41
|
+
name: 'Research Network',
|
|
42
|
+
instructions: 'Coordinate specialized agents to research topics thoroughly.',
|
|
43
|
+
model: openai('gpt-4o'),
|
|
44
|
+
agents: [webSearchAgent, dataAnalysisAgent],
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// Use the network
|
|
48
|
+
const result = await researchNetwork.generate('Research the impact of climate change on agriculture');
|
|
49
|
+
console.log(result.text);
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Constructor
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
constructor(config: AgentNetworkConfig)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Parameters
|
|
59
|
+
|
|
60
|
+
- `config`: Configuration object for the AgentNetwork
|
|
61
|
+
- `name`: Name of the network
|
|
62
|
+
- `instructions`: Instructions for the routing agent
|
|
63
|
+
- `model`: Language model to use for routing
|
|
64
|
+
- `agents`: Array of specialized agents in the network
|
|
65
|
+
|
|
66
|
+
## Methods
|
|
67
|
+
|
|
68
|
+
### generate()
|
|
69
|
+
|
|
70
|
+
Generates a response using the agent network. This method has replaced the deprecated `run()` method for consistency with the rest of the codebase.
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
async generate(
|
|
74
|
+
messages: string | string[] | CoreMessage[],
|
|
75
|
+
args?: AgentGenerateOptions
|
|
76
|
+
): Promise<GenerateTextResult>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### stream()
|
|
80
|
+
|
|
81
|
+
Streams a response using the agent network.
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
async stream(
|
|
85
|
+
messages: string | string[] | CoreMessage[],
|
|
86
|
+
args?: AgentStreamOptions
|
|
87
|
+
): Promise<StreamTextResult>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### getRoutingAgent()
|
|
91
|
+
|
|
92
|
+
Returns the routing agent used by the network.
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
getRoutingAgent(): Agent
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### getAgents()
|
|
99
|
+
|
|
100
|
+
Returns the array of specialized agents in the network.
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
getAgents(): Agent[]
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### getAgentHistory()
|
|
107
|
+
|
|
108
|
+
Returns the history of interactions for a specific agent.
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
getAgentHistory(agentId: string): Array<{
|
|
112
|
+
input: string;
|
|
113
|
+
output: string;
|
|
114
|
+
timestamp: string;
|
|
115
|
+
}>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### getAgentInteractionHistory()
|
|
119
|
+
|
|
120
|
+
Returns the history of all agent interactions that have occurred in the network.
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
getAgentInteractionHistory(): Record<
|
|
124
|
+
string,
|
|
125
|
+
Array<{
|
|
126
|
+
input: string;
|
|
127
|
+
output: string;
|
|
128
|
+
timestamp: string;
|
|
129
|
+
}>
|
|
130
|
+
>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### getAgentInteractionSummary()
|
|
134
|
+
|
|
135
|
+
Returns a formatted summary of agent interactions in chronological order.
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
getAgentInteractionSummary(): string
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## When to Use AgentNetwork vs Workflows
|
|
142
|
+
|
|
143
|
+
- **Use AgentNetwork when:** You want the AI to figure out the best way to use your agents, with dynamic routing based on the task requirements.
|
|
144
|
+
|
|
145
|
+
- **Use Workflows when:** You need explicit control over execution paths, with predetermined sequences of agent calls and conditional logic.
|
|
146
|
+
|
|
147
|
+
## Internal Tools
|
|
148
|
+
|
|
149
|
+
The AgentNetwork uses a special `transmit` tool that allows the routing agent to call specialized agents. This tool handles:
|
|
150
|
+
|
|
151
|
+
- Single agent calls
|
|
152
|
+
- Multiple parallel agent calls
|
|
153
|
+
- Context sharing between agents
|
|
154
|
+
|
|
155
|
+
## Limitations
|
|
156
|
+
|
|
157
|
+
- The AgentNetwork approach may use more tokens than a well-designed Workflow for the same task
|
|
158
|
+
- Debugging can be more challenging as the routing decisions are made by the LLM
|
|
159
|
+
- Performance may vary based on the quality of the routing instructions and the capabilities of the specialized agents
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: createLogger() | Mastra Observability Docs"
|
|
3
|
+
description: Documentation for the createLogger function, which instantiates a logger based on a given configuration.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# createLogger()
|
|
7
|
+
|
|
8
|
+
The `createLogger()` function is used to instantiate a logger based on a given configuration. You can create console-based, file-based, or Upstash Redis-based loggers by specifying the type and any additional parameters relevant to that type.
|
|
9
|
+
|
|
10
|
+
### Usage
|
|
11
|
+
|
|
12
|
+
#### Console Logger (Development)
|
|
13
|
+
|
|
14
|
+
```typescript showLineNumbers copy
|
|
15
|
+
const consoleLogger = createLogger({ name: "Mastra", level: "debug" });
|
|
16
|
+
consoleLogger.info("App started");
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
#### File Transport (Structured Logs)
|
|
20
|
+
|
|
21
|
+
```typescript showLineNumbers copy
|
|
22
|
+
import { FileTransport } from "@mastra/loggers/file";
|
|
23
|
+
|
|
24
|
+
const fileLogger = createLogger({
|
|
25
|
+
name: "Mastra",
|
|
26
|
+
transports: { file: new FileTransport({ path: "test-dir/test.log" }) },
|
|
27
|
+
level: "warn",
|
|
28
|
+
});
|
|
29
|
+
fileLogger.warn("Low disk space", {
|
|
30
|
+
destinationPath: "system",
|
|
31
|
+
type: "WORKFLOW",
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
#### Upstash Logger (Remote Log Drain)
|
|
36
|
+
|
|
37
|
+
```typescript showLineNumbers copy
|
|
38
|
+
import { UpstashTransport } from "@mastra/loggers/upstash";
|
|
39
|
+
|
|
40
|
+
const logger = createLogger({
|
|
41
|
+
name: "Mastra",
|
|
42
|
+
transports: {
|
|
43
|
+
upstash: new UpstashTransport({
|
|
44
|
+
listName: "production-logs",
|
|
45
|
+
upstashUrl: process.env.UPSTASH_URL!,
|
|
46
|
+
upstashToken: process.env.UPSTASH_TOKEN!,
|
|
47
|
+
}),
|
|
48
|
+
},
|
|
49
|
+
level: "info",
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
logger.info({
|
|
53
|
+
message: "User signed in",
|
|
54
|
+
destinationPath: "auth",
|
|
55
|
+
type: "AGENT",
|
|
56
|
+
runId: "run_123",
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Parameters
|
|
61
|
+
|
|
62
|
+
<PropertiesTable
|
|
63
|
+
content={[
|
|
64
|
+
{
|
|
65
|
+
name: "type",
|
|
66
|
+
type: "CONSOLE" | "FILE" | "UPSTASH",
|
|
67
|
+
description: "Specifies the logger implementation to create.",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: "level",
|
|
71
|
+
type: "LogLevel",
|
|
72
|
+
isOptional: true,
|
|
73
|
+
default: "INFO",
|
|
74
|
+
description:
|
|
75
|
+
"Minimum severity level of logs to record. One of DEBUG, INFO, WARN, or ERROR.",
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: "dirPath",
|
|
79
|
+
type: "string",
|
|
80
|
+
isOptional: true,
|
|
81
|
+
description:
|
|
82
|
+
'For FILE type only. Directory path where log files are stored (default: "logs").',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: "url",
|
|
86
|
+
type: "string",
|
|
87
|
+
isOptional: true,
|
|
88
|
+
description:
|
|
89
|
+
"For UPSTASH type only. Upstash Redis endpoint URL used for storing logs.",
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: "token",
|
|
93
|
+
type: "string",
|
|
94
|
+
isOptional: true,
|
|
95
|
+
description: "For UPSTASH type only. Upstash Redis access token.",
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: "key",
|
|
99
|
+
type: "string",
|
|
100
|
+
isOptional: true,
|
|
101
|
+
default: "logs",
|
|
102
|
+
description:
|
|
103
|
+
"For UPSTASH type only. Redis list key under which logs are stored.",
|
|
104
|
+
},
|
|
105
|
+
]}
|
|
106
|
+
/>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Logger Instance | Mastra Observability Docs"
|
|
3
|
+
description: Documentation for Logger instances, which provide methods to record events at various severity levels.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Logger Instance
|
|
7
|
+
|
|
8
|
+
A Logger instance is created by `createLogger()` and provides methods to record events at various severity levels. Depending on the logger type, messages may be written to the console, file, or an external service.
|
|
9
|
+
|
|
10
|
+
## Example
|
|
11
|
+
|
|
12
|
+
```typescript showLineNumbers copy
|
|
13
|
+
// Using a console logger
|
|
14
|
+
const logger = createLogger({ name: 'Mastra', level: 'info' });
|
|
15
|
+
|
|
16
|
+
logger.debug('Debug message'); // Won't be logged because level is INFO
|
|
17
|
+
logger.info({ message: 'User action occurred', destinationPath: 'user-actions', type: 'AGENT' }); // Logged
|
|
18
|
+
logger.error('An error occurred'); // Logged as ERROR
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Methods
|
|
22
|
+
|
|
23
|
+
<PropertiesTable
|
|
24
|
+
content={[
|
|
25
|
+
{
|
|
26
|
+
name: 'debug',
|
|
27
|
+
type: '(message: BaseLogMessage | string, ...args: any[]) => void | Promise<void>',
|
|
28
|
+
description: 'Write a DEBUG-level log. Only recorded if level ≤ DEBUG.',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'info',
|
|
32
|
+
type: '(message: BaseLogMessage | string, ...args: any[]) => void | Promise<void>',
|
|
33
|
+
description: 'Write an INFO-level log. Only recorded if level ≤ INFO.',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'warn',
|
|
37
|
+
type: '(message: BaseLogMessage | string, ...args: any[]) => void | Promise<void>',
|
|
38
|
+
description: 'Write a WARN-level log. Only recorded if level ≤ WARN.',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'error',
|
|
42
|
+
type: '(message: BaseLogMessage | string, ...args: any[]) => void | Promise<void>',
|
|
43
|
+
description: 'Write an ERROR-level log. Only recorded if level ≤ ERROR.',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'cleanup',
|
|
47
|
+
type: '() => Promise<void>',
|
|
48
|
+
isOptional: true,
|
|
49
|
+
description:
|
|
50
|
+
'Cleanup resources held by the logger (e.g., network connections for Upstash). Not all loggers implement this.',
|
|
51
|
+
},
|
|
52
|
+
]}
|
|
53
|
+
/>
|
|
54
|
+
|
|
55
|
+
**Note:** Some loggers require a `BaseLogMessage` object (with `message`, `destinationPath`, `type` fields). For instance, the `File` and `Upstash` loggers need structured messages.
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: OtelConfig | Mastra Observability Docs"
|
|
3
|
+
description: Documentation for the OtelConfig object, which configures OpenTelemetry instrumentation, tracing, and exporting behavior.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# `OtelConfig`
|
|
7
|
+
|
|
8
|
+
The `OtelConfig` object is used to configure OpenTelemetry instrumentation, tracing, and exporting behavior within your application. By adjusting its properties, you can control how telemetry data (such as traces) is collected, sampled, and exported.
|
|
9
|
+
|
|
10
|
+
To use the `OtelConfig` within Mastra, pass it as the value of the `telemetry` key when initializing Mastra. This will configure Mastra to use your custom OpenTelemetry settings for tracing and instrumentation.
|
|
11
|
+
|
|
12
|
+
```typescript showLineNumbers copy
|
|
13
|
+
import { Mastra } from 'mastra';
|
|
14
|
+
|
|
15
|
+
const otelConfig: OtelConfig = {
|
|
16
|
+
serviceName: 'my-awesome-service',
|
|
17
|
+
enabled: true,
|
|
18
|
+
sampling: {
|
|
19
|
+
type: 'ratio',
|
|
20
|
+
probability: 0.5,
|
|
21
|
+
},
|
|
22
|
+
export: {
|
|
23
|
+
type: 'otlp',
|
|
24
|
+
endpoint: 'https://otel-collector.example.com/v1/traces',
|
|
25
|
+
headers: {
|
|
26
|
+
Authorization: 'Bearer YOUR_TOKEN_HERE',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Properties
|
|
33
|
+
|
|
34
|
+
<PropertiesTable
|
|
35
|
+
content={[
|
|
36
|
+
{
|
|
37
|
+
name: 'serviceName',
|
|
38
|
+
type: 'string',
|
|
39
|
+
isOptional: true,
|
|
40
|
+
default: 'default-service',
|
|
41
|
+
description:
|
|
42
|
+
'Human-readable name used to identify your service in telemetry backends.',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: 'enabled',
|
|
46
|
+
type: 'boolean',
|
|
47
|
+
isOptional: true,
|
|
48
|
+
default: 'true',
|
|
49
|
+
description:
|
|
50
|
+
'Whether telemetry collection and export are enabled.',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'sampling',
|
|
54
|
+
type: 'SamplingStrategy',
|
|
55
|
+
isOptional: true,
|
|
56
|
+
description:
|
|
57
|
+
'Defines the sampling strategy for traces, controlling how much data is collected.',
|
|
58
|
+
properties: [
|
|
59
|
+
{
|
|
60
|
+
name: 'type',
|
|
61
|
+
type: `'ratio' | 'always_on' | 'always_off' | 'parent_based'`,
|
|
62
|
+
description:
|
|
63
|
+
'Specifies the sampling strategy type.',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'probability',
|
|
67
|
+
type: 'number (0.0 to 1.0)',
|
|
68
|
+
isOptional: true,
|
|
69
|
+
description:
|
|
70
|
+
'For `ratio` or `parent_based` strategies, defines the sampling probability.',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: 'root',
|
|
74
|
+
type: 'object',
|
|
75
|
+
isOptional: true,
|
|
76
|
+
description:
|
|
77
|
+
'For `parent_based` strategy, configures root-level probability sampling.',
|
|
78
|
+
properties: [
|
|
79
|
+
{
|
|
80
|
+
name: 'probability',
|
|
81
|
+
type: 'number (0.0 to 1.0)',
|
|
82
|
+
isOptional: true,
|
|
83
|
+
description:
|
|
84
|
+
'Sampling probability for root traces in `parent_based` strategy.',
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: 'export',
|
|
92
|
+
type: 'object',
|
|
93
|
+
isOptional: true,
|
|
94
|
+
description:
|
|
95
|
+
'Configuration for exporting collected telemetry data.',
|
|
96
|
+
properties: [
|
|
97
|
+
{
|
|
98
|
+
name: 'type',
|
|
99
|
+
type: `'otlp' | 'console'`,
|
|
100
|
+
description:
|
|
101
|
+
'Specifies the exporter type. Use `otlp` for external exporters or `console` for development.',
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: 'endpoint',
|
|
105
|
+
type: 'string',
|
|
106
|
+
isOptional: true,
|
|
107
|
+
description:
|
|
108
|
+
'For `otlp` type, the OTLP endpoint URL to send traces to.',
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: 'headers',
|
|
112
|
+
type: 'Record<string, string>',
|
|
113
|
+
isOptional: true,
|
|
114
|
+
description:
|
|
115
|
+
'Additional headers to send with OTLP requests, useful for authentication or routing.',
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
},
|
|
119
|
+
]}
|
|
120
|
+
/>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Braintrust | Observability | Mastra Docs"
|
|
3
|
+
description: Documentation for integrating Braintrust with Mastra, an evaluation and monitoring platform for LLM applications.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Braintrust
|
|
7
|
+
|
|
8
|
+
Braintrust is an evaluation and monitoring platform for LLM applications.
|
|
9
|
+
|
|
10
|
+
## Configuration
|
|
11
|
+
|
|
12
|
+
To use Braintrust with Mastra, configure these environment variables:
|
|
13
|
+
|
|
14
|
+
```env
|
|
15
|
+
OTEL_EXPORTER_OTLP_ENDPOINT=https://api.braintrust.dev/otel
|
|
16
|
+
OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer <Your API Key>, x-bt-parent=project_id:<Your Project ID>"
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Implementation
|
|
20
|
+
|
|
21
|
+
Here's how to configure Mastra to use Braintrust:
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { Mastra } from "@mastra/core";
|
|
25
|
+
|
|
26
|
+
export const mastra = new Mastra({
|
|
27
|
+
// ... other config
|
|
28
|
+
telemetry: {
|
|
29
|
+
serviceName: "your-service-name",
|
|
30
|
+
enabled: true,
|
|
31
|
+
export: {
|
|
32
|
+
type: "otlp",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Dashboard
|
|
39
|
+
|
|
40
|
+
Access your Braintrust dashboard at [braintrust.dev](https://www.braintrust.dev/)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Dash0 Integration | Mastra Observability Docs"
|
|
3
|
+
description: Documentation for integrating Mastra with Dash0, an Open Telementry native observability solution.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Dash0
|
|
7
|
+
|
|
8
|
+
Dash0, an Open Telementry native observability solution that provides full-stack monitoring capabilities as well as integrations with other CNCF projects like Perses and Prometheus.
|
|
9
|
+
|
|
10
|
+
## Configuration
|
|
11
|
+
|
|
12
|
+
To use Dash0 with Mastra, configure these environment variables:
|
|
13
|
+
|
|
14
|
+
```env
|
|
15
|
+
OTEL_EXPORTER_OTLP_ENDPOINT=https://ingress.<region>.dash0.com
|
|
16
|
+
OTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer <your-auth-token>, Dash0-Dataset=<optional-dataset>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Implementation
|
|
20
|
+
|
|
21
|
+
Here's how to configure Mastra to use Dash0:
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { Mastra } from "@mastra/core";
|
|
25
|
+
|
|
26
|
+
export const mastra = new Mastra({
|
|
27
|
+
// ... other config
|
|
28
|
+
telemetry: {
|
|
29
|
+
serviceName: "your-service-name",
|
|
30
|
+
enabled: true,
|
|
31
|
+
export: {
|
|
32
|
+
type: "otlp",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Dashboard
|
|
39
|
+
|
|
40
|
+
Access your Dash0 dashboards at [dash0.com](https://www.dash0.com/) and find out how to do more [Distributed Tracing](https://www.dash0.com/distributed-tracing) integrations in the [Dash0 Integration Hub](https://www.dash0.com/hub/integrations)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Provider List | Observability | Mastra Docs"
|
|
3
|
+
description: Overview of observability providers supported by Mastra, including Dash0, SigNoz, Braintrust, Langfuse, and more.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Observability Providers
|
|
7
|
+
|
|
8
|
+
Observability providers include:
|
|
9
|
+
- [Braintrust](./providers/braintrust.mdx)
|
|
10
|
+
- [Dash0](./providers/dash0.mdx)
|
|
11
|
+
- [Laminar](./providers/laminar.mdx)
|
|
12
|
+
- [Langfuse](./providers/langfuse.mdx)
|
|
13
|
+
- [Langsmith](./providers/langsmith.mdx)
|
|
14
|
+
- [New Relic](./providers/new-relic.mdx)
|
|
15
|
+
- [SigNoz](./providers/signoz.mdx)
|
|
16
|
+
- [Traceloop](./providers/traceloop.mdx)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Laminar Integration | Mastra Observability Docs"
|
|
3
|
+
description: Documentation for integrating Laminar with Mastra, a specialized observability platform for LLM applications.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Laminar
|
|
7
|
+
|
|
8
|
+
Laminar is a specialized observability platform for LLM applications.
|
|
9
|
+
|
|
10
|
+
## Configuration
|
|
11
|
+
|
|
12
|
+
To use Laminar with Mastra, configure these environment variables:
|
|
13
|
+
|
|
14
|
+
```env
|
|
15
|
+
OTEL_EXPORTER_OTLP_ENDPOINT=https://api.lmnr.ai:8443
|
|
16
|
+
OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer your_api_key, x-laminar-team-id=your_team_id"
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Implementation
|
|
20
|
+
|
|
21
|
+
Here's how to configure Mastra to use Laminar:
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { Mastra } from "@mastra/core";
|
|
25
|
+
|
|
26
|
+
export const mastra = new Mastra({
|
|
27
|
+
// ... other config
|
|
28
|
+
telemetry: {
|
|
29
|
+
serviceName: "your-service-name",
|
|
30
|
+
enabled: true,
|
|
31
|
+
export: {
|
|
32
|
+
type: "otlp",
|
|
33
|
+
protocol: "grpc",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Dashboard
|
|
40
|
+
|
|
41
|
+
Access your Laminar dashboard at [https://lmnr.ai/](https://lmnr.ai/)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Langfuse Integration | Mastra Observability Docs"
|
|
3
|
+
description: Documentation for integrating Langfuse with Mastra, an open-source observability platform for LLM applications.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Langfuse
|
|
7
|
+
|
|
8
|
+
Langfuse is an open-source observability platform designed specifically for LLM applications.
|
|
9
|
+
|
|
10
|
+
> **Note**: Currently, only AI-related calls will contain detailed telemetry data. Other operations will create traces but with limited information.
|
|
11
|
+
|
|
12
|
+
## Configuration
|
|
13
|
+
|
|
14
|
+
To use Langfuse with Mastra, you'll need to configure the following environment variables:
|
|
15
|
+
|
|
16
|
+
```env
|
|
17
|
+
LANGFUSE_PUBLIC_KEY=your_public_key
|
|
18
|
+
LANGFUSE_SECRET_KEY=your_secret_key
|
|
19
|
+
LANGFUSE_BASEURL=https://cloud.langfuse.com # Optional - defaults to cloud.langfuse.com
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**Important**: When configuring the telemetry export settings, the `traceName` parameter must be set to `"ai"` for the Langfuse integration to work properly.
|
|
23
|
+
|
|
24
|
+
## Implementation
|
|
25
|
+
|
|
26
|
+
Here's how to configure Mastra to use Langfuse:
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { Mastra } from "@mastra/core";
|
|
30
|
+
import { LangfuseExporter } from "langfuse-vercel";
|
|
31
|
+
|
|
32
|
+
export const mastra = new Mastra({
|
|
33
|
+
// ... other config
|
|
34
|
+
telemetry: {
|
|
35
|
+
serviceName: "ai", // this must be set to "ai" so that the LangfuseExporter thinks it's an AI SDK trace
|
|
36
|
+
enabled: true,
|
|
37
|
+
export: {
|
|
38
|
+
type: "custom",
|
|
39
|
+
exporter: new LangfuseExporter({
|
|
40
|
+
publicKey: process.env.LANGFUSE_PUBLIC_KEY,
|
|
41
|
+
secretKey: process.env.LANGFUSE_SECRET_KEY,
|
|
42
|
+
baseUrl: process.env.LANGFUSE_BASEURL,
|
|
43
|
+
}),
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Dashboard
|
|
50
|
+
|
|
51
|
+
Once configured, you can view your traces and analytics in the Langfuse dashboard at [cloud.langfuse.com](https://cloud.langfuse.com)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: LangSmith Integration | Mastra Observability Docs"
|
|
3
|
+
description: Documentation for integrating LangSmith with Mastra, a platform for debugging, testing, evaluating, and monitoring LLM applications.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# LangSmith
|
|
7
|
+
|
|
8
|
+
LangSmith is LangChain's platform for debugging, testing, evaluating, and monitoring LLM applications.
|
|
9
|
+
|
|
10
|
+
> **Note**: Currently, this integration only traces AI-related calls in your application. Other types of operations are not captured in the telemetry data.
|
|
11
|
+
|
|
12
|
+
## Configuration
|
|
13
|
+
|
|
14
|
+
To use LangSmith with Mastra, you'll need to configure the following environment variables:
|
|
15
|
+
|
|
16
|
+
```env
|
|
17
|
+
LANGSMITH_TRACING=true
|
|
18
|
+
LANGSMITH_ENDPOINT=https://api.smith.langchain.com
|
|
19
|
+
LANGSMITH_API_KEY=your-api-key
|
|
20
|
+
LANGSMITH_PROJECT=your-project-name
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Implementation
|
|
24
|
+
|
|
25
|
+
Here's how to configure Mastra to use LangSmith:
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { Mastra } from "@mastra/core";
|
|
29
|
+
import { AISDKExporter } from "langsmith/vercel";
|
|
30
|
+
|
|
31
|
+
export const mastra = new Mastra({
|
|
32
|
+
// ... other config
|
|
33
|
+
telemetry: {
|
|
34
|
+
serviceName: "your-service-name",
|
|
35
|
+
enabled: true,
|
|
36
|
+
export: {
|
|
37
|
+
type: "custom",
|
|
38
|
+
exporter: new AISDKExporter(),
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Dashboard
|
|
45
|
+
|
|
46
|
+
Access your traces and analytics in the LangSmith dashboard at [smith.langchain.com](https://smith.langchain.com)
|
|
47
|
+
|
|
48
|
+
> **Note**: Even if you run your workflows, you may not see data appearing in a new project. You will need to sort by Name column to see all projects, select your project, then filter by LLM Calls instead of Root Runs.
|