Conversation
- Introduced `Workflow Agent Text Streaming Demo` to showcase text streaming capabilities with weather analysis. - Added `Agent Network Custom Events Demo` to demonstrate handling custom events in a network of agents for report generation. - Created `Tool Nested Streams Demo` to illustrate nested agent streams for weather forecasting. - Implemented `Sub Agents and Workflows Custom Events Demo` to manage order processing with structured progress events. - Developed `Branching Workflow` to handle different order types (standard and express) with appropriate processing steps. - Added `Order Fulfillment Workflow` to process payments and prepare orders for shipping, emitting progress events throughout. - Documented the `nestedWeatherAgentStreamTool` for using nested agents to analyze weather for a specified city. - Updated various markdown files to include detailed descriptions and code snippets for each demo and workflow.
- Added observability spans to the `governed-rag-index.workflow.ts` for the `indexDocumentsStep`, capturing input data and execution time. - Integrated observability spans in `learning-extraction-workflow.ts`, including metrics for extraction and human approval steps, improving error handling and performance tracking. - Implemented spans in `marketingCampaignWorkflow.ts` for both planning and content creation steps, allowing for better monitoring of campaign processes. - Enhanced `repo-ingestion-workflow.ts` with spans for scanning and ingesting files, providing detailed insights into file processing. - Updated `research-synthesis-workflow.ts` to include spans for initializing research, researching topics, synthesizing research, and generating reports, improving error reporting and performance metrics. - Added observability spans in `safe-refactoring-workflow.ts` for generating and verifying refactors, enhancing error tracking and response time metrics. - Integrated spans in `spec-generation-workflow.ts` for planning, generating PRDs, architectures, and tasks, allowing for better monitoring of the specification generation process. - Enhanced `stock-analysis-workflow.ts` with spans for fetching stock data, getting company news, running analysis, and generating reports, improving observability and error handling.
Learn moreAll Green is an AI agent that automatically: ✅ Addresses code review comments ✅ Fixes failing CI checks ✅ Resolves merge conflicts |
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
|
🤖 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 failedFailed to post review comments Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings. WalkthroughComprehensive PR introducing Convex backend integration, extensive streaming and tool documentation, and standardizing tool implementations across the codebase with enhanced tracing capabilities, lifecycle hooks, and requestContext propagation for improved observability. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ❌ 3❌ Failed checks (1 warning, 2 inconclusive)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
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 integrates Convex for robust data persistence within the Mastra ecosystem and significantly expands the documentation for Agent Skills, providing clear guidelines for developers. It also refines the tracing and logging mechanisms across a wide array of tools by incorporating 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
|
|
🤖 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.
Pull request overview
This pull request implements comprehensive observability improvements across the Mastra workflows and tools codebase by standardizing span creation and error handling patterns.
Changes:
- Migrated from direct OpenTelemetry API usage to Mastra's
getOrCreateSpanhelper function - Standardized span lifecycle management (creation, update, error handling, and closing)
- Added proper type annotations for
TracingContextthroughout the codebase - Updated AGENTS.md documentation to reflect observability improvements
Reviewed changes
Copilot reviewed 71 out of 73 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/mastra/workflows/*.ts (17 files) | Replaced legacy span creation with getOrCreateSpan, added error tracking, and standardized span metadata |
| src/mastra/tools/*.ts (10 files) | Added TracingContext type imports and updated span creation patterns |
| src/mastra/workflows/AGENTS.md | Updated version to 2.1.0 and documented observability additions |
| const mastraInst = mastra ?? (globalThis as unknown as Record<string, unknown>).mastra | ||
| const agent = mastraInst?.getAgent?.('weatherAgent') | ||
| if (agent === undefined || agent === null) { | ||
| span?.error({ error: new Error('Weather agent not found'), endSpan: true }) | ||
| throw new Error('Weather agent not found') |
There was a problem hiding this comment.
The fallback to globalThis.mastra creates an implicit dependency on global state that may not exist. This could fail silently if neither mastra parameter nor global state contains the agent, leading to difficult-to-debug runtime errors. Consider adding explicit validation or throwing a descriptive error if mastra is unavailable.
| const mastraInst = mastra ?? (globalThis as unknown as Record<string, unknown>).mastra | |
| const agent = mastraInst?.getAgent?.('weatherAgent') | |
| if (agent === undefined || agent === null) { | |
| span?.error({ error: new Error('Weather agent not found'), endSpan: true }) | |
| throw new Error('Weather agent not found') | |
| const mastraInst = | |
| mastra ?? | |
| ((globalThis as unknown as { mastra?: { getAgent?: (id: string) => unknown } }).mastra ?? | |
| null) | |
| if (!mastraInst || typeof mastraInst.getAgent !== 'function') { | |
| const error = new Error('Mastra instance with getAgent is not available') | |
| span?.error({ error, endSpan: true }) | |
| throw error | |
| } | |
| const agent = mastraInst.getAgent('weatherAgent') | |
| if (agent === undefined || agent === null) { | |
| const error = new Error('Weather agent "weatherAgent" not found') | |
| span?.error({ error, endSpan: true }) | |
| throw error |
| const result = { | ||
| message: inputData.message, | ||
| }; |
There was a problem hiding this comment.
This step simply passes through the input message without any transformation. Consider documenting why this pass-through step exists or whether it serves a specific purpose in the telephone game workflow pattern.
| stocks: inputData.stocks.map(s => ({ | ||
| symbol: s.symbol, | ||
| price: s.price, | ||
| metrics: s.metrics, | ||
| sentiment: s.sentiment, | ||
| })), |
There was a problem hiding this comment.
The manual mapping creates a copy of stock data but doesn't provide clear benefit over using the original array. If the intent is to ensure immutability or filter properties, this should be documented. Otherwise, consider using the original array directly.
| stocks: inputData.stocks.map(s => ({ | |
| symbol: s.symbol, | |
| price: s.price, | |
| metrics: s.metrics, | |
| sentiment: s.sentiment, | |
| })), | |
| stocks: inputData.stocks, |
|
|
||
| let fixedData = excalidrawData | ||
| try { | ||
| const { csvData, delimiter = ',', hasHeaders = true, layoutType = 'table', title } = inputData |
There was a problem hiding this comment.
The csvToExcalidrawTool has been significantly simplified to only support table layout, but the layoutType parameter still accepts values like 'flowchart', 'mindmap', and 'timeline' that are no longer implemented. Either remove these unused layout options from the schema or implement them.
There was a problem hiding this comment.
Code Review
This pull request introduces comprehensive documentation for Agent Skills in GitHub Copilot, detailing their structure, format, resource bundling, and progressive loading. It also adds new Convex storage and schema definitions for Mastra, and extensively documents Mastra's streaming capabilities for agents, workflows, and tools, including various Run methods (observeStream, resumeStream, stream), ChunkType definitions, and event types. Several UI examples are added to demonstrate custom events and nested streams in React components. Code changes also include updates to src/mastra/agents/acpAgent.ts to enable InternalSpans.ALL tracing, and refactors in src/mastra/agents/researchAgent.ts to remove unused tool imports. Minor fixes are applied across various tool definitions (arxiv.tool.ts, browser-tool.ts, calculator.tool.ts, calendar-tool.ts, chartjs.tool.ts, code-analysis.tool.ts, code-chunking.ts, code-search.tool.ts, color-change-tool.ts, confirmation.tool.ts, copywriter-agent-tool.ts, csv-to-json.tool.ts, cytoscape.tool.ts, data-file-manager.ts) to ensure requestContext is passed to child spans for automatic metadata extraction, and to improve logging and error handling. Review comments highlight a typo in a Convex table name (mastra_scorers should be mastra_scores), missing content in a markdown file, an as any type assertion that should be addressed, an incorrect link to a reference skills repository, a stray sentence that should be a tool-error chunk description, a missing heading for an LLM metadata chunk, a typo in cachedInputTokens, a formatting issue with related links, and a grammatical error in a sentence.
| mastra_messages: mastraMessagesTable, | ||
| mastra_resources: mastraResourcesTable, | ||
| mastra_workflow_snapshots: mastraWorkflowSnapshotsTable, | ||
| mastra_scorers: mastraScoresTable, |
There was a problem hiding this comment.
| ```ts | ||
|
|
||
| ``` No newline at end of file |
|
|
||
| }, | ||
| options: { | ||
| tracingPolicy: InternalSpans.ALL as any, |
|
|
||
| - [Agent Skills Specification](https://agentskills.io/) | ||
| - [VS Code Agent Skills Documentation](https://code.visualstudio.com/docs/copilot/customization/agent-skills) | ||
| - [Reference Skills Repository](https://github.com/anthropics/skills) |
There was a problem hiding this comment.
|
|
||
| Signals the end of streaming tool call arguments. | ||
|
|
||
| An error occurred during tool execution. |
There was a problem hiding this comment.
|
|
||
| "step-output" | ||
|
|
||
| Contains metadata about the LLM provider's response. Emitted by some providers after text generation to provide additional context like model ID, timestamps, and response headers. This chunk is used internally for state tracking and doesn't affect message assembly. |
|
|
||
| ### stream.usage: | ||
|
|
||
| Promise<{ inputTokens: number; outputTokens: number; totalTokens: number, reasoningTokens?: number, cacheInputTokens?: number }> |
There was a problem hiding this comment.
There's a typo in the stream.usage return type. cacheInputTokens? should likely be cachedInputTokens? to maintain consistency with other parts of the documentation (e.g., Run.stream()).
| Promise<{ inputTokens: number; outputTokens: number; totalTokens: number, reasoningTokens?: number, cacheInputTokens?: number }> | |
| Promise<{ inputTokens: number; outputTokens: number; totalTokens: number, reasoningTokens?: number, cachedInputTokens?: number }> |
| - [Workflows overview](https://mastra.ai/docs/v1/workflows/overview#running-workflows) | ||
| - [Workflow.createRun()](https://mastra.ai/reference/v1/workflows/workflow-methods/create-run) | ||
| - [Run.resumeStream()](https://mastra.ai/reference/v1/streaming/workflows/resumeStream) No newline at end of file |
| ## Usage example | ||
|
|
||
| ```typescript | ||
| src/mastra/tools/reverse-tool.tsimport { createTool } from "@mastra/core/tools"; |
There was a problem hiding this comment.
There's a missing newline in the code block, causing the file path comment and the import statement to be on the same line. This affects readability and might cause issues with code highlighters.
| src/mastra/tools/reverse-tool.tsimport { createTool } from "@mastra/core/tools"; | |
| src/mastra/tools/reverse-tool.ts | |
| import { createTool } from "@mastra/core/tools"; |
| }); | ||
| ``` | ||
|
|
||
| You can also use `writer.custom()` if you want to emit top level stream chunks, This useful and relevant when integrating with UI Frameworks |
There was a problem hiding this comment.
There's a minor grammatical error in this sentence. It should be 'This is useful...'.
| You can also use `writer.custom()` if you want to emit top level stream chunks, This useful and relevant when integrating with UI Frameworks | |
| You can also use `writer.custom()` if you want to emit top level stream chunks. This is useful and relevant when integrating with UI Frameworks |

No description provided.