Skip to content

Develop#90

Merged
ssdeanx merged 2 commits intomainfrom
develop
Jan 13, 2026
Merged

Develop#90
ssdeanx merged 2 commits intomainfrom
develop

Conversation

@ssdeanx
Copy link
Owner

@ssdeanx ssdeanx commented Jan 13, 2026

No description provided.

- 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.
Copilot AI review requested due to automatic review settings January 13, 2026 19:44
@continue
Copy link

continue bot commented Jan 13, 2026

All Green - Keep your PRs mergeable

Learn more

All Green is an AI agent that automatically:

✅ Addresses code review comments

✅ Fixes failing CI checks

✅ Resolves merge conflicts


Unsubscribe from All Green comments

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, we are unable to review this pull request

The GitHub API does not allow us to fetch diffs exceeding 20000 lines

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@github-actions
Copy link

🤖 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.

@coderabbitai
Copy link

coderabbitai bot commented Jan 13, 2026

Caution

Review failed

Failed to post review comments

Summary by CodeRabbit

  • New Features

    • Added streaming APIs for workflows enabling real-time progress monitoring, event inspection, and resumption of interrupted runs
    • Introduced tool lifecycle hooks for enhanced input/output observability
    • Integrated database schema support for workflow persistence and event tracking
  • Documentation

    • Comprehensive streaming reference guides for workflows and tools
    • Tool creation and lifecycle best practices
    • Real-time event type reference with usage examples
    • UI integration patterns for streaming output display

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

Comprehensive 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

Cohort / File(s) Summary
Convex Backend Integration
convex/mastra/storage.ts, convex/schema.ts, package.json
New Convex module and schema configuration mapping mastra collections (threads, messages, resources, workflow snapshots, scorers, vector indexes, vectors, documents) to table definitions; added @mastra/convex dependency.
Streaming & Workflow Documentation
docs/tools-worklows/Streaming Overview.md, docs/tools-worklows/Streaming Events.md, docs/tools-worklows/Tool streaming.md, docs/tools-worklows/Workflow streaming.md, docs/tools-worklows/Reference Run.*()*.md, docs/tools-worklows/Reference ChunkType.md, docs/tools-worklows/Reference createTool().md
New comprehensive documentation for streaming capabilities, streaming event types, tool creation API, and workflow/run methods (stream, observeStream, resumeStream, timeTravelStream).
Agent Skills & System Documentation
.github/instructions/agent-skills.instructions.md, src/mastra/tools/AGENTS.md
New Agent Skills guidance document outlining portable, on-demand skill creation; updated AGENTS.md with corrected tracing imports and TracingContext type usage.
UI-Dojo Examples & Documentation
docs/ui-dojo/*.md, docs/ui-dojo/workflows_*.md
New UI demo components and workflows demonstrating streaming features, progress tracking, nested agents, custom events, sub-agents, branching workflows, and order fulfillment patterns.
Tool Implementation Enhancements
src/mastra/tools/arxiv.tool.ts, src/mastra/tools/browser-tool.ts, src/mastra/tools/calculator.tool.ts, src/mastra/tools/calendar-tool.ts, src/mastra/tools/chartjs.tool.ts, src/mastra/tools/code-analysis.tool.ts, src/mastra/tools/code-chunking.ts, src/mastra/tools/code-search.tool.ts, src/mastra/tools/color-change-tool.ts, src/mastra/tools/confirmation.tool.ts, src/mastra/tools/copywriter-agent-tool.ts, src/mastra/tools/csv-to-json.tool.ts, src/mastra/tools/cytoscape.tool.ts, src/mastra/tools/data-file-manager.ts
Standardized tool implementations across multiple files with: explicit tracing context typing (TracingContext | undefined), lifecycle hooks (onInputStart, onInputDelta, onInputAvailable, onOutput), requestContext propagation into tracing spans, structured progress events (writer.custom), enhanced error handling, and richer span metadata. Complex tools (arxiv, browser-tool, code-analysis, data-file-manager) received substantial implementation expansions with multi-language support and comprehensive validation.
Agent Configuration Updates
src/mastra/agents/acpAgent.ts, src/mastra/agents/researchAgent.ts
Added tracing policy configuration (InternalSpans.ALL) to acpAgent options; pruned external tool imports and reduced tool set in researchAgent.
Storage Configuration
src/mastra/config/pg-storage.ts
Added commented-out reranker configuration with google.chat model reference.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

  • feat: enhance tools with improved logging and context handling #77: Both PRs modify many src/mastra/tools/* modules with the same code-level changes—adding lifecycle hooks (onInputStart/onInputDelta/onInputAvailable/onOutput), propagating requestContext/tracing, and standardizing logging across tools.
  • feat: Enhance tools with improved context handling and logging #78: Both PRs modify the same tool modules (browser-tool.ts, arxiv.tool.ts, data-file-manager.ts, code-search tools) to add TracingContext-typed interfaces, propagate requestContext into spans, and reintroduce lifecycle hooks with richer logging.
  • Develop #52: Both PRs implement nested-agent streaming support across tool modules, standardize progress events to data-tool-progress, and update tool/agent wiring and documentation.

Poem

🐰 A hop through the streaming garden we go,
With tools now traced, and hooks that flow,
Convex foundations laid so deep,
As contexts propagate through every leap—
Documentation blooms, progress events play,
The agent skills dance brighter today! ✨

🚥 Pre-merge checks | ❌ 3
❌ Failed checks (1 warning, 2 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.04% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The pull request title 'Develop' is vague and generic, providing no meaningful information about the changeset contents or primary objective. Replace the title with a descriptive summary of the main change, such as 'Add Mastra Convex integration and streaming documentation' or 'Implement storage configuration and documentation updates'.
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to assess whether the description relates to the changeset. Add a pull request description that explains the purpose, scope, and key changes of this development work.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch develop

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 requestContext into spans and adding detailed lifecycle hook logs, enhancing debugging and monitoring capabilities. Additionally, the research agent has been refactored to remove outdated or less-used external data tools.

Highlights

  • Convex Integration: Introduced new Convex-based storage and schema definitions for Mastra, enabling persistent data management for threads, messages, resources, and workflows.
  • Agent Skills Documentation: Added comprehensive guidelines for creating GitHub Copilot Agent Skills, covering directory structure, SKILL.md format, resource bundling, and progressive loading architecture.
  • Enhanced Tool Observability: Updated numerous existing tools (e.g., Arxiv, Browser, Calculator, Calendar, Chart.js, Code Analysis, Code Chunking, Code Search, Color Change, CSV to JSON, Data File Manager) to include requestContext in tracing spans, improving observability and context propagation.
  • Tool Lifecycle Hooks Logging: Implemented detailed logging for tool lifecycle hooks (onInputStart, onInputDelta, onInputAvailable, onOutput) across various tools, providing better insight into tool execution flow.
  • Research Agent Refactoring: Streamlined the researchAgent.ts by removing several specialized financial data tools (Alpha Vantage, Finnhub, Polygon) and web scraping utilities, focusing its capabilities.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link

🤖 I'm sorry @ssdeanx, but I was unable to process your request. Please see the logs for more details.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 getOrCreateSpan helper function
  • Standardized span lifecycle management (creation, update, error handling, and closing)
  • Added proper type annotations for TracingContext throughout 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

Comment on lines +195 to 199
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')
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
Comment on lines +59 to +61
const result = {
message: inputData.message,
};
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +956 to +961
stocks: inputData.stocks.map(s => ({
symbol: s.symbol,
price: s.price,
metrics: s.metrics,
sentiment: s.sentiment,
})),
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
stocks: inputData.stocks.map(s => ({
symbol: s.symbol,
price: s.price,
metrics: s.metrics,
sentiment: s.sentiment,
})),
stocks: inputData.stocks,

Copilot uses AI. Check for mistakes.

let fixedData = excalidrawData
try {
const { csvData, delimiter = ',', hasHeaders = true, layoutType = 'table', title } = inputData
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@ssdeanx ssdeanx merged commit face0a3 into main Jan 13, 2026
27 of 32 checks passed
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

There appears to be a typo in the table name. The key mastra_scorers should probably be mastra_scores to align with the imported mastraScoresTable and maintain consistency with other table names.

Suggested change
mastra_scorers: mastraScoresTable,
mastra_scores: mastraScoresTable,

Comment on lines +14 to +16
```ts

``` No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This markdown file contains an empty code block. It seems like content is missing.


},
options: {
tracingPolicy: InternalSpans.ALL as any,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The use of as any for tracingPolicy is a code smell and bypasses type safety. It's better to find the correct type for this property or define it if it's missing, to ensure type correctness and prevent potential runtime errors.


- [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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There seems to be a typo in the link for the reference skills repository. It currently points to an Anthropic repository, which might be incorrect given the context of GitHub Copilot. It should likely point to a GitHub or Microsoft-owned repository for reference skills.


Signals the end of streaming tool call arguments.

An error occurred during tool execution.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This line 'An error occurred during tool execution.' appears to be a stray sentence. It seems like it should be the description for a tool-error chunk type, which is missing from the 'Tool Chunks' section. Please verify and either remove it or place it under the correct heading.


"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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This paragraph describing a chunk that contains metadata about the LLM provider's response is missing a heading. It seems to be describing a new chunk type that should be properly documented with a title.


### stream.usage:

Promise<{ inputTokens: number; outputTokens: number; totalTokens: number, reasoningTokens?: number, cacheInputTokens?: number }>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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()).

Suggested change
Promise<{ inputTokens: number; outputTokens: number; totalTokens: number, reasoningTokens?: number, cacheInputTokens?: number }>
Promise<{ inputTokens: number; outputTokens: number; totalTokens: number, reasoningTokens?: number, cachedInputTokens?: number }>

Comment on lines +132 to +134
- [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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The list of related links at the end of the file is incorrectly formatted as part of the 'Stream Events' section. It should be moved into its own '## Related' section for better document structure and readability.

## Usage example

```typescript
src/mastra/tools/reverse-tool.tsimport { createTool } from "@mastra/core/tools";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There's a minor grammatical error in this sentence. It should be 'This is useful...'.

Suggested change
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant