Skip to content

Commit 223c6bd

Browse files
committed
feat: update agents to include observability tracing policy
- Added `InternalSpans` import from `@mastra/core/observability` in multiple agent files. - Updated options in various agents to include a tracing policy with `internal: InternalSpans.ALL`. - Removed commented-out code for `convertDataFormatTool` and `processXMLTool` in `dataTransformationAgent.ts`. - Ensured all agents now have a consistent tracing policy setup for improved observability. - Adjusted memory configurations in `codingAgents.ts` to use `pgMemory` instead of `upstashMemory`. - Cleaned up agent configurations for better maintainability and clarity.
1 parent 05e462a commit 223c6bd

41 files changed

Lines changed: 478 additions & 198 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package-lock.json

Lines changed: 138 additions & 138 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@
4242
"node": ">=20.9.0"
4343
},
4444
"dependencies": {
45-
"@ai-sdk/google": "^3.0.6",
46-
"@ai-sdk/google-vertex": "^4.0.13",
47-
"@ai-sdk/openai": "^3.0.8",
48-
"@ai-sdk/openai-compatible": "^2.0.5",
49-
"@ai-sdk/react": "^3.0.30",
45+
"@ai-sdk/google": "^3.0.7",
46+
"@ai-sdk/google-vertex": "^4.0.14",
47+
"@ai-sdk/openai": "^3.0.9",
48+
"@ai-sdk/openai-compatible": "^2.0.8",
49+
"@ai-sdk/react": "^3.0.35",
5050
"@dotenvx/dotenvx": "^1.51.4",
5151
"@e2b/code-interpreter": "^2.3.3",
5252
"@emotion/react": "^11.14.0",
@@ -108,7 +108,7 @@
108108
"@vercel/otel": "^2.1.0",
109109
"@xyflow/react": "^12.10.0",
110110
"a2a-ai-provider": "^0.4.0-alpha.2",
111-
"ai": "^5.0.119",
111+
"ai": "^5.0.121",
112112
"ai-sdk-ollama": "^3.1.1",
113113
"ai-sdk-provider-claude-code": "^3.2.1",
114114
"ai-sdk-provider-gemini-cli": "^2.0.1",
@@ -158,7 +158,7 @@
158158
"monaco-editor-webpack-plugin": "^7.1.1",
159159
"monaco-languages": "^2.11.1",
160160
"monaco-themes": "^0.4.8",
161-
"motion": "^12.26.1",
161+
"motion": "^12.26.2",
162162
"nanoid": "^5.1.6",
163163
"next": "^16.1.1",
164164
"next-themes": "^0.4.6",
@@ -226,8 +226,8 @@
226226
"@types/react-dom": "^19.2.3",
227227
"@types/strip-comments": "^2.0.4",
228228
"@types/unist": "^3.0.3",
229-
"@typescript-eslint/eslint-plugin": "^8.52.0",
230-
"@typescript-eslint/parser": "^8.52.0",
229+
"@typescript-eslint/eslint-plugin": "^8.53.0",
230+
"@typescript-eslint/parser": "^8.53.0",
231231
"@vitest/coverage-v8": "^4.0.17",
232232
"cross-env": "^10.1.0",
233233
"eslint": "^9.39.2",
@@ -240,21 +240,21 @@
240240
"tailwindcss": "^4.1.18",
241241
"tw-animate-css": "^1.4.0",
242242
"typescript": "^5.9.3",
243-
"typescript-eslint": "^8.52.0",
243+
"typescript-eslint": "^8.53.0",
244244
"typescript-language-server": "^5.1.3",
245245
"vitest": "^4.0.17"
246246
},
247247
"overrides": {
248248
"jsondiffpatch": "0.7.3",
249-
"ai": "^5.0.119",
249+
"ai": "^5.0.121",
250250
"morgan": "^1.10.1",
251251
"js-yaml": "^4.1.1",
252252
"multer": "^2.0.2",
253253
"body-parser": "^2.2.2",
254254
"jws": "^4.0.1",
255255
"qs": "^6.14.1",
256256
"eslint": "^9.39.2",
257-
"typescript-eslint": "^8.52.0",
258-
"@typescript-eslint/parser": "^8.52.0"
257+
"@typescript-eslint/eslint-plugin": "^8.53.0",
258+
"@typescript-eslint/parser": "^8.53.0"
259259
}
260-
}
260+
}

src/mastra/agents/academicResearchAgent.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
} from '../tools'
1717

1818
import { extractLearningsTool } from '../tools/extractLearningsTool'
19+
import { InternalSpans } from '@mastra/core/observability'
1920

2021
type UserTier = 'free' | 'pro' | 'enterprise'
2122

@@ -136,6 +137,11 @@ ${
136137
extractLearningsTool,
137138
},
138139
memory: pgMemory,
140+
options: {
141+
tracingPolicy: {
142+
internal: InternalSpans.ALL
143+
}
144+
},
139145
maxRetries: 3,
140146
defaultOptions: {
141147
autoResumeSuspendedTools: true,

src/mastra/agents/acpAgent.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { googleAIFlashLite, pgMemory, pgQueryTool } from '../config';
33
import { arxivTool } from '../tools/arxiv.tool';
44
import { csvToJsonTool } from '../tools/csv-to-json.tool';
55
import { createDataDirTool, getDataFileInfoTool, listDataDirTool, moveDataFileTool, searchDataFilesTool, writeDataFileTool } from '../tools/data-file-manager';
6-
import { convertDataFormatTool, csvToExcalidrawTool, readCSVDataTool } from '../tools/data-processing-tools';
6+
import { csvToExcalidrawTool, readCSVDataTool } from '../tools/data-processing-tools';
77
import { mdocumentChunker } from '../tools/document-chunking.tool';
88
import { evaluateResultTool } from '../tools/evaluateResultTool';
99
import { execaTool } from '../tools/execa-tool';
@@ -81,7 +81,7 @@ User: ${userId} | Role: ${roleConstraint}
8181
csvToJsonTool,
8282
csvToExcalidrawTool,
8383
readCSVDataTool,
84-
convertDataFormatTool,
84+
// convertDataFormatTool,
8585
writeDataFileTool,
8686
listDataDirTool,
8787
searchDataFilesTool,
@@ -103,7 +103,9 @@ User: ${userId} | Role: ${roleConstraint}
103103

104104
},
105105
options: {
106-
tracingPolicy: InternalSpans.ALL as any,
106+
tracingPolicy: {
107+
internal: InternalSpans.ALL
108+
}
107109
},
108110
defaultOptions: {
109111
autoResumeSuspendedTools: true,

src/mastra/agents/bgColorAgent.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Agent } from "@mastra/core/agent";
22
import { Memory } from "@mastra/memory";
33
import { colorChangeTool } from "../tools/color-change-tool";
4-
4+
import { InternalSpans } from "@mastra/core/observability";
55
export const bgColorAgent = new Agent({
66
id: "bg-color-agent",
77
name: "Background Color Agent",
@@ -15,6 +15,11 @@ export const bgColorAgent = new Agent({
1515
model: "openai/gpt-4o-mini",
1616
tools: { colorChangeTool },
1717
memory: new Memory(),
18+
options: {
19+
tracingPolicy: {
20+
internal: InternalSpans.ALL
21+
}
22+
},
1823
defaultOptions: {
1924
autoResumeSuspendedTools: true,
2025
},

src/mastra/agents/businessLegalAgents.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
siteMapExtractorTool,
3030
webScraperTool,
3131
} from '../tools/web-scraper-tool';
32+
import { InternalSpans } from '@mastra/core/observability';
3233

3334

3435
type Research = 'simple' | 'deep' | 'extensive' | 'extreme' | 'ultra' | 'insane'
@@ -142,7 +143,11 @@ ${PGVECTOR_PROMPT}
142143
pdfToMarkdownTool
143144
},
144145
memory: pgMemory,
145-
146+
options: {
147+
tracingPolicy: {
148+
internal: InternalSpans.ALL
149+
}
150+
},
146151
scorers: {
147152
relevancy: {
148153
scorer: createAnswerRelevancyScorer({ model: googleAIFlashLite }),

src/mastra/agents/calendarAgent.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { googleAIFlashLite, pgMemory } from '../config';
44
import { google, type GoogleGenerativeAIProviderOptions } from '@ai-sdk/google';
55
import type { RequestContext } from '@mastra/core/request-context';
66
import { TokenLimiterProcessor } from '@mastra/core/processors';
7+
import { InternalSpans } from '@mastra/core/observability';
78

89
export interface CalendarContext {
910
userId?: string
@@ -55,6 +56,11 @@ Current user: ${userId ?? 'anonymous'}`,
5556
getUpcomingEvents,
5657
findFreeSlots,
5758
},
59+
options: {
60+
tracingPolicy: {
61+
internal: InternalSpans.ALL
62+
}
63+
},
5864
outputProcessors: [new TokenLimiterProcessor(128000)],
5965
defaultOptions: {
6066
autoResumeSuspendedTools: true,

src/mastra/agents/codingAgents.ts

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ import {
3939
import { multiStringEditTool } from '../tools/multi-string-edit.tool';
4040
import { testGeneratorTool } from '../tools/test-generator.tool';
4141
import { scrapingSchedulerTool } from '../tools/web-scraper-tool';
42-
42+
import { InternalSpans } from '@mastra/core/observability';
43+
import { pgMemory } from '../config/pg-storage';
4344
type UserTier = 'free' | 'pro' | 'enterprise'
4445
export interface CodingRuntimeContext {
4546
'user-tier': UserTier
@@ -127,14 +128,19 @@ Always consider maintainability, scalability, and testability in your recommenda
127128
scrapingSchedulerTool,
128129
// ...githubMCP.getTools(),
129130
},
130-
memory: upstashMemory,
131+
memory: pgMemory,
131132
scorers: {
132133
relevancy: {
133134
scorer: createAnswerRelevancyScorer({ model: googleAIFlashLite }),
134135
sampling: { type: 'ratio', rate: 0.5 }
135136
},
136137
},
137138
maxRetries: 3,
139+
options: {
140+
tracingPolicy: {
141+
internal: InternalSpans.ALL
142+
}
143+
},
138144
inputProcessors: [
139145
],
140146
outputProcessors: [new TokenLimiterProcessor(128000), new BatchPartsProcessor({ batchSize: 20, maxWaitTime: 100, emitOnNonText: true })]
@@ -234,8 +240,12 @@ Be constructive and educational in feedback.`,
234240
searchCode,
235241
getFileContent,
236242
},
237-
memory: upstashMemory,
238-
243+
memory: pgMemory,
244+
options: {
245+
tracingPolicy: {
246+
internal: InternalSpans.ALL
247+
}
248+
},
239249
scorers: {
240250
relevancy: {
241251
scorer: createAnswerRelevancyScorer({ model: googleAIFlashLite }),
@@ -363,8 +373,12 @@ Always use Vitest syntax: describe, it, expect, vi.mock, vi.fn.`,
363373
runCode,
364374
// ...githubMCP.getTools(),
365375
},
366-
memory: upstashMemory,
367-
376+
memory: pgMemory,
377+
options: {
378+
tracingPolicy: {
379+
internal: InternalSpans.ALL
380+
}
381+
},
368382
scorers: {
369383
relevancy: {
370384
scorer: createAnswerRelevancyScorer({ model: googleAIFlashLite }),
@@ -495,8 +509,12 @@ For each refactoring:
495509
runCommand,
496510
runCode,
497511
},
498-
memory: upstashMemory,
499-
512+
memory: pgMemory,
513+
options: {
514+
tracingPolicy: {
515+
internal: InternalSpans.ALL
516+
}
517+
},
500518
scorers: {
501519
relevancy: {
502520
scorer: createAnswerRelevancyScorer({ model: googleAIFlashLite }),

src/mastra/agents/contentStrategistAgent.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import type { GoogleGenerativeAIProviderOptions } from '@ai-sdk/google';
88
import type { RequestContext } from '@mastra/core/request-context'
99
import { TokenLimiterProcessor } from '@mastra/core/processors';
1010
import { createToneScorer, createTextualDifferenceScorer, createCompletenessScorer } from '../evals/scorers/prebuilt'
11-
11+
import { log } from '../config/logger';
12+
import { InternalSpans } from '@mastra/core/observability';
1213
type UserTier = 'free' | 'pro' | 'enterprise'
1314
export interface ContentAgentContext {
1415
userId?: string
@@ -71,6 +72,11 @@ User: ${userId} | Tier: ${userTier} | Style: ${strategy}
7172
chartSupervisorTool,
7273
scrapingSchedulerTool
7374
},
75+
options: {
76+
tracingPolicy: {
77+
internal: InternalSpans.ALL
78+
}
79+
},
7480
scorers: {
7581
toneConsistency: { scorer: createToneScorer() },
7682
textualDifference: { scorer: createTextualDifferenceScorer() },

src/mastra/agents/copywriterAgent.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import type { GoogleGenerativeAIProviderOptions } from '@ai-sdk/google'
1717
import type { RequestContext } from '@mastra/core/request-context'
1818
import { TokenLimiterProcessor } from '@mastra/core/processors'
1919
import { createToneScorer, createTextualDifferenceScorer, createCompletenessScorer } from '../evals/scorers/prebuilt'
20-
20+
import { InternalSpans } from '@mastra/core/observability'
2121
// Define runtime context for this agent
2222
export interface CopywriterAgentContext {
2323
userId?: string
@@ -81,6 +81,11 @@ Create compelling content (blog, marketing, social, technical, business, creativ
8181
textualDifference: { scorer: createTextualDifferenceScorer() },
8282
completeness: { scorer: createCompletenessScorer() },
8383
},
84+
options: {
85+
tracingPolicy: {
86+
internal: InternalSpans.ALL
87+
}
88+
},
8489
workflows: {},
8590
maxRetries: 5,
8691
outputProcessors: [new TokenLimiterProcessor(1048576)],

0 commit comments

Comments
 (0)