Conversation
- Implemented AuthenticationService for JWT verification and access policy generation. - Introduced DocumentIndexingService for processing and indexing documents with enhanced chunking and embedding capabilities. - Added support for security tag extraction based on document classification and allowed roles. feat: Introduce A2A and ACP AI providers - Created a2a.ts to demonstrate integration with A2A AI provider for streaming text responses. - Developed acp.ts to set up the Gemini ACP provider with necessary configurations. feat: Define agent schemas using Zod - Established comprehensive schemas for various agents including JWT claims, access filters, document contexts, and output formats. - Included validation for subscription tiers, usage stats, and content generation workflows. docs: Add initial API documentation for Mastra v1 - Created v1.md to provide guidance on migration and usage of the new API features.
|
Keep this PR in a mergeable state → Learn moreAll Green is an AI agent that automatically: ✅ Addresses code review comments ✅ Fixes failing CI checks ✅ Resolves merge conflicts |
|
Skipped: This PR changes more files than the configured file change limit: ( |
|
🤖 Hi @ssdeanx, I've received your request, and I'm working on it now! You can track my progress in the logs for more details. |
|
Caution Review failedThe pull request is closed. Summary by CodeRabbitRelease Notes
✏️ Tip: You can customize this high-level summary in your review settings. WalkthroughComprehensive v1 migration refactoring RuntimeContext to RequestContext throughout agents, tools, and APIs, migrating custom AISpan tracing to OpenTelemetry, standardizing tool execute signatures to (inputData, context), upgrading core Mastra dependencies from 0.x to 1.x beta, adding scorer identifiers and prebuilt scorers, and introducing new authentication and document indexing services. Changes
Estimated code review effort🎯 5 (Critical) | ⏱️ ~120 minutes Areas requiring extra attention:
Possibly related PRs
Poem
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (107)
⛔ Files not processed due to max files limit (19)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR migrates the codebase to Mastra v1 by replacing the deprecated tracing API with OpenTelemetry's standard API and updating tool execution patterns to align with the new framework architecture.
Key changes:
- Replaced Mastra-specific tracing (
AISpanType,InternalSpans,TracingContext) with OpenTelemetry API (trace,SpanStatusCode) - Updated tool execution signatures from
{ context, tracingContext, runtimeContext, writer }to(inputData, context)pattern - Migrated from
generate()tostream()for agent responses with inline JSON parsing - Renamed
RuntimeContexttoRequestContextthroughout the codebase
Reviewed changes
Copilot reviewed 127 out of 136 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| workflows/*.ts | Updated tracing to use OpenTelemetry API; migrated agent calls to streaming pattern with fallback parsing |
| tools/*.ts | Converted tool execution signatures; replaced Mastra tracing with OpenTelemetry spans |
| tools/tests/*.ts | Updated test imports for new observability package path |
| networks/reportGenerationNetwork.ts | Removed unused InternalSpans import |
| }); | ||
|
|
||
| const {value} = context | ||
| // const {value} = input // unused |
There was a problem hiding this comment.
Remove the commented-out unused variable declaration on line 147. Dead code should be removed rather than commented out.
| // const {value} = input // unused |
| import { createTool } from '@mastra/core/tools' | ||
| import { z } from 'zod' | ||
| import { log } from '../config/logger' | ||
| import type { RequestContext } from '@mastra/core/request-context'; |
There was a problem hiding this comment.
Duplicate import of RequestContext from '@mastra/core/request-context' on lines 2 and 6. Remove the duplicate import on line 6.
| import type { RequestContext } from '@mastra/core/request-context'; |
| execute: async (inputData, context) => { | ||
| const writer = context?.writer; | ||
| const tracingContext = context?.tracingContext; | ||
|
|
||
| const span = tracingContext?.currentSpan?.createChildSpan({ | ||
| type: AISpanType.TOOL_CALL, | ||
| name: 'read-pdf', | ||
| input: { pdfPath: context.pdfPath }, | ||
| tracingPolicy: { internal: InternalSpans.TOOL } | ||
| input: { pdfPath: inputData.pdfPath }, |
There was a problem hiding this comment.
The tracing code on lines 40-44 still uses the deprecated Mastra-specific API (tracingContext?.currentSpan?.createChildSpan, AISpanType.TOOL_CALL) instead of the OpenTelemetry API. This is inconsistent with the migration goal. Replace with trace.getTracer() and tracer.startSpan() pattern as used in other files.
|
🤖 I'm sorry @ssdeanx, but I was unable to process your request. Please see the logs for more details. |
There was a problem hiding this comment.
Remark-lint (reported by Codacy) found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
Summary of ChangesHello @ssdeanx, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request represents a major upgrade to Mastra v1, focusing on modernizing the core architecture and enhancing key functionalities. It introduces new services for authentication and document indexing, integrates advanced AI providers, and standardizes data structures through Zod schemas. A significant portion of the changes involves a complete overhaul of the observability and tracing system to align with OpenTelemetry, ensuring better monitoring and debugging capabilities. These updates aim to provide a more robust, scalable, and developer-friendly platform for building AI applications. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request primarily focuses on a major version upgrade of the Mastra framework to v1, entailing significant changes to observability, tracing, and context handling. Key updates include renaming RuntimeContext to RequestContext across numerous agent and API files, and a complete overhaul of the tracing system to align with OpenTelemetry standards, removing the old InternalSpans and tracingPolicy options from agents and tools. Many tools now explicitly use trace.getTracer().startSpan() and span.setAttributes() for detailed tracing, addressing a review comment about incomplete tracing migration. The package.json reflects these changes with numerous @mastra/* dependencies updated to 1.0.0-beta versions, and new packages like @mastra/observability and a2a-ai-provider introduced. Documentation files (h.md, v1-migration-guide.md, v1.md) have been added or updated to reflect these architectural shifts, including a comprehensive migration guide for tools and tracing. Minor changes include adding ANALYZE='false' to .env.example, simplifying styledJsx config, and integrating @next/bundle-analyzer in next.config.ts. Several review comments highlight the incomplete migration of tracing in tools, leading to runtime errors, and the need to use span.setAttributes() for capturing output data before span.end(). Other comments point out unused parameters and suggest more descriptive filenames for new documentation.
| const span = tracingContext?.currentSpan?.createChildSpan({ | ||
| type: AISpanType.TOOL_CALL, | ||
| name: 'fs-tool', | ||
| input: { action: context.action, file: context.file }, | ||
| tracingPolicy: { internal: InternalSpans.ALL } | ||
| input: { action: inputData.action, file: inputData.file }, | ||
| }); |
There was a problem hiding this comment.
The tracing implementation in this tool is incomplete and will cause a runtime error. tracingContext is from the old system and is no longer available on the context object. Additionally, AISpanType is no longer imported. This tool needs to be fully migrated to the new OpenTelemetry-based tracing, similar to other tools in this PR.
| const span = tracingContext?.currentSpan?.createChildSpan({ | |
| type: AISpanType.TOOL_CALL, | |
| name: 'fs-tool', | |
| input: { action: context.action, file: context.file }, | |
| tracingPolicy: { internal: InternalSpans.ALL } | |
| input: { action: inputData.action, file: inputData.file }, | |
| }); | |
| const tracer = trace.getTracer('fs-tool', '1.0.0'); | |
| const span = tracer.startSpan('fs-tool', { | |
| attributes: { | |
| 'tool.id': 'fsTool', | |
| 'tool.input.action': inputData.action, | |
| 'tool.input.file': inputData.file, | |
| } | |
| }); |
| format: "aisdk", | ||
| }); | ||
| const runtimeContext = new RuntimeContext(); | ||
| const requestContext = new RequestContext(); |
| @@ -0,0 +1,420 @@ | |||
| Adding Custom Metadata | |||
There was a problem hiding this comment.
| } | ||
|
|
||
| export async function runAllExperiments() { | ||
| export async function runAllExperiments(p0: unknown) { |
| }, | ||
| }, | ||
| processors: [new TokenLimiter(1048576)], | ||
| processors: [], |
There was a problem hiding this comment.
I noticed the TokenLimiter processor has been removed from the pgMemory configuration. Was this intentional? If so, is token limiting now handled elsewhere, or is it no longer required for this memory setup? Understanding the reasoning will help ensure a safeguard hasn't been unintentionally removed.
| // But I can't replicate `end({output})` directly. | ||
| // I will set attributes and then end. | ||
|
|
||
| apiSpan?.end(); |
There was a problem hiding this comment.
The migration to the new OpenTelemetry API seems to have resulted in a loss of tracing information. The previous implementation recorded output details like status and data size in the span. The new OpenTelemetry span.end() method doesn't accept arguments. To preserve this valuable information, you should use span.setAttributes() before calling span.end(). This pattern appears in multiple places in this file and other tool files (polygon-tools.ts, serpapi-*.ts, etc.) and should be applied consistently.
apiSpan.setAttributes({
'http.status_code': response.status,
'http.status_text': response.statusText,
'response.data.size': JSON.stringify(data).length,
'duration_ms': apiDuration
});
apiSpan.end();
feat: Introduce A2A and ACP AI providers
feat: Define agent schemas using Zod
docs: Add initial API documentation for Mastra v1