Skip to content

Commit 160868e

Browse files
committed
Add research/analysis config to context
Introduce Research and AnalysisConfig types and add responseFormat plus nested research and analysis fields to the BusinessRuntimeContext. Read defaults in legalResearchAgent and expose depth/scope settings in the agent system prompt. Fix googleTools usage and register the business legal agents in mastra and the chat API route.
1 parent 712f97c commit 160868e

2 files changed

Lines changed: 26 additions & 10 deletions

File tree

src/mastra/agents/businessLegalAgents.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,24 @@ import {
3030
} from '../tools/web-scraper-tool';
3131

3232

33-
export interface BusinessLegalAgentContext extends RuntimeContext {
34-
userId: string,
35-
tier: string,
36-
researchDepth: number,
37-
analysisDepth: string,
38-
complianceScope: string,
39-
strategyScope: string
40-
}
33+
34+
export type Research = 'simple' | 'deep' | 'extensive' | 'extreme' | 'ultra' | 'insane'
35+
36+
export type AnalysisConfig = 'summary' | 'detailed' | 'extensive' | 'full'
4137

4238
export type UserTier = 'free' | 'pro' | 'enterprise'
4339
export type BusinessRuntimeContext = {
4440
'user-tier': UserTier
4541
language: 'en' | 'es' | 'ja' | 'fr'
42+
responseFormat: 'json' | 'markdown'
43+
research: {
44+
depth: Research,
45+
scope: AnalysisConfig
46+
}
47+
analysis: {
48+
depth: Research,
49+
scope: AnalysisConfig
50+
}
4651
}
4752

4853
log.info('Initializing Business Legal Team Agents...')
@@ -56,12 +61,17 @@ export const legalResearchAgent = new Agent({
5661
// runtimeContext is read at invocation time
5762
const userTier = runtimeContext.get('user-tier') ?? 'free'
5863
const language = runtimeContext.get('language') ?? 'en'
64+
const responseFormat = runtimeContext.get('responseFormat') ?? 'json'
65+
const research = runtimeContext.get('research') ?? { depth: 'extensive', scope: 'full' }
66+
const analysis = runtimeContext.get('analysis') ?? { depth: 'extensive', scope: 'full' }
5967
return {
6068
role: 'system',
6169
content: `You are a Senior Legal Research Analyst. Your goal is to research legal topics thoroughly using authoritative sources.
6270
Your working with:
6371
- User: ${userTier}
6472
- Language: ${language}
73+
- Research: Depth ${research.depth}, Scope ${research.scope}
74+
- Analysis: Depth ${analysis.depth}, Scope ${analysis.scope}
6575
6676
**Key Guidelines:**
6777
- Focus on primary sources: statutes, case law, regulations
@@ -321,7 +331,7 @@ You are a Compliance Officer. Monitor regulatory compliance and identify risks a
321331
htmlToMarkdownTool,
322332
contentCleanerTool,
323333
googleScholarTool,
324-
google_search: google.tools.googleSearch({
334+
google_search: googleTools.googleSearch({
325335
mode: "MODE_DYNAMIC",
326336
dynamicThreshold: 0.7,
327337
}),

src/mastra/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ import { agentNetwork, dataPipelineNetwork, reportGenerationNetwork, researchPip
6565
// Workflows
6666
import { trace } from "@opentelemetry/api";
6767
import { acpAgent } from './agents/acpAgent';
68+
import { businessStrategyAgent, complianceMonitoringAgent, contractAnalysisAgent, legalResearchAgent } from "./agents/businessLegalAgents";
6869
import { dane, daneChangeLog, daneCommitMessage, daneIssueLabeler, daneLinkChecker } from './agents/dane';
6970
import { changelogWorkflow } from './workflows/changelog';
7071
import { contentReviewWorkflow } from './workflows/content-review-workflow';
@@ -132,6 +133,11 @@ export const mastra = new Mastra({
132133
chartDataProcessorAgent,
133134
chartGeneratorAgent,
134135
chartSupervisorAgent,
136+
// Business Legal Agents
137+
legalResearchAgent,
138+
businessStrategyAgent,
139+
complianceMonitoringAgent,
140+
contractAnalysisAgent
135141
},
136142
scorers: { toolCallAppropriatenessScorer, completenessScorer, translationScorer, responseQualityScorer, taskCompletionScorer },
137143
mcpServers: { a2aCoordinator: a2aCoordinatorMcpServer, notes: notesMCP },
@@ -195,7 +201,7 @@ export const mastra = new Mastra({
195201
apiRoutes: [
196202
chatRoute({
197203
path: "/chat",
198-
agent: "weatherAgent, a2aCoordinatorAgent, csvToExcalidrawAgent, imageToCsvAgent, excalidrawValidatorAgent, reportAgent, learningExtractionAgent, evaluationAgent, researchAgent, copywriterAgent, editorAgent, agentNetwork, contentStrategistAgent, scriptWriterAgent, dataExportAgent, dataIngestionAgent, dataTransformationAgent, researchPaperAgent, documentProcessingAgent, knowledgeIndexingAgent, stockAnalysisAgent, daneNewContributor, chartTypeAdvisorAgent, chartDataProcessorAgent, chartGeneratorAgent, chartSupervisorAgent",
204+
agent: "weatherAgent, a2aCoordinatorAgent, csvToExcalidrawAgent, imageToCsvAgent, excalidrawValidatorAgent, reportAgent, learningExtractionAgent, evaluationAgent, researchAgent, copywriterAgent, editorAgent, agentNetwork, contentStrategistAgent, scriptWriterAgent, dataExportAgent, dataIngestionAgent, dataTransformationAgent, researchPaperAgent, documentProcessingAgent, knowledgeIndexingAgent, stockAnalysisAgent, daneNewContributor, chartTypeAdvisorAgent, chartDataProcessorAgent, chartGeneratorAgent, chartSupervisorAgent, legalResearchAgent, businessStrategyAgent, complianceMonitoringAgent, contractAnalysisAgent",
199205
defaultOptions: {
200206
maxSteps: 50,
201207
includeRawChunks: true,

0 commit comments

Comments
 (0)