From fb785fa8c01a8954edfecf04b91b99aed2dc970f Mon Sep 17 00:00:00 2001 From: ssdeanx Date: Sat, 21 Mar 2026 07:57:39 -0400 Subject: [PATCH] feat: update Google AI model options and refactor imports across agents - Changed import from GoogleGenerativeAIProviderOptions to GoogleLanguageModelOptions in multiple files for consistency. - Updated model references to 'google/gemini-3.1-flash-preview' and 'google/gemini-3.1-flash-lite-preview' in various agents. - Removed unused imports and tools to streamline agent code. - Added new tools for Google search and URL context in content strategist, copywriter, and research paper agents. - Refactored agent configurations to improve clarity and maintainability. --- src/mastra/a2a/a2aCoordinatorAgent.ts | 14 ++--- src/mastra/a2a/codingA2ACoordinator.ts | 40 +++----------- src/mastra/agents/academicResearchAgent.ts | 4 +- src/mastra/agents/acpAgent.ts | 20 ++----- src/mastra/agents/codingAgents.ts | 58 ++++----------------- src/mastra/agents/contentStrategistAgent.ts | 8 +-- src/mastra/agents/copywriterAgent.ts | 22 +++----- src/mastra/agents/editorAgent.ts | 17 +++--- src/mastra/agents/reportAgent.ts | 6 +-- src/mastra/agents/researchPaperAgent.ts | 3 ++ src/mastra/agents/socialMediaAgent.ts | 6 +-- src/mastra/agents/stockAnalysisAgent.ts | 9 ++-- src/mastra/agents/supervisor-agent.ts | 24 +++++++-- src/mastra/agents/webResearchAgent.ts | 22 +++----- src/mastra/index.ts | 2 +- 15 files changed, 90 insertions(+), 165 deletions(-) diff --git a/src/mastra/a2a/a2aCoordinatorAgent.ts b/src/mastra/a2a/a2aCoordinatorAgent.ts index c578274..80291cf 100644 --- a/src/mastra/a2a/a2aCoordinatorAgent.ts +++ b/src/mastra/a2a/a2aCoordinatorAgent.ts @@ -1,4 +1,4 @@ -import type { GoogleGenerativeAIProviderOptions } from '@ai-sdk/google' +import type { GoogleLanguageModelOptions } from '@ai-sdk/google' import { Agent } from '@mastra/core/agent' import { createAnswerRelevancyScorer, @@ -16,7 +16,6 @@ import { editorAgent } from '../agents/editorAgent' import { knowledgeIndexingAgent } from '../agents/knowledgeIndexingAgent' import { projectManagementAgent } from '../agents/projectManagementAgent' import { researchAgent } from '../agents/researchAgent' -import { googleAI, googleAIFlashLite } from '../config/google' import { pgMemory } from '../config/pg-storage' import { repoIngestionWorkflow } from '../workflows/repo-ingestion-workflow' import { researchSynthesisWorkflow } from '../workflows/research-synthesis-workflow' @@ -96,15 +95,14 @@ Use knowledgeIndexingAgent to provide semantic context for complex queries. thinkingConfig: { thinkingLevel: 'high', includeThoughts: true, - thinkingBudget: -1, }, mediaResolution: 'MEDIA_RESOLUTION_MEDIUM', responseModalities: ['TEXT', 'IMAGE'], - } satisfies GoogleGenerativeAIProviderOptions, + } satisfies GoogleLanguageModelOptions, }, } }, - model: googleAI, + model: 'google/gemini-3.1-flash-preview', memory: pgMemory, options: {}, agents: { @@ -128,11 +126,13 @@ Use knowledgeIndexingAgent to provide semantic context for complex queries. tools: {}, scorers: { relevancy: { - scorer: createAnswerRelevancyScorer({ model: googleAIFlashLite }), + scorer: createAnswerRelevancyScorer({ model: + 'google/gemini-3.1-flash-lite-preview' + }), sampling: { type: 'ratio', rate: 0.4 }, }, safety: { - scorer: createToxicityScorer({ model: googleAIFlashLite }), + scorer: createToxicityScorer({ model: 'google/gemini-3.1-flash-lite-preview' }), sampling: { type: 'ratio', rate: 0.3 }, }, }, diff --git a/src/mastra/a2a/codingA2ACoordinator.ts b/src/mastra/a2a/codingA2ACoordinator.ts index fda0547..d4da220 100644 --- a/src/mastra/a2a/codingA2ACoordinator.ts +++ b/src/mastra/a2a/codingA2ACoordinator.ts @@ -4,11 +4,10 @@ import { createToxicityScorer, } from '@mastra/evals/scorers/prebuilt' -import { googleAIFlashLite } from '../config/google' import { log } from '../config/logger' import { pgMemory } from '../config/pg-storage' -import type { GoogleGenerativeAIProviderOptions } from '@ai-sdk/google' +import { google, type GoogleLanguageModelOptions } from '@ai-sdk/google' import { InternalSpans } from '@mastra/core/observability' import { codeArchitectAgent, @@ -16,20 +15,6 @@ import { refactoringAgent, testEngineerAgent, } from '../agents/codingAgents' -import { - checkFileExists, - createDirectory, - createSandbox, - deleteFile, - getFileInfo, - getFileSize, - listFiles, - runCode, - runCommand, - watchDirectory, - writeFile, - writeFiles, -} from '../tools/e2b' import { automatedReportingWorkflow } from '../workflows/automated-reporting-workflow' import { dataAnalysisWorkflow } from '../workflows/data-analysis-workflow' import { financialReportWorkflow } from '../workflows/financial-report-workflow' @@ -197,11 +182,11 @@ When a user's request requires prolonged, structured work across multiple subtas }, mediaResolution: 'MEDIA_RESOLUTION_MEDIUM', responseModalities: ['TEXT', 'IMAGE'], - } satisfies GoogleGenerativeAIProviderOptions, + } satisfies GoogleLanguageModelOptions, }, } }, - model: googleAIFlashLite, + model: 'google/gemini-3.1-flash-preview', memory: pgMemory, agents: { @@ -222,18 +207,9 @@ When a user's request requires prolonged, structured work across multiple subtas automatedReportingWorkflow, }, tools: { - createSandbox, - writeFile, - writeFiles, - listFiles, - deleteFile, - createDirectory, - getFileInfo, - checkFileExists, - getFileSize, - watchDirectory, - runCommand, - runCode, + google_search: google.tools.googleSearch({}), + url_context: google.tools.urlContext({}), + code_execution: google.tools.codeExecution({}), }, maxRetries: 5, options: { @@ -244,11 +220,11 @@ When a user's request requires prolonged, structured work across multiple subtas scorers: { relevancy: { - scorer: createAnswerRelevancyScorer({ model: googleAIFlashLite }), + scorer: createAnswerRelevancyScorer({ model: 'google/gemini-3.1-flash-lite-preview' }), sampling: { type: 'ratio', rate: 0.4 }, }, safety: { - scorer: createToxicityScorer({ model: googleAIFlashLite }), + scorer: createToxicityScorer({ model: 'google/gemini-3.1-flash-lite-preview' }), sampling: { type: 'ratio', rate: 0.3 }, }, }, diff --git a/src/mastra/agents/academicResearchAgent.ts b/src/mastra/agents/academicResearchAgent.ts index eb2b119..0e85912 100644 --- a/src/mastra/agents/academicResearchAgent.ts +++ b/src/mastra/agents/academicResearchAgent.ts @@ -1,4 +1,4 @@ -import type { GoogleGenerativeAIProviderOptions } from '@ai-sdk/google' +import type { GoogleLanguageModelOptions } from '@ai-sdk/google' import { Agent } from '@mastra/core/agent' import type { RequestContext } from '@mastra/core/request-context' import type { AgentRequestContext } from './request-context' @@ -106,7 +106,7 @@ ${ includeThoughts: true, thinkingLevel: 'high', }, - } satisfies GoogleGenerativeAIProviderOptions, + } satisfies GoogleLanguageModelOptions, }, } }, diff --git a/src/mastra/agents/acpAgent.ts b/src/mastra/agents/acpAgent.ts index 7b42066..9038b12 100644 --- a/src/mastra/agents/acpAgent.ts +++ b/src/mastra/agents/acpAgent.ts @@ -2,14 +2,6 @@ import { Agent } from '@mastra/core/agent' import { pgMemory, pgQueryTool } from '../config' import { arxivTool } from '../tools/arxiv.tool' import { csvToJsonTool } from '../tools/csv-to-json.tool' -import { - createDataDirTool, - getDataFileInfoTool, - listDataDirTool, - moveDataFileTool, - searchDataFilesTool, - writeDataFileTool, -} from '../tools/data-file-manager' import { csvToExcalidrawTool, readCSVDataTool, @@ -25,7 +17,7 @@ import { } from '../tools/github' import { jsonToCsvTool } from '../tools/json-to-csv.tool' import { pdfToMarkdownTool } from '../tools/pdf-data-conversion.tool' -import type { GoogleGenerativeAIProviderOptions } from '@ai-sdk/google' +import type { GoogleLanguageModelOptions } from '@ai-sdk/google' import type { RequestContext } from '@mastra/core/request-context' import { PGVECTOR_PROMPT } from '@mastra/pg' import { TokenLimiterProcessor } from '@mastra/core/processors' @@ -74,10 +66,10 @@ User: ${userId} | Role: ${roleConstraint} google: { thinkingConfig: { includeThoughts: true, - thinkingBudget: -1, + thinkingLevel: 'medium', }, responseModalities: ['TEXT'], - } satisfies GoogleGenerativeAIProviderOptions, + } satisfies GoogleLanguageModelOptions, }, } }, @@ -96,12 +88,6 @@ User: ${userId} | Role: ${roleConstraint} csvToExcalidrawTool, readCSVDataTool, // convertDataFormatTool, - writeDataFileTool, - listDataDirTool, - searchDataFilesTool, - moveDataFileTool, - getDataFileInfoTool, - createDataDirTool, searchCode, getFileContent, getRepositoryInfo, diff --git a/src/mastra/agents/codingAgents.ts b/src/mastra/agents/codingAgents.ts index f4f84fb..9cc39b0 100644 --- a/src/mastra/agents/codingAgents.ts +++ b/src/mastra/agents/codingAgents.ts @@ -1,6 +1,6 @@ import { Agent } from '@mastra/core/agent' -import type { GoogleGenerativeAIProviderOptions } from '@ai-sdk/google' +import type { GoogleGenerativeAIProviderOptions, GoogleLanguageModelOptions } from '@ai-sdk/google' import { TokenLimiterProcessor } from '@mastra/core/processors' @@ -8,11 +8,6 @@ import { createAnswerRelevancyScorer, createToxicityScorer, } from '@mastra/evals/scorers/prebuilt' -import { - google3, - googleAI3, - googleAIFlashLite, -} from '../config/google' import { log } from '../config/logger' import { InternalSpans } from '@mastra/core/observability' @@ -20,20 +15,6 @@ import { pgMemory } from '../config/pg-storage' import { codeAnalysisTool } from '../tools/code-analysis.tool' import { codeSearchTool } from '../tools/code-search.tool' import { diffReviewTool } from '../tools/diff-review.tool' -import { - checkFileExists, - createDirectory, - createSandbox, - deleteFile, - getFileInfo, - getFileSize, - listFiles, - runCode, - runCommand, - watchDirectory, - writeFile, - writeFiles, -} from '../tools/e2b' import { findReferencesTool } from '../tools/find-references.tool' import { findSymbolTool } from '../tools/find-symbol.tool' import { @@ -87,34 +68,13 @@ const codeReviewerTools = { const testEngineerTools = { codeAnalysisTool, testGeneratorTool, - createSandbox, - runCommand, - runCode, - writeFile, - writeFiles, - deleteFile, - listFiles, - getFileInfo, - getFileSize, - checkFileExists, + } const refactoringTools = { codeAnalysisTool, diffReviewTool, multiStringEditTool, - createSandbox, - runCode, - runCommand, - writeFile, - writeFiles, - deleteFile, - listFiles, - getFileInfo, - getFileSize, - checkFileExists, - createDirectory, - watchDirectory, searchCode, getFileContent, getRepositoryInfo, @@ -178,19 +138,19 @@ Always consider maintainability, scalability, and testability in your recommenda responseModalities: ['TEXT'], cachedContent: 'Repo Name, Description, Key Modules, Recent Commits', - } satisfies GoogleGenerativeAIProviderOptions, + } satisfies GoogleLanguageModelOptions, }, } }, model: ({ requestContext }) => { const userTier = getUserTierFromContext(requestContext) - return userTier === 'enterprise' ? googleAI3 : google3 + return userTier === 'enterprise' ? 'google/gemini-3.1-flash-preview' : 'google/gemini-3.1-flash-lite-preview' }, tools: codeArchitectTools, memory: pgMemory, scorers: { relevancy: { - scorer: createAnswerRelevancyScorer({ model: googleAIFlashLite }), + scorer: createAnswerRelevancyScorer({ model: 'google/gemini-3.1-flash-lite-preview' }), sampling: { type: 'ratio', rate: 0.5 }, }, }, @@ -304,11 +264,11 @@ Be constructive and educational in feedback.`, }, scorers: { relevancy: { - scorer: createAnswerRelevancyScorer({ model: googleAIFlashLite }), + scorer: createAnswerRelevancyScorer({ model: 'google/gemini-3.1-flash-lite-preview' }), sampling: { type: 'ratio', rate: 0.5 }, }, safety: { - scorer: createToxicityScorer({ model: googleAIFlashLite }), + scorer: createToxicityScorer({ model: 'google/gemini-3.1-flash-lite-preview' }), sampling: { type: 'ratio', rate: 0.3 }, }, }, @@ -427,7 +387,7 @@ Always use Vitest syntax: describe, it, expect, vi.mock, vi.fn.`, }, scorers: { relevancy: { - scorer: createAnswerRelevancyScorer({ model: googleAIFlashLite }), + scorer: createAnswerRelevancyScorer({ model: 'google/gemini-3.1-flash-lite-preview' }), sampling: { type: 'ratio', rate: 0.5 }, }, }, @@ -554,7 +514,7 @@ For each refactoring: }, scorers: { relevancy: { - scorer: createAnswerRelevancyScorer({ model: googleAIFlashLite }), + scorer: createAnswerRelevancyScorer({ model: 'google/gemini-3.1-flash-lite-preview' }), sampling: { type: 'ratio', rate: 0.5 }, }, }, diff --git a/src/mastra/agents/contentStrategistAgent.ts b/src/mastra/agents/contentStrategistAgent.ts index 190e7d1..59da794 100644 --- a/src/mastra/agents/contentStrategistAgent.ts +++ b/src/mastra/agents/contentStrategistAgent.ts @@ -2,10 +2,9 @@ import { Agent } from '@mastra/core/agent' import { pgMemory } from '../config/pg-storage' import { scrapingSchedulerTool, - webScraperTool, } from '../tools/web-scraper-tool' -import type { GoogleGenerativeAIProviderOptions } from '@ai-sdk/google' +import { google, type GoogleGenerativeAIProviderOptions } from '@ai-sdk/google' import { InternalSpans } from '@mastra/core/observability' import { TokenLimiterProcessor } from '@mastra/core/processors' import { @@ -19,6 +18,7 @@ import { createToneScorer, } from '../evals/scorers/prebuilt' import { chartSupervisorTool } from '../tools/financial-chart-tools' +import { fetchTool } from '../tools/fetch.tool' const STAGGERED_OUTPUT_CONTEXT_KEY = 'staggeredOutput' as const const SECTION_COUNT_CONTEXT_KEY = 'sectionCount' as const @@ -79,9 +79,11 @@ function getBackupDataToolsFromContext(requestContext: { } const contentStrategistTools = { - webScraperTool, + fetchTool, chartSupervisorTool, scrapingSchedulerTool, + google_search: google.tools.googleSearch({}), + url_context: google.tools.urlContext({}), } export const contentStrategistAgent = new Agent({ diff --git a/src/mastra/agents/copywriterAgent.ts b/src/mastra/agents/copywriterAgent.ts index f528334..9f90760 100644 --- a/src/mastra/agents/copywriterAgent.ts +++ b/src/mastra/agents/copywriterAgent.ts @@ -1,22 +1,13 @@ import { Agent } from '@mastra/core/agent' import { log } from '../config/logger' import { pgMemory } from '../config/pg-storage' -import { - contentCleanerTool, - // batchWebScraperTool, - // siteMapExtractorTool, - // linkExtractorTool, - htmlToMarkdownTool, - scrapingSchedulerTool, - webScraperTool, -} from '../tools/web-scraper-tool' import type { GoogleGenerativeAIProviderOptions } from '@ai-sdk/google' import { InternalSpans } from '@mastra/core/observability' import { TokenLimiterProcessor } from '@mastra/core/processors' import { USER_ID_CONTEXT_KEY, - USER_TIER_CONTEXT_KEY, +// USER_TIER_CONTEXT_KEY, type AgentRequestContext, } from './request-context' //import { @@ -25,6 +16,8 @@ import { // createToneScorer, //} from '../evals/scorers/prebuilt' import { chartSupervisorTool } from '../tools/financial-chart-tools' +import { fetchTool } from '../tools' +import { google } from '../config' // Define runtime context for this agent export type CopywriterAgentContext = AgentRequestContext<{ @@ -34,11 +27,10 @@ export type CopywriterAgentContext = AgentRequestContext<{ log.info('Initializing Copywriter Agent...') const copywriterTools = { - webScraperTool, - scrapingSchedulerTool, - htmlToMarkdownTool, - contentCleanerTool, + fetchTool, chartSupervisorTool, + google_search: google.tools.googleSearch({}), + url_context: google.tools.urlContext({}), } export const copywriterAgent = new Agent({ @@ -71,7 +63,7 @@ Create compelling content (blog, marketing, social, technical, business, creativ google: { thinkingConfig: { includeThoughts: true, - thinkingBudget: -1, + thinkingLevel: 'medium', }, responseModalities: ['TEXT'], mediaResolution: 'MEDIA_RESOLUTION_LOW', diff --git a/src/mastra/agents/editorAgent.ts b/src/mastra/agents/editorAgent.ts index a3da88e..af5d618 100644 --- a/src/mastra/agents/editorAgent.ts +++ b/src/mastra/agents/editorAgent.ts @@ -1,11 +1,12 @@ import type { GoogleGenerativeAIProviderMetadata, - GoogleGenerativeAIProviderOptions, +// GoogleGenerativeAIProviderOptions, + GoogleLanguageModelOptions, } from '@ai-sdk/google' import { google } from '@ai-sdk/google' import { Agent } from '@mastra/core/agent' import { - LANGUAGE_CONTEXT_KEY, + // LANGUAGE_CONTEXT_KEY, USER_TIER_CONTEXT_KEY, getLanguageFromContext, getUserTierFromContext, @@ -14,8 +15,6 @@ import { import { googleAI } from '../config/google' import { log } from '../config/logger' import { pgMemory } from '../config/pg-storage' - -import { TokenLimiterProcessor } from '@mastra/core/processors' import { InternalSpans } from '@mastra/core/observability' export type EditorRuntimeContext = AgentRequestContext @@ -58,10 +57,10 @@ Refine clarity, coherence, grammar, and style across Technical, Business, Creati google: { thinkingConfig: { includeThoughts: true, - thinkingBudget: -1, + thinkingLevel: 'medium', }, responseModalities: ['TEXT'], - } satisfies GoogleGenerativeAIProviderOptions, + } satisfies GoogleLanguageModelOptions, }, } }, @@ -90,7 +89,7 @@ Refine clarity, coherence, grammar, and style across Technical, Business, Creati }, workflows: {}, maxRetries: 5, - outputProcessors: [new TokenLimiterProcessor(1048576)], +// outputProcessors: [new TokenLimiterProcessor(1048576)], // defaultOptions: { // autoResumeSuspendedTools: true, // }, @@ -105,6 +104,6 @@ export type ProviderMetadataMap = { export const providerMetadata: ProviderMetadataMap | undefined = (googleAI as unknown as { providerMetadata?: ProviderMetadataMap }) - ?.providerMetadata ?? + .providerMetadata ?? (google as unknown as { providerMetadata?: ProviderMetadataMap }) - ?.providerMetadata + .providerMetadata diff --git a/src/mastra/agents/reportAgent.ts b/src/mastra/agents/reportAgent.ts index 429ac82..346ee39 100644 --- a/src/mastra/agents/reportAgent.ts +++ b/src/mastra/agents/reportAgent.ts @@ -2,7 +2,7 @@ import { Agent } from '@mastra/core/agent' import { log } from '../config/logger' import { pgMemory } from '../config/pg-storage' -import type { GoogleGenerativeAIProviderOptions } from '@ai-sdk/google' +import type { GoogleLanguageModelOptions } from '@ai-sdk/google' import { InternalSpans } from '@mastra/core/observability' import { TokenLimiterProcessor @@ -51,11 +51,11 @@ export const reportAgent = new Agent({ google: { thinkingConfig: { includeThoughts: true, - thinkingBudget: -1, + thinkingLevel: 'medium', }, mediaResolution: 'MEDIA_RESOLUTION_MEDIUM', responseModalities: ['TEXT'], - } satisfies GoogleGenerativeAIProviderOptions, + } satisfies GoogleLanguageModelOptions, }, } }, diff --git a/src/mastra/agents/researchPaperAgent.ts b/src/mastra/agents/researchPaperAgent.ts index 8c178a2..0738020 100644 --- a/src/mastra/agents/researchPaperAgent.ts +++ b/src/mastra/agents/researchPaperAgent.ts @@ -16,6 +16,7 @@ import { getUserTierFromContext, type AgentRequestContext, } from './request-context' +import { google } from '../config' export type ResearchPaperAgentRuntimeContext = AgentRequestContext @@ -23,6 +24,8 @@ const researchPaperTools = { arxivTool, arxivPdfParserTool, arxivPaperDownloaderTool, + google_search: google.tools.googleSearch({}), + url_context: google.tools.urlContext({}), } log.info('Initializing Research Paper Agent...') diff --git a/src/mastra/agents/socialMediaAgent.ts b/src/mastra/agents/socialMediaAgent.ts index 22ba0c7..53b2238 100644 --- a/src/mastra/agents/socialMediaAgent.ts +++ b/src/mastra/agents/socialMediaAgent.ts @@ -3,7 +3,7 @@ import { log } from '../config/logger' import { pgMemory } from '../config/pg-storage' import { InternalSpans } from '@mastra/core/observability' -import { calendarAgent } from './calendarAgent' +//import { calendarAgent } from './calendarAgent' import { contentStrategistAgent } from './contentStrategistAgent' import { copywriterAgent } from './copywriterAgent' import { researchAgent } from './researchAgent' @@ -97,8 +97,8 @@ export const socialMediaAgent = new Agent({ copywriterAgent, contentStrategistAgent, researchAgent, - calendarAgent, - } as Record, + // calendarAgent, + }, options: { tracingPolicy: { internal: InternalSpans.ALL, diff --git a/src/mastra/agents/stockAnalysisAgent.ts b/src/mastra/agents/stockAnalysisAgent.ts index 39a249a..aaf6f20 100644 --- a/src/mastra/agents/stockAnalysisAgent.ts +++ b/src/mastra/agents/stockAnalysisAgent.ts @@ -2,6 +2,7 @@ import { Agent } from '@mastra/core/agent' import { log } from '../config/logger' import { pgMemory } from '../config/pg-storage' +import type { GoogleLanguageModelOptions } from '@ai-sdk/google'; import { alphaVantageStockTool } from '../tools/alpha-vantage.tool' import { @@ -17,7 +18,7 @@ import { polygonStockQuotesTool, } from '../tools/polygon-tools' import { googleFinanceTool } from '../tools/serpapi-academic-local.tool' -import type { GoogleGenerativeAIProviderOptions } from '@ai-sdk/google' +//import type { GoogleGenerativeAIProviderOptions } from '@ai-sdk/google' import { TokenLimiterProcessor } from '@mastra/core/processors' import { InternalSpans } from '@mastra/core/observability' import { @@ -42,7 +43,6 @@ const stockAnalysisTools = { } log.info('Initializing Stock Analysis Agent...') - export const stockAnalysisAgent = new Agent({ id: 'stockAnalysisAgent', name: 'Stock Analysis Agent', @@ -96,9 +96,10 @@ export const stockAnalysisAgent = new Agent({ google: { thinkingConfig: { includeThoughts: true, - thinkingBudget: -1, + thinkingLevel: 'medium', }, - } satisfies GoogleGenerativeAIProviderOptions, + mediaResolution: 'MEDIA_RESOLUTION_MEDIUM', + } satisfies GoogleLanguageModelOptions, }, } }, diff --git a/src/mastra/agents/supervisor-agent.ts b/src/mastra/agents/supervisor-agent.ts index bafe842..5b919cb 100644 --- a/src/mastra/agents/supervisor-agent.ts +++ b/src/mastra/agents/supervisor-agent.ts @@ -8,6 +8,8 @@ import { log } from '../config/logger' import { AgentFSFilesystem } from '@mastra/agentfs' //import { AgentFS } from 'agentfs-sdk' import { Workspace, LocalSandbox } from '@mastra/core/workspace'; +import type { GoogleLanguageModelOptions } from '@ai-sdk/google' +import { google } from '../config' const workspace = new Workspace({ filesystem: new AgentFSFilesystem({ @@ -49,7 +51,10 @@ Success criteria: - Final output is well-formatted and complete - If anything is missing or uncertain, continue gathering information`, model: 'opencode/minimax-m2.5-free', - tools: {libsqlgraphQueryTool, libsqlQueryTool}, + tools: {libsqlgraphQueryTool, libsqlQueryTool, + google_search: google.tools.googleSearch({}), + url_context: google.tools.urlContext({}), + }, agents: { researchAgent, copywriterAgent, @@ -65,12 +70,21 @@ Success criteria: maxSteps: 25, providerOptions: { anthropic: { + sendReasoning: true, + thinking: { + type: 'adaptive', + }, }, google: { - temperature: 0.2, - }, + thinkingConfig: { + includeThoughts: true, + thinkingLevel: 'medium', + }, + mediaResolution: 'MEDIA_RESOLUTION_MEDIUM', + } satisfies GoogleLanguageModelOptions, openai: { - temperature: 0.2, + parallelToolCalls: true, + reasoningEffort: 'medium', }, xai: { temperature: 0.2, @@ -132,7 +146,7 @@ Success criteria: // Validate task completion isTaskComplete: { scorers: [taskCompleteScorer], - strategy: 'all', + strategy: 'any', // Mark as complete if any scorer indicates completion parallel: true, onComplete: async result => { log.info('Completion check', { diff --git a/src/mastra/agents/webResearchAgent.ts b/src/mastra/agents/webResearchAgent.ts index 978aa04..15cb35d 100644 --- a/src/mastra/agents/webResearchAgent.ts +++ b/src/mastra/agents/webResearchAgent.ts @@ -1,7 +1,6 @@ -import type { GoogleGenerativeAIProviderOptions } from '@ai-sdk/google' +import type { GoogleLanguageModelOptions } from '@ai-sdk/google' import { Agent } from '@mastra/core/agent' import { - BatchPartsProcessor, TokenLimiterProcessor, } from '@mastra/core/processors' import type { RequestContext } from '@mastra/core/request-context' @@ -11,18 +10,13 @@ import { log } from '../config/logger' import { pgMemory } from '../config/pg-storage' import { - webScraperTool, - siteMapExtractorTool, - linkExtractorTool, - htmlToMarkdownTool, - contentCleanerTool, - batchWebScraperTool, scrapingSchedulerTool, } from '../tools/web-scraper-tool' import { extractLearningsTool } from '../tools/extractLearningsTool' import { InternalSpans } from '@mastra/core/observability' import type { AgentRequestContext } from './request-context' +import { fetchTool } from '../tools' export type WebResearchRuntimeContext = AgentRequestContext<{ researchPhase?: string @@ -92,7 +86,7 @@ Provide structured results with: includeThoughts: true, thinkingLevel: 'medium', }, - } satisfies GoogleGenerativeAIProviderOptions, + } satisfies GoogleLanguageModelOptions, }, } }, @@ -106,14 +100,12 @@ Provide structured results with: return google.chat('gemini-3.1-flash-lite-previeww') }, tools: { - webScraperTool, - siteMapExtractorTool, - linkExtractorTool, - htmlToMarkdownTool, - contentCleanerTool, - batchWebScraperTool, + fetchTool, scrapingSchedulerTool, extractLearningsTool, + google_search: google.tools.googleSearch({}), + url_context: google.tools.urlContext({}), + code_execution: google.tools.codeExecution({}), }, memory: pgMemory, maxRetries: 5, diff --git a/src/mastra/index.ts b/src/mastra/index.ts index be237e2..4f11002 100644 --- a/src/mastra/index.ts +++ b/src/mastra/index.ts @@ -171,7 +171,7 @@ export const mastra = new Mastra({ agents: { // Core Agents weatherAgent, - // supervisorAgent, + supervisorAgent, csvToExcalidrawAgent, imageToCsvAgent, copywriterAgent,