Conversation
- Updated OTEL configuration in instrumentation.ts to prevent double instrumentation. - Refactored Dane agent to use new webScraperTool and updated model to 'google/gemini-3-flash-preview'. - Commented out unused tools in editorAgent.ts and noteTakerAgent.ts for clarity. - Removed outdated agent-experiments.ts file and added new experiments with logging for various agents. - Improved error handling in repo-ingestion-workflow.ts for better clarity on scan results. - Updated target audience checks in content-review-workflow.ts for more robust validation. - Adjusted output processor limits in weather-agent.ts for performance optimization. - Cleaned up whitespace in changelog.ts and other workflow files for consistency.
Learn moreAll Green is an AI agent that automatically: ✅ Addresses code review comments ✅ Fixes failing CI checks ✅ Resolves merge conflicts |
Reviewer's GuideRefines observability and multiple agents/workflows: makes Vercel OTEL registration opt-in to avoid double instrumentation, modernizes the Dane agent configuration and tools, tightens validation and error handling in workflows, scales back unused tools, and adds structured logging to agent evaluation experiments while reducing scorer usage. Sequence diagram for agent experiment logging and scorer usage changessequenceDiagram
actor Dev
participant ExperimentRunner as runContentStrategistExperiment
participant Logger as log
participant Eval as runEvals
participant Agent as contentStrategistAgent
Dev->>ExperimentRunner: invoke()
ExperimentRunner->>Logger: info("Running Content Strategist Experiment")
ExperimentRunner->>Eval: runEvals({target: Agent, data: prompts, scorers: []})
Eval-->>ExperimentRunner: results
ExperimentRunner->>Logger: info("Content Strategist Experiment Results", {results})
ExperimentRunner-->>Dev: results
Updated class diagram for Dane agent configuration and toolsclassDiagram
class DaneContext {
string userId
string sessionId
string organizationId
}
class Agent {
<<library>>
}
class Dane {
<<Agent instance>>
+string id
+string name
+string model
+object tools
+object memory
+TokenLimiterProcessor[] outputProcessors
+object providerConfig
}
class TokenLimiterProcessor {
+TokenLimiterProcessor(maxTokens number)
+number maxTokens
}
class execaTool {
<<tool>>
}
class browserTool {
<<tool>>
}
class webScraperTool {
<<tool>>
}
class listEvents {
<<tool>>
}
class GoogleGenerativeAIProviderOptions {
+boolean includeThoughts
+string thinkingLevel
+string[] responseModalities
}
Agent <|.. Dane
Dane --> DaneContext
Dane --> TokenLimiterProcessor
Dane --> execaTool
Dane --> browserTool
Dane --> webScraperTool
Dane --> listEvents
Dane --> GoogleGenerativeAIProviderOptions
class GoogleModelConfig {
+string modelId
+GoogleGenerativeAIProviderOptions options
}
Dane --> GoogleModelConfig
%% Updated properties
Dane : model = "google/gemini-3-flash-preview"
GoogleGenerativeAIProviderOptions : includeThoughts = true
GoogleGenerativeAIProviderOptions : thinkingLevel = "high"
GoogleGenerativeAIProviderOptions : responseModalities = ["TEXT"]
Flow diagram for updated repo ingestion scan and ingest error handlinggraph TD
A["scanStep start"] --> B["Call githubRepoScanner.scan"]
B --> C["Receive scanResultRaw"]
C --> D{"isScanSuccess(scanResultRaw)?<br/>r is object and has success"}
D -->|"no"| E["Set errorMessage = 'unknown error'"]
E --> F["Throw Error 'Failed to scan GitHub repo: unknown error'"]
D -->|"yes"| G{"scanResultRaw.success and scanResultRaw.tree exists?"}
G -->|"no"| H["Set errorMessage = scanResultRaw.error or 'unknown error'"]
H --> I["Throw Error 'Failed to scan GitHub repo: ' + errorMessage"]
G -->|"yes"| J["Proceed with scanResultRaw.tree"]
J --> K["ingestStep start"]
K --> L["Fetch file content from GitHub"]
L --> M["Cast to successResult"]
M --> N{"successResult.success and<br/>content is not null/undefined/empty?"}
N -->|"no"| O["Throw Error 'Failed to fetch file from GitHub: ' + successResult.error"]
N -->|"yes"| P["Use successResult.content for ingestion"]
P --> Q["Complete ingestion"]
Flow diagram for content review workflow target audience handlinggraph TD
A["researchTopicStep start"] --> B["Read inputData.targetAudience"]
B --> C{targetAudience is not undefined
and not null
and trimmed length > 0?}
C -->|"yes"| D["Include 'targeting {targetAudience}' in research prompt"]
C -->|"no"| E["Omit targeting clause from research prompt"]
D --> F["Call agent.stream with prompt"]
E --> F
F --> G["draftContentStep"]
G --> H["Check targetAudience with same non-empty validation"]
H -->|"yes"| I["Include 'Target Audience: {targetAudience}' in drafting prompt"]
H -->|"no"| J["Omit target audience from drafting prompt"]
I --> K["Generate content"]
J --> K
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings. WalkthroughThe PR modifies instrumentation setup with a feature flag, updates multiple agents and workflows with tool removals or replacements, consolidates logging approaches, and strengthens type safety in result handling across evals and workflows. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ 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 |
|
🤖 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. |
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 introduces a series of enhancements aimed at improving the robustness, performance, and maintainability of various agent-based workflows. It refines OpenTelemetry instrumentation to prevent conflicts, updates a core agent with a more advanced model and tool, and strengthens error handling in critical data ingestion processes. Additionally, it streamlines experiment configurations and includes general code cleanups to ensure a more consistent and reliable codebase. 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.
Hey there - I've reviewed your changes - here's some feedback:
- In
repo-ingestion-workflow.ts, the updated check now treats an empty stringcontentas a failure; if zero‑byte or intentionally empty files are valid, consider distinguishingnull/undefinedfrom''instead of rejecting all empty content. - Several agents/workflows now have
toolsortoolsets.slackcommented out (e.g.,editorAgent,noteTakerAgent,changelogstepA2,telephone-game); it may be clearer and less error‑prone to keep these as explicit empty arrays/objects with a brief comment rather than commented configuration. - In
noteTakerAgent, theinstructionsconstant was renamed toinstructions1without an apparent need; consider reverting to a clearer name likeinstructionsornoteTakerInstructionsto avoid confusion about multiple instruction variants.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `repo-ingestion-workflow.ts`, the updated check now treats an empty string `content` as a failure; if zero‑byte or intentionally empty files are valid, consider distinguishing `null/undefined` from `''` instead of rejecting all empty content.
- Several agents/workflows now have `tools` or `toolsets.slack` commented out (e.g., `editorAgent`, `noteTakerAgent`, `changelog` stepA2, `telephone-game`); it may be clearer and less error‑prone to keep these as explicit empty arrays/objects with a brief comment rather than commented configuration.
- In `noteTakerAgent`, the `instructions` constant was renamed to `instructions1` without an apparent need; consider reverting to a clearer name like `instructions` or `noteTakerInstructions` to avoid confusion about multiple instruction variants.
## Individual Comments
### Comment 1
<location> `src/mastra/agents/dane.ts:202` </location>
<code_context>
}
},
- model: googleAIFlashLite,
+ model: 'google/gemini-3-flash-preview',
memory: pgMemory,
tools: {
</code_context>
<issue_to_address>
**suggestion:** Model string and the `google.chat(...)` configuration point at different model versions.
The agent now uses `'google/gemini-3-flash-preview'`, but `defaultOpts` still calls `google.chat('gemini-2.5-flash-preview-09-2025')`. This mismatch can cause confusion or inconsistent behavior (e.g., metrics referring to a different model). Consider keeping these values in sync or deriving both from a shared constant.
Suggested implementation:
```typescript
includeThoughts: true,
thinkingLevel: 'high',
},
responseModalities: ['TEXT'],
} satisfies GoogleGenerativeAIProviderOptions,
}
}
},
model: `google/${GOOGLE_FLASH_MODEL_ID}`,
memory: pgMemory,
tools: {
```
```typescript
provider: google.chat(GOOGLE_FLASH_MODEL_ID),
```
```typescript
const GOOGLE_FLASH_MODEL_ID = 'gemini-3-flash-preview';
export const dane =
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| } | ||
| }, | ||
| model: googleAIFlashLite, | ||
| model: 'google/gemini-3-flash-preview', |
There was a problem hiding this comment.
suggestion: Model string and the google.chat(...) configuration point at different model versions.
The agent now uses 'google/gemini-3-flash-preview', but defaultOpts still calls google.chat('gemini-2.5-flash-preview-09-2025'). This mismatch can cause confusion or inconsistent behavior (e.g., metrics referring to a different model). Consider keeping these values in sync or deriving both from a shared constant.
Suggested implementation:
includeThoughts: true,
thinkingLevel: 'high',
},
responseModalities: ['TEXT'],
} satisfies GoogleGenerativeAIProviderOptions,
}
}
},
model: `google/${GOOGLE_FLASH_MODEL_ID}`,
memory: pgMemory,
tools: { provider: google.chat(GOOGLE_FLASH_MODEL_ID),const GOOGLE_FLASH_MODEL_ID = 'gemini-3-flash-preview';
export const dane =|
🤖 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.
Code Review
This pull request introduces a series of enhancements and refactorings across various agent workflows and configurations. The changes include preventing double OTEL instrumentation, updating agent models and tools, improving logging by switching to a structured logger, and hardening error handling in workflows. My review focuses on improving code clarity, maintainability, and consistency. I've suggested simplifying some verbose conditional checks, renaming a variable for better descriptiveness, and fixing an indentation issue.
| const instructions1 = ` | ||
| You are an AI note assistant tasked with providing concise, structured summaries of their content... // omitted for brevity | ||
| `; | ||
|
|
||
| export const noteTakerAgent = new Agent({ | ||
| id: "noteTakerAgent", | ||
| name: "Note Taker Agent", | ||
| instructions: instructions, | ||
| instructions: instructions1, |
There was a problem hiding this comment.
The variable instructions has been renamed to instructions1. This name is not descriptive and could be confusing for future maintenance. It would be better to use a name that clearly indicates its purpose, such as noteTakerInstructions, or simply instructions if it's the only one in the file.
| const instructions1 = ` | |
| You are an AI note assistant tasked with providing concise, structured summaries of their content... // omitted for brevity | |
| `; | |
| export const noteTakerAgent = new Agent({ | |
| id: "noteTakerAgent", | |
| name: "Note Taker Agent", | |
| instructions: instructions, | |
| instructions: instructions1, | |
| const noteTakerInstructions = ` | |
| You are an AI note assistant tasked with providing concise, structured summaries of their content... // omitted for brevity | |
| `; | |
| export const noteTakerAgent = new Agent({ | |
| id: "noteTakerAgent", | |
| name: "Note Taker Agent", | |
| instructions: noteTakerInstructions, |
| log.info('Learning Extraction Experiment Results:', { results: JSON.stringify(results, null, 2) }) | ||
| return results |
There was a problem hiding this comment.
There's an indentation issue here. The log.info and return statements are over-indented, which affects code readability and consistency with the rest of the file.
| log.info('Learning Extraction Experiment Results:', { results: JSON.stringify(results, null, 2) }) | |
| return results | |
| log.info('Learning Extraction Experiment Results:', { results: JSON.stringify(results, null, 2) }) | |
| return results |
|
|
||
| const prompt = `Research the topic "${inputData.topic}" for a ${inputData.contentType} | ||
| ${inputData.targetAudience ? `targeting ${inputData.targetAudience}` : ''}. | ||
| ${inputData.targetAudience !== undefined && inputData.targetAudience !== null && inputData.targetAudience.trim().length > 0 ? `targeting ${inputData.targetAudience}` : ''}. |
There was a problem hiding this comment.
The condition to check for targetAudience is quite verbose. It can be simplified for better readability. Using optional chaining (?.) with trim() provides a more concise and idiomatic way to check for a non-empty string, as it correctly handles undefined and null values.
| ${inputData.targetAudience !== undefined && inputData.targetAudience !== null && inputData.targetAudience.trim().length > 0 ? `targeting ${inputData.targetAudience}` : ''}. | |
| ${inputData.targetAudience?.trim() ? `targeting ${inputData.targetAudience}` : ''}. |
| Research Summary: ${inputData.research.summary} | ||
| Key Points to Cover: ${inputData.research.keyPoints.join(', ')} | ||
| ${inputData.targetAudience ? `Target Audience: ${inputData.targetAudience}` : ''} | ||
| ${inputData.targetAudience !== undefined && inputData.targetAudience !== null && inputData.targetAudience.trim().length > 0 ? `Target Audience: ${inputData.targetAudience}` : ''} |
There was a problem hiding this comment.
This condition to check for targetAudience is verbose and duplicated. It can be simplified for better readability and consistency. Using optional chaining (?.) with trim() is a more concise way to achieve the same result.
| ${inputData.targetAudience !== undefined && inputData.targetAudience !== null && inputData.targetAudience.trim().length > 0 ? `Target Audience: ${inputData.targetAudience}` : ''} | |
| ${inputData.targetAudience?.trim() ? `Target Audience: ${inputData.targetAudience}` : ''} |
|
|
||
| const successResult = result as { success: boolean; content?: string; encoding?: string; sha?: string; size?: number; error?: string }; | ||
| if (!successResult.success || !successResult.content) { | ||
| if (!successResult.success || successResult.content === null || successResult.content === undefined || successResult.content === '') { |
There was a problem hiding this comment.
The condition to check for successResult.content is more verbose than necessary. The !successResult.content check is sufficient as it correctly handles null, undefined, and empty strings (''), which are all falsy in TypeScript. This makes the code more concise and idiomatic.
| if (!successResult.success || successResult.content === null || successResult.content === undefined || successResult.content === '') { | |
| if (!successResult.success || !successResult.content) { |
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (4)
src/mastra/workflows/financial-report-workflow.ts (2)
144-144: Remove extra whitespace in parameter list.Line 144 has inconsistent spacing between parameters.
- execute: async ({ inputData, writer }) => { + execute: async ({ inputData, writer }) => {
249-249: Add missing semicolons for consistency.Lines 249, 387, 449, and 553 are missing semicolons after
})inwriter.custom()calls, while other similar calls elsewhere include them. Ensure consistency across all writer.custom() invocations.- }) + });Apply this pattern to all affected lines (249, 387, 449, 553).
Also applies to: 387-387, 449-449, 553-553
src/mastra/workflows/changelog.ts (1)
309-319: Critical: Prompt references disabled Slack tool, causing inconsistent behavior.The prompt on line 309 instructs the agent to "send this to this slack channel" using
slack_post_message, but the Slack tool is commented out on line 317. This creates a mismatch where the agent is instructed to perform an action it cannot execute, potentially leading to errors or confusion.Apply this diff to remove the Slack reference from the prompt:
- Finally send this to this slack channel: "${channelId}" with the tool slack_post_messageAlternatively, if Slack posting is needed, re-enable the tool:
-// slack: tools, + slack: tools,src/mastra/agents/dane.ts (1)
3-3: Minor: Remove unusedgoogleSearchimport.The
googleSearchtool is imported on line 3 but no longer used after being replaced bywebScraperToolin the tools object.Apply this diff to remove the unused import:
-import { browserTool, googleSearch } from '../tools/browser-tool' +import { browserTool } from '../tools/browser-tool'
📜 Review details
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (11)
instrumentation.ts(1 hunks)src/mastra/agents/dane.ts(2 hunks)src/mastra/agents/editorAgent.ts(1 hunks)src/mastra/agents/noteTakerAgent.ts(1 hunks)src/mastra/agents/weather-agent.ts(1 hunks)src/mastra/evals/agent-experiments.ts(7 hunks)src/mastra/workflows/changelog.ts(4 hunks)src/mastra/workflows/content-review-workflow.ts(2 hunks)src/mastra/workflows/financial-report-workflow.ts(1 hunks)src/mastra/workflows/repo-ingestion-workflow.ts(2 hunks)src/mastra/workflows/telephone-game.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (18)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)
**/*.{js,jsx,ts,tsx}: Usenext/dynamicfor dynamic imports to load components only when needed, improving initial load time.
Usenext/imagecomponent for automatic image optimization, including lazy loading and responsive images.
Use React.memo to prevent unnecessary re-renders of components.
Use the<Link prefetch>tag to prefetch pages that are likely to be visited.
Use getServerSideProps, getStaticProps, or server components for fetching data on the server-side.
Use SWR or React Query for client-side data fetching and caching.
Use CSS Modules, Styled Components, or Tailwind CSS for component-level styling. Prefer Tailwind CSS for rapid development.
Use React Context, Zustand, Jotai, or Recoil for managing global state. Avoid Redux unless necessary.
Usereact-hook-formfor managing forms and validation.
Only fetch the data that is needed by the component to avoid over-fetching.
Avoid long-running synchronous operations in the main thread to prevent blocking.
Always usesetStateor hooks to update state instead of mutating state directly.
Include a complete dependency array inuseEffecthooks to prevent unexpected behavior.
Avoid writing server-side code in client components to prevent exposing secrets or causing unexpected behavior.
Usetry...catchblocks for handling errors in asynchronous operations.
Implement error boundary components usinggetDerivedStateFromErrororcomponentDidCatchlifecycle methods.
Sanitize user input to prevent Cross-Site Scripting (XSS) attacks. Be especially careful when rendering HTML directly from user input.
Store authentication tokens in HTTP-only cookies or local storage securely.
Implement role-based access control to restrict access to sensitive resources.
Clean up event listeners and timers inuseEffecthooks to avoid memory leaks.
Only update state when necessary to reduce the number of re-renders and improve performance.
Use immutable data structures and avoid mutating data directly to prevent unexpected...
Files:
src/mastra/workflows/content-review-workflow.tssrc/mastra/agents/weather-agent.tssrc/mastra/agents/dane.tssrc/mastra/workflows/repo-ingestion-workflow.tssrc/mastra/agents/noteTakerAgent.tssrc/mastra/workflows/financial-report-workflow.tssrc/mastra/agents/editorAgent.tssrc/mastra/workflows/telephone-game.tssrc/mastra/workflows/changelog.tssrc/mastra/evals/agent-experiments.tsinstrumentation.ts
**/*.{js,ts}
📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)
Use parameterized queries or an ORM to prevent SQL injection attacks.
Files:
src/mastra/workflows/content-review-workflow.tssrc/mastra/agents/weather-agent.tssrc/mastra/agents/dane.tssrc/mastra/workflows/repo-ingestion-workflow.tssrc/mastra/agents/noteTakerAgent.tssrc/mastra/workflows/financial-report-workflow.tssrc/mastra/agents/editorAgent.tssrc/mastra/workflows/telephone-game.tssrc/mastra/workflows/changelog.tssrc/mastra/evals/agent-experiments.tsinstrumentation.ts
**/*.{ts,tsx,js,jsx,py,java,cs,rb,go,rs,cpp,c,h,hpp,swift,kotlin,php,scala,clj,groovy,lua,sh,bash}
📄 CodeRabbit inference engine (.github/instructions/self-explanatory-code-commenting.instructions.md)
**/*.{ts,tsx,js,jsx,py,java,cs,rb,go,rs,cpp,c,h,hpp,swift,kotlin,php,scala,clj,groovy,lua,sh,bash}: Write code that speaks for itself. Comment only when necessary to explain WHY, not WHAT. Avoid obvious comments that state what the code literally does.
Avoid redundant comments that simply repeat what the code is doing
Keep comments accurate and up-to-date with code changes. Remove or update outdated comments that no longer match the implementation.
Write comments for complex business logic that explain the WHY behind specific calculations or business rules
Document non-obvious algorithms with comments explaining the algorithm choice and its reasoning
Add comments explaining what regex patterns match, especially for complex patterns
Document API constraints, rate limits, gotchas, and external dependencies with explanatory comments
Avoid commenting out dead code. Use version control instead of maintaining commented code blocks.
Do not maintain code change history or modification logs as comments. Rely on git history and commit messages instead.
Avoid decorative divider comments (e.g., lines of equals signs or asterisks) for section separation
Ensure comments are placed appropriately above or adjacent to the code they describe
Write comments using proper grammar, spelling, and professional language
Prefer self-documenting code with clear variable/function names over adding comments to explain unclear code
Files:
src/mastra/workflows/content-review-workflow.tssrc/mastra/agents/weather-agent.tssrc/mastra/agents/dane.tssrc/mastra/workflows/repo-ingestion-workflow.tssrc/mastra/agents/noteTakerAgent.tssrc/mastra/workflows/financial-report-workflow.tssrc/mastra/agents/editorAgent.tssrc/mastra/workflows/telephone-game.tssrc/mastra/workflows/changelog.tssrc/mastra/evals/agent-experiments.tsinstrumentation.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/instructions/self-explanatory-code-commenting.instructions.md)
**/*.{ts,tsx,js,jsx}: Document public APIs with TSDoc/JSDoc comments including parameter descriptions, return types, examples, and thrown exceptions
Add TSDoc comments to configuration constants and environment variables explaining their source, reasoning, or constraints
Use TSDoc annotation tags (TODO, FIXME, HACK, NOTE, WARNING, PERF, SECURITY, BUG, REFACTOR, DEPRECATED) to mark special comments
Include file headers with @fileoverview, @author, @copyright, and @license tags to document file purpose and ownership
Document function parameters with @param tags, return values with @returns tags, and exceptions with @throws tags in TSDoc comments
Use @see tags in TSDoc comments to reference related functions, methods, or documentation
Include @example tags in public API documentation with code examples showing typical usageUse ESLint configuration from eslint.config.cjs with TypeScript rules and Prettier integration
Files:
src/mastra/workflows/content-review-workflow.tssrc/mastra/agents/weather-agent.tssrc/mastra/agents/dane.tssrc/mastra/workflows/repo-ingestion-workflow.tssrc/mastra/agents/noteTakerAgent.tssrc/mastra/workflows/financial-report-workflow.tssrc/mastra/agents/editorAgent.tssrc/mastra/workflows/telephone-game.tssrc/mastra/workflows/changelog.tssrc/mastra/evals/agent-experiments.tsinstrumentation.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/self-explanatory-code-commenting.instructions.md)
**/*.{ts,tsx}: Document interface and type definitions with TSDoc comments explaining their purpose and usage context
Document interface properties with /** */ comments explaining each field's purpose and constraints
Document generic type parameters with @template tags explaining what each type parameter represents
Use type guards with comments explaining the runtime validation logic being performed
Document advanced/complex TypeScript types with explanatory comments about their purpose and use cases
Files:
src/mastra/workflows/content-review-workflow.tssrc/mastra/agents/weather-agent.tssrc/mastra/agents/dane.tssrc/mastra/workflows/repo-ingestion-workflow.tssrc/mastra/agents/noteTakerAgent.tssrc/mastra/workflows/financial-report-workflow.tssrc/mastra/agents/editorAgent.tssrc/mastra/workflows/telephone-game.tssrc/mastra/workflows/changelog.tssrc/mastra/evals/agent-experiments.tsinstrumentation.ts
src/mastra/**/*
📄 CodeRabbit inference engine (src/AGENTS.md)
mastramodules can import fromutils, but must not import fromapporcli(excepttypes)
Files:
src/mastra/workflows/content-review-workflow.tssrc/mastra/agents/weather-agent.tssrc/mastra/agents/dane.tssrc/mastra/workflows/repo-ingestion-workflow.tssrc/mastra/agents/noteTakerAgent.tssrc/mastra/workflows/financial-report-workflow.tssrc/mastra/agents/editorAgent.tssrc/mastra/workflows/telephone-game.tssrc/mastra/workflows/changelog.tssrc/mastra/evals/agent-experiments.ts
src/mastra/workflows/**/*.ts
📄 CodeRabbit inference engine (src/mastra/AGENTS.md)
Add workflows under
src/mastra/workflowsto orchestrate multi-step flows
src/mastra/workflows/**/*.ts: Define workflows using Mastra DSL patterns (e.g.,.then(),.branch(),.parallel(),.foreach(),.dowhile()) and demonstrate the appropriate pattern for your use case
Use tools and agents as building blocks in workflows; prefer composition over duplication
Use sequential pattern (.then()) for workflows with dependent steps executed in order (e.g., weatherWorkflow, stockAnalysisWorkflow, changelogWorkflow)
Use parallel pattern (.parallel()) for workflows that fetch or process multiple independent data sources concurrently (e.g., financialReportWorkflow)
Use conditional branch pattern (.branch()) for workflows that need to route to different processing paths based on input conditions (e.g., documentProcessingWorkflow for PDF handling)
Use loop pattern (.dowhile()) for workflows that need iterative refinement until a condition is met (e.g., contentReviewWorkflow)
Use iteration pattern (.foreach()) for workflows that process multiple items concurrently (e.g., researchSynthesisWorkflow for topic research)
Use human-in-the-loop pattern withsuspend()andresume()for workflows requiring human approval or input (e.g., learningExtractionWorkflow)
Pipe agent response streams to the step writer usingresponse.fullStream.pipeTo(writer)to enable text chunk streaming in workflow steps
UseinputSchemaandoutputSchemawith Zod for type-safe step definitions in workflows
Call.commit()on workflow definitions after constructing them to finalize and register the workflow
Add tests and e2e test harnesses to validate workflow integrationsDefine workflows using the Mastra DSL for multi-step orchestration
Files:
src/mastra/workflows/content-review-workflow.tssrc/mastra/workflows/repo-ingestion-workflow.tssrc/mastra/workflows/financial-report-workflow.tssrc/mastra/workflows/telephone-game.tssrc/mastra/workflows/changelog.ts
src/mastra/{tools,workflows}/**/*.ts
📄 CodeRabbit inference engine (src/mastra/AGENTS.md)
Use
RequestContext(per-request) or agent-specific runtime context types (e.g.EditorRuntimeContext) to enforce access control in tools and workflows
Files:
src/mastra/workflows/content-review-workflow.tssrc/mastra/workflows/repo-ingestion-workflow.tssrc/mastra/workflows/financial-report-workflow.tssrc/mastra/workflows/telephone-game.tssrc/mastra/workflows/changelog.ts
**/*.{ts,tsx,js,jsx,json}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
For Next.js projects, always utilize the
next-devtools-mcpserver for all Next.js related queries
Files:
src/mastra/workflows/content-review-workflow.tssrc/mastra/agents/weather-agent.tssrc/mastra/agents/dane.tssrc/mastra/workflows/repo-ingestion-workflow.tssrc/mastra/agents/noteTakerAgent.tssrc/mastra/workflows/financial-report-workflow.tssrc/mastra/agents/editorAgent.tssrc/mastra/workflows/telephone-game.tssrc/mastra/workflows/changelog.tssrc/mastra/evals/agent-experiments.tsinstrumentation.ts
**/*.{js,ts,jsx,tsx,java,py,cs,go,rb,php,swift,kt,scala,rs,cpp,c,h}
📄 CodeRabbit inference engine (.github/instructions/code-review-generic.instructions.md)
**/*.{js,ts,jsx,tsx,java,py,cs,go,rb,php,swift,kt,scala,rs,cpp,c,h}: Use descriptive and meaningful names for variables, functions, and classes
Apply Single Responsibility Principle: each function/class does one thing well
Follow DRY (Don't Repeat Yourself): eliminate code duplication
Keep functions small and focused (ideally < 20-30 lines)
Avoid deeply nested code (max 3-4 levels)
Avoid magic numbers and strings; use named constants instead
Code should be self-documenting; use comments only when necessary
Implement proper error handling at appropriate levels with meaningful error messages
Avoid silent failures or ignored exceptions; fail fast and validate inputs early
Use appropriate error types/exceptions with meaningful context
Validate and sanitize all user inputs
Use parameterized queries for database access; never use string concatenation for SQL queries
Implement proper authentication checks before accessing resources
Verify user has permission to perform actions; implement proper authorization
Use established cryptographic libraries; never roll your own crypto implementation
Avoid N+1 query problems; use proper indexing and eager loading for database queries
Use appropriate algorithms with suitable time/space complexity for the use case
Utilize caching for expensive or repeated operations
Ensure proper cleanup of connections, files, and streams to prevent resource leaks
Implement pagination for large result sets
Load data only when needed (lazy loading pattern)
Document all public APIs with purpose, parameters, and return values
Add explanatory comments for non-obvious logic
No commented-out code or unresolved TODO comments without associated tickets should remain in commits
Ensure code follows consistent style and conventions with the rest of the codebase
Files:
src/mastra/workflows/content-review-workflow.tssrc/mastra/agents/weather-agent.tssrc/mastra/agents/dane.tssrc/mastra/workflows/repo-ingestion-workflow.tssrc/mastra/agents/noteTakerAgent.tssrc/mastra/workflows/financial-report-workflow.tssrc/mastra/agents/editorAgent.tssrc/mastra/workflows/telephone-game.tssrc/mastra/workflows/changelog.tssrc/mastra/evals/agent-experiments.tsinstrumentation.ts
**/*.{js,ts,jsx,tsx,java,py,cs,go,rb,php,swift,kt,scala,rs,cpp,c,h,json,yaml,yml,env,config}
📄 CodeRabbit inference engine (.github/instructions/code-review-generic.instructions.md)
Never include passwords, API keys, tokens, or PII in code or logs
Files:
src/mastra/workflows/content-review-workflow.tssrc/mastra/agents/weather-agent.tssrc/mastra/agents/dane.tssrc/mastra/workflows/repo-ingestion-workflow.tssrc/mastra/agents/noteTakerAgent.tssrc/mastra/workflows/financial-report-workflow.tssrc/mastra/agents/editorAgent.tssrc/mastra/workflows/telephone-game.tssrc/mastra/workflows/changelog.tssrc/mastra/evals/agent-experiments.tsinstrumentation.ts
**/*.{ts,tsx,java,cs,go,php,swift,kt,scala}
📄 CodeRabbit inference engine (.github/instructions/code-review-generic.instructions.md)
Prefer small, focused interfaces (Interface Segregation Principle)
Files:
src/mastra/workflows/content-review-workflow.tssrc/mastra/agents/weather-agent.tssrc/mastra/agents/dane.tssrc/mastra/workflows/repo-ingestion-workflow.tssrc/mastra/agents/noteTakerAgent.tssrc/mastra/workflows/financial-report-workflow.tssrc/mastra/agents/editorAgent.tssrc/mastra/workflows/telephone-game.tssrc/mastra/workflows/changelog.tssrc/mastra/evals/agent-experiments.tsinstrumentation.ts
**/*.{js,mjs,cjs,ts,tsx,jsx,py,java,cs,go,rb,php,rs,cpp,c,h,hpp}
📄 CodeRabbit inference engine (.github/instructions/update-docs-on-code-change.instructions.md)
Use automated documentation generators for code documentation - JSDoc/TSDoc for JavaScript/TypeScript, Sphinx/pdoc for Python, Javadoc for Java, xmldoc for C#, godoc for Go, rustdoc for Rust
Files:
src/mastra/workflows/content-review-workflow.tssrc/mastra/agents/weather-agent.tssrc/mastra/agents/dane.tssrc/mastra/workflows/repo-ingestion-workflow.tssrc/mastra/agents/noteTakerAgent.tssrc/mastra/workflows/financial-report-workflow.tssrc/mastra/agents/editorAgent.tssrc/mastra/workflows/telephone-game.tssrc/mastra/workflows/changelog.tssrc/mastra/evals/agent-experiments.tsinstrumentation.ts
src/mastra/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Use
maskSensitiveMessageData()helper fromsrc/mastra/config/pg-storage.tsto mask secrets in logs
Files:
src/mastra/workflows/content-review-workflow.tssrc/mastra/agents/weather-agent.tssrc/mastra/agents/dane.tssrc/mastra/workflows/repo-ingestion-workflow.tssrc/mastra/agents/noteTakerAgent.tssrc/mastra/workflows/financial-report-workflow.tssrc/mastra/agents/editorAgent.tssrc/mastra/workflows/telephone-game.tssrc/mastra/workflows/changelog.tssrc/mastra/evals/agent-experiments.ts
**/*.{ts,tsx,js,jsx,json,md}
📄 CodeRabbit inference engine (AGENTS.md)
Use Prettier for code formatting with ES5 trailing commas, 4-space tabs, and single quotes
Files:
src/mastra/workflows/content-review-workflow.tssrc/mastra/agents/weather-agent.tssrc/mastra/agents/dane.tssrc/mastra/workflows/repo-ingestion-workflow.tssrc/mastra/agents/noteTakerAgent.tssrc/mastra/workflows/financial-report-workflow.tssrc/mastra/agents/editorAgent.tssrc/mastra/workflows/telephone-game.tssrc/mastra/workflows/changelog.tssrc/mastra/evals/agent-experiments.tsinstrumentation.ts
**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript with ES2022 target and Next.js path aliases configured in tsconfig.json
Files:
src/mastra/workflows/content-review-workflow.tssrc/mastra/agents/weather-agent.tssrc/mastra/agents/dane.tssrc/mastra/workflows/repo-ingestion-workflow.tssrc/mastra/agents/noteTakerAgent.tssrc/mastra/workflows/financial-report-workflow.tssrc/mastra/agents/editorAgent.tssrc/mastra/workflows/telephone-game.tssrc/mastra/workflows/changelog.tssrc/mastra/evals/agent-experiments.tsinstrumentation.ts
src/mastra/agents/*.ts
📄 CodeRabbit inference engine (src/mastra/agents/AGENTS.md)
src/mastra/agents/*.ts: Agent file naming convention: Create agent files using kebab-case with.tsextension in/src/mastra/agents/directory (e.g.,your-agent-name.ts)
Each agent must follow the pattern: export agent asconst yourAgent = new Agent({ id: 'your-agent-id', name: 'Your Agent Name', description: '...' })
Files:
src/mastra/agents/weather-agent.tssrc/mastra/agents/dane.tssrc/mastra/agents/noteTakerAgent.tssrc/mastra/agents/editorAgent.ts
src/mastra/agents/**/*.ts
📄 CodeRabbit inference engine (src/mastra/AGENTS.md)
Add agents under
src/mastra/agentsthat wire tools together into higher-level behaviorsImplement agents by composing tools into specialized behaviors using the Mastra agents DSL
Files:
src/mastra/agents/weather-agent.tssrc/mastra/agents/dane.tssrc/mastra/agents/noteTakerAgent.tssrc/mastra/agents/editorAgent.ts
🧬 Code graph analysis (3)
src/mastra/agents/dane.ts (1)
src/mastra/config/pg-storage.ts (1)
pgMemory(87-150)
src/mastra/agents/noteTakerAgent.ts (1)
src/mastra/config/pg-storage.ts (1)
pgMemory(87-150)
src/mastra/evals/agent-experiments.ts (1)
src/mastra/config/logger.ts (1)
log(14-18)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: CodeQL analysis (javascript-typescript)
- GitHub Check: Agent
- GitHub Check: Sourcery review
- GitHub Check: Greptile Review
- GitHub Check: Codacy Security Scan
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (13)
src/mastra/workflows/financial-report-workflow.ts (1)
1-1044: Overall workflow structure is well-implemented.The financial report workflow demonstrates solid use of the Mastra DSL with proper patterns:
- Sequential
.then()chaining for dependent steps- Parallel pattern (
.parallel()) for concurrent data fetching- Comprehensive Zod schemas for type-safe validation
- OTEL tracing at appropriate boundaries
- Robust error handling and progress tracking via writer stream
- Proper use of
commit()to finalize the workflowThe workflow correctly orchestrates multi-step financial data aggregation with streaming progress updates to callers via
stream.textStream.pipeTo(writer)at lines 741 and 882.Please verify that the semicolon inconsistency is not flagged by your configured ESLint rules, and confirm that Prettier formatting is applied consistently across the codebase.
src/mastra/workflows/repo-ingestion-workflow.ts (2)
105-106: Improved error extraction with safe fallback.The error message extraction correctly uses the type guard to safely access
scanResultRaw.errorwhen available, with a clear fallback. This provides better error reporting as intended by the PR objectives.
233-233: Verify that empty files should be treated as errors.The validation now explicitly rejects empty string content. While this catches silent fetch failures, it may also reject legitimate empty files (e.g., empty JSON files, placeholder files, or files that are legitimately empty in the repository).
Verify that this aligns with expected behavior for your use case.
src/mastra/agents/weather-agent.ts (1)
64-64: LGTM: Token limit reduction aligns with performance optimization goals.The reduction from 1,048,576 to 128,000 tokens is a significant tightening of the output budget, which should improve response times and resource usage for the weather agent.
src/mastra/workflows/telephone-game.ts (1)
13-13: LGTM: Neutral cleanup of empty tools configuration.Commenting out the empty tools array is consistent with the broader pattern in this PR of removing explicit empty tool configurations from agent definitions.
src/mastra/workflows/changelog.ts (1)
222-222: LGTM: Whitespace cleanup improves consistency.The whitespace adjustments improve code formatting without affecting functionality.
Also applies to: 333-333, 350-350
src/mastra/workflows/content-review-workflow.ts (1)
129-129: LGTM: Enhanced target audience validation prevents empty/whitespace values.The updated validation properly handles undefined, null, and whitespace-only strings, ensuring the "Target Audience" line only appears when there's meaningful content. This is more robust than the previous truthy check.
Also applies to: 264-264
instrumentation.ts (1)
3-27: LGTM: Well-documented conditional OTEL registration prevents double instrumentation.The feature flag approach with clear documentation effectively prevents conflicting OTEL SDK instances. The strict string equality check and aligned service name demonstrate careful consideration of the dual-configuration scenario.
src/mastra/evals/agent-experiments.ts (1)
12-12: LGTM: Structured logging improves observability.Replacing console.log with the centralized logger provides better log management, filtering, and integration with monitoring tools. The empty scorer arrays appear to be an intentional simplification of the experiments.
Also applies to: 15-15, 31-31, 36-36, 52-52
src/mastra/agents/editorAgent.ts (1)
123-123: LGTM: Consistent with PR-wide cleanup pattern.Commenting out the empty tools array aligns with similar changes across multiple agent files, removing unnecessary explicit empty configurations.
src/mastra/agents/dane.ts (2)
202-202: No changes required—model string format is correct and supported.Mastra's Agent class supports string-based model identifiers using the "provider/model" pattern, such as
'google/gemini-3-flash-preview'. The built-in model router string approach is recommended for simplicity over using AI SDK model provider objects. The model identifiergemini-3-flash-previewis a valid Google Gemini 3 Flash model available in the Gemini API.
195-195: No action required—configuration is correct for each model version.The
daneagent using Gemini 3 Flash (google/gemini-3-flash-preview) correctly usesthinkingLevel: 'high', while other agents using Gemini 2.5 Flash Lite (googleAIFlashLite) correctly usethinkingBudget: -1. The thinking_level parameter replaces thinking_budget for Gemini 3 models. You cannot use both thinking_level and the legacy thinking_budget parameter in the same request. Doing so will return a 400 error. Different model versions require their respective thinking parameters; this is not an inconsistency but proper API compliance.Likely an incorrect or invalid review comment.
src/mastra/agents/noteTakerAgent.ts (1)
3-3: Import change aligns with tools removal.The removal of
pgQueryToolfrom the import is consistent with the commented-out tools configuration on line 14, which aligns with the PR objective of removing unused tools.
| const instructions1 = ` | ||
| You are an AI note assistant tasked with providing concise, structured summaries of their content... // omitted for brevity | ||
| `; |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Revert to descriptive constant name.
The constant name instructions1 includes a numeric suffix that doesn't add semantic value. Per coding guidelines requiring descriptive names, consider reverting to the original name instructions.
Apply this diff:
-const instructions1 = `
+const instructions = `
You are an AI note assistant tasked with providing concise, structured summaries of their content... // omitted for brevity
`;And update line 12:
- instructions: instructions1,
+ instructions: instructions,Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In src/mastra/agents/noteTakerAgent.ts around lines 5 to 7 (and update at line
12), rename the constant instructions1 back to a descriptive name instructions:
change the declaration identifier from instructions1 to instructions and update
any reference on line 12 to use instructions instead of instructions1; ensure
you only rename the identifier (no other content changes) so all usages remain
consistent.
| instructions: instructions1, | ||
| memory: pgMemory, | ||
| tools: [pgQueryTool], | ||
| // tools: [], |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
Remove commented-out code.
Per coding guidelines: "Avoid commenting out dead code. Use version control instead of maintaining commented code blocks." The commented tools array should be removed entirely rather than left as a comment.
Apply this diff:
memory: pgMemory,
-// tools: [],
model: "google/gemini-2.5-flash-lite-preview-09-2025",📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // tools: [], | |
| memory: pgMemory, | |
| model: "google/gemini-2.5-flash-lite-preview-09-2025", |
🤖 Prompt for AI Agents
In src/mastra/agents/noteTakerAgent.ts around line 14, remove the commented-out
dead code "// tools: []," entirely (do not replace it with another comment);
update any trailing commas/formatting if needed and run the formatter/linter to
ensure file remains syntactically correct after deletion.
| } | ||
|
|
||
|
|
||
| const result: z.infer<typeof analysisResultSchema> = { | ||
| stocks: inputData.stocks, |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Remove unnecessary blank line.
Line 760 introduces an extra blank line before the result variable declaration. This is minor formatting but breaks consistency with other step definitions.
}
-
const result: z.infer<typeof analysisResultSchema> = {📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| } | |
| const result: z.infer<typeof analysisResultSchema> = { | |
| stocks: inputData.stocks, | |
| } | |
| const result: z.infer<typeof analysisResultSchema> = { | |
| stocks: inputData.stocks, |
🤖 Prompt for AI Agents
In src/mastra/workflows/financial-report-workflow.ts around lines 758 to 762,
there is an extra blank line between the closing brace of the previous block and
the `const result` declaration; remove that blank line so the `const result:
z.infer<typeof analysisResultSchema> = {` sits immediately after the preceding
`}` to match the file's step-definition formatting, then run the project's
formatter (prettier/ESLint) to ensure consistency.
| const isScanSuccess = (r: unknown): r is { success: boolean; tree?: GitTreeItem[]; error?: string } => | ||
| r !== null && typeof r === 'object' && 'success' in r; |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Strengthen the type guard with runtime validation.
The type guard narrows unknown to an object with a success: boolean property, but the runtime check only verifies that the success property exists—not that it's actually a boolean. If the API returns an unexpected shape like { success: "false" }, the type guard would succeed but subsequent boolean checks could behave unexpectedly.
Apply this diff to add runtime type verification:
-const isScanSuccess = (r: unknown): r is { success: boolean; tree?: GitTreeItem[]; error?: string } =>
- r !== null && typeof r === 'object' && 'success' in r;
+const isScanSuccess = (r: unknown): r is { success: boolean; tree?: GitTreeItem[]; error?: string } =>
+ r !== null && typeof r === 'object' && 'success' in r && typeof (r as { success: unknown }).success === 'boolean';🤖 Prompt for AI Agents
In src/mastra/workflows/repo-ingestion-workflow.ts around lines 101 to 102, the
type guard currently only checks for the existence of a 'success' property but
not its runtime type; update the predicate to validate that r is a non-null
object and that r.success is a boolean (and if present, r.tree is an array and
r.error is a string) so the guard only narrows when shapes and primitive types
match; implement the runtime checks inside the arrow function and return true
only when those validations pass, otherwise return false.
There was a problem hiding this comment.
Pull request overview
This pull request enhances agent workflows and configurations with focus on improving observability, refactoring agent tools, and cleaning up code quality. The changes span across instrumentation setup, agent configurations, workflow validation, and experimental evaluations.
Key Changes:
- Added conditional OTEL registration to prevent double instrumentation conflicts between Vercel and Mastra
- Refactored Dane agent with new webScraperTool and updated (invalid) model identifier
- Migrated from console.log to structured logging across experiment files
- Strengthened type safety and error handling in workflow validation logic
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| instrumentation.ts | Added conditional OTEL initialization to prevent conflicts with Mastra's configuration |
| src/mastra/agents/dane.ts | Updated model to 'gemini-3-flash-preview', replaced googleSearch with webScraperTool, changed thinking config |
| src/mastra/agents/editorAgent.ts | Commented out empty tools array |
| src/mastra/agents/noteTakerAgent.ts | Renamed instructions variable to 'instructions1', commented out tools, removed unused import |
| src/mastra/agents/weather-agent.ts | Reduced token limiter from 1048576 to 128000, removed unused scorer import |
| src/mastra/workflows/repo-ingestion-workflow.ts | Improved type guard from 'any' to 'unknown', enhanced error message handling, added explicit empty string validation |
| src/mastra/workflows/content-review-workflow.ts | Added comprehensive null/undefined/empty checks for targetAudience field |
| src/mastra/workflows/changelog.ts | Commented out slack tools, cleaned up whitespace |
| src/mastra/workflows/telephone-game.ts | Commented out empty tools array |
| src/mastra/workflows/financial-report-workflow.ts | Removed trailing whitespace |
| src/mastra/evals/agent-experiments.ts | Migrated from console.log to structured logger, removed all scorer implementations, fixed indentation issue |
Comments suppressed due to low confidence (2)
src/mastra/evals/agent-experiments.ts:52
- Inconsistent logging format. Line 36 uses 'Running Copywriter Experiment...' (with ellipsis as a string literal) while line 15 uses structured logging with an event object. Line 52 also mixes the pattern with 'Copywriter Experiment Results:' using a colon. Consider standardizing to the structured logging approach used in line 15 for consistency.
src/mastra/evals/agent-experiments.ts:122 - Inconsistent indentation detected. Lines 121-122 are indented with extra spaces compared to the rest of the function. This should match the indentation of line 120 above.
| execaTool, | ||
| browserTool, | ||
| googleSearch, | ||
| webScraperTool, |
There was a problem hiding this comment.
The instructions documentation still references 'googleSearch' tool (lines 172-174), but the actual tools configuration now uses 'webScraperTool' instead of 'googleSearch'. This inconsistency between documentation and implementation could confuse the agent's behavior and users reviewing the code.
| tools: [pgQueryTool], | ||
| // tools: [], | ||
| model: "google/gemini-2.5-flash-lite-preview-09-2025", | ||
| voice: new GoogleVoice(), // Add OpenAI voice provider with default configuration |
There was a problem hiding this comment.
The comment states "Add OpenAI voice provider with default configuration" but the code actually uses GoogleVoice(), not an OpenAI voice provider. This misleading comment should be corrected to accurately reflect the implementation.
| voice: new GoogleVoice(), // Add OpenAI voice provider with default configuration | |
| voice: new GoogleVoice(), // Add Google voice provider with default configuration |
| const result = await agent.generate(prompt, { | ||
| toolsets: { | ||
| slack: tools, | ||
| // slack: tools, |
There was a problem hiding this comment.
Commented-out code should be removed rather than left in the codebase. The slack toolset is commented out but no explanation is provided. If this is intentional, add a comment explaining why, or remove it entirely to avoid confusion.
| // slack: tools, | |
| slack: tools, |
|
|
||
| const prompt = `Research the topic "${inputData.topic}" for a ${inputData.contentType} | ||
| ${inputData.targetAudience ? `targeting ${inputData.targetAudience}` : ''}. | ||
| ${inputData.targetAudience !== undefined && inputData.targetAudience !== null && inputData.targetAudience.trim().length > 0 ? `targeting ${inputData.targetAudience}` : ''}. |
There was a problem hiding this comment.
The validation check for targetAudience is overly complex and verbose. The condition checks for undefined, null, AND empty string after trimming, which could be simplified using optional chaining and a more concise approach. Consider: inputData.targetAudience?.trim() ? \targeting ${inputData.targetAudience}` : ''`
| ${inputData.targetAudience !== undefined && inputData.targetAudience !== null && inputData.targetAudience.trim().length > 0 ? `targeting ${inputData.targetAudience}` : ''}. | |
| ${inputData.targetAudience?.trim() ? `targeting ${inputData.targetAudience}` : ''}. |
| const instructions1 = ` | ||
| You are an AI note assistant tasked with providing concise, structured summaries of their content... // omitted for brevity | ||
| `; | ||
|
|
||
| export const noteTakerAgent = new Agent({ | ||
| id: "noteTakerAgent", | ||
| name: "Note Taker Agent", | ||
| instructions: instructions, | ||
| instructions: instructions1, |
There was a problem hiding this comment.
The variable name was changed from 'instructions' to 'instructions1', which is less descriptive and appears arbitrary. This naming doesn't follow clear conventions and makes the code less maintainable. Consider keeping the original name 'instructions' or using a more meaningful name like 'noteTakerInstructions'.
| instructions: instructions1, | ||
| memory: pgMemory, | ||
| tools: [pgQueryTool], | ||
| // tools: [], |
There was a problem hiding this comment.
Commented-out code should be removed rather than left in the codebase. If tools need to be temporarily disabled, consider using a configuration flag or documenting why they're disabled. Empty arrays or comments like this create maintenance debt.
| // tools: [], |
| }, | ||
| memory: pgMemory, | ||
| tools: [], | ||
| // tools: [], |
There was a problem hiding this comment.
Commented-out code should be removed rather than left in the codebase. If tools need to be temporarily disabled, consider using a configuration flag or documenting why they're disabled. Empty arrays or comments like this create maintenance debt.
| // tools: [], |
| model: googleAIFlashLite, | ||
| memory: pgMemory, | ||
| tools: [], | ||
| // tools: [], |
There was a problem hiding this comment.
Commented-out code should be removed rather than left in the codebase. If tools need to be temporarily disabled, consider using a configuration flag or documenting why they're disabled. Empty arrays or comments like this create maintenance debt.
| // tools: [], |
| Research Summary: ${inputData.research.summary} | ||
| Key Points to Cover: ${inputData.research.keyPoints.join(', ')} | ||
| ${inputData.targetAudience ? `Target Audience: ${inputData.targetAudience}` : ''} | ||
| ${inputData.targetAudience !== undefined && inputData.targetAudience !== null && inputData.targetAudience.trim().length > 0 ? `Target Audience: ${inputData.targetAudience}` : ''} |
There was a problem hiding this comment.
The validation check for targetAudience is overly complex and verbose. The condition checks for undefined, null, AND empty string after trimming, which could be simplified using optional chaining and a more concise approach. Consider: inputData.targetAudience?.trim() ? \Target Audience: ${inputData.targetAudience}` : ''`
| ${inputData.targetAudience !== undefined && inputData.targetAudience !== null && inputData.targetAudience.trim().length > 0 ? `Target Audience: ${inputData.targetAudience}` : ''} | |
| ${inputData.targetAudience?.trim() ? `Target Audience: ${inputData.targetAudience}` : ''} |
|
|
||
| const successResult = result as { success: boolean; content?: string; encoding?: string; sha?: string; size?: number; error?: string }; | ||
| if (!successResult.success || !successResult.content) { | ||
| if (!successResult.success || successResult.content === null || successResult.content === undefined || successResult.content === '') { |
There was a problem hiding this comment.
The empty string check in this condition is redundant and could lead to unexpected behavior. An empty string is falsy, so if content is an empty string and the file actually exists but is empty, this will throw an error. Consider removing the empty string check or handling empty files differently if they're valid cases.
| if (!successResult.success || successResult.content === null || successResult.content === undefined || successResult.content === '') { | |
| if (!successResult.success || successResult.content == null) { |
Greptile Summary
Important Files Changed
Confidence score: 2/5
Sequence DiagramsequenceDiagram
participant User
participant ContentReviewWorkflow
participant ResearchAgent
participant CopywriterAgent
participant EditorAgent
participant EvaluationAgent
User->>ContentReviewWorkflow: "Start content creation (topic, contentType, targetAudience, qualityThreshold)"
ContentReviewWorkflow->>ResearchAgent: "Research topic for content type"
ResearchAgent-->>ContentReviewWorkflow: "Research summary, key points, sources, facts"
ContentReviewWorkflow->>CopywriterAgent: "Draft content based on research"
CopywriterAgent-->>ContentReviewWorkflow: "Initial content draft with word count"
ContentReviewWorkflow->>EvaluationAgent: "Review and score content quality"
EvaluationAgent-->>ContentReviewWorkflow: "Quality score and feedback"
alt Score below quality threshold
loop Until approved or max iterations reached
ContentReviewWorkflow->>CopywriterAgent: "Refine content based on feedback"
CopywriterAgent-->>ContentReviewWorkflow: "Improved content draft"
ContentReviewWorkflow->>EvaluationAgent: "Re-evaluate refined content"
EvaluationAgent-->>ContentReviewWorkflow: "Updated score and feedback"
end
end
ContentReviewWorkflow->>ContentReviewWorkflow: "Finalize approved content"
ContentReviewWorkflow-->>User: "Final content with metadata, score, and iteration history"
|
There was a problem hiding this comment.
Additional Comments (2)
-
src/mastra/agents/dane.ts, line 3 (link)style: googleSearch is imported but no longer used in the tools configuration
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
-
src/mastra/agents/dane.ts, line 173-174 (link)logic: Instructions reference 'googleSearch' but the agent now uses 'webScraperTool' - this creates confusion about available tools
11 files reviewed, 4 comments
| tools: [pgQueryTool], | ||
| // tools: [], | ||
| model: "google/gemini-2.5-flash-lite-preview-09-2025", | ||
| voice: new GoogleVoice(), // Add OpenAI voice provider with default configuration |
There was a problem hiding this comment.
style: Comment mentions OpenAI voice provider but the code uses GoogleVoice
| voice: new GoogleVoice(), // Add OpenAI voice provider with default configuration | |
| voice: new GoogleVoice(), // Add Google voice provider with default configuration |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/mastra/agents/noteTakerAgent.ts
Line: 16:16
Comment:
**style:** Comment mentions OpenAI voice provider but the code uses GoogleVoice
```suggestion
voice: new GoogleVoice(), // Add Google voice provider with default configuration
```
How can I resolve this? If you propose a fix, please make it concise.| log.info('Learning Extraction Experiment Results:', { results: JSON.stringify(results, null, 2) }) | ||
| return results |
There was a problem hiding this comment.
syntax: incorrect indentation will cause syntax error - these lines should be properly indented within the function block
| log.info('Learning Extraction Experiment Results:', { results: JSON.stringify(results, null, 2) }) | |
| return results | |
| log.info('Learning Extraction Experiment Results:', { results: JSON.stringify(results, null, 2) }) | |
| return results |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/mastra/evals/agent-experiments.ts
Line: 121:122
Comment:
**syntax:** incorrect indentation will cause syntax error - these lines should be properly indented within the function block
```suggestion
log.info('Learning Extraction Experiment Results:', { results: JSON.stringify(results, null, 2) })
return results
```
How can I resolve this? If you propose a fix, please make it concise.
Summary by Sourcery
Improve agent configurations, observability, and workflow robustness across the Mastra system.
New Features:
Bug Fixes:
Enhancements: