-
Notifications
You must be signed in to change notification settings - Fork 1
feat: update weather agent and Google configuration #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Added cached content option to the weather agent for improved performance. - Updated Google model initialization to use languageModel method for various chat and image models. - Commented out unused imports and variables in Google configuration files. refactor: modify embedding model initialization - Changed embedding model initialization in LanceDB, MongoDB, and Qdrant configurations to use ModelRouterEmbeddingModel for better flexibility. fix: adjust sampling probability in Mastra configuration - Increased sampling probability from 0.5 to 0.75 to enhance decision-making in the agent's sampling strategy. chore: update crawler statistics and session pool state - Modified SDK_CRAWLER_STATISTICS_0.json to reflect new request metrics and timestamps. - Updated SDK_SESSION_POOL_STATE.json with new session IDs and cookie values for improved session management. feat: implement weather tool logging enhancements - Updated logging in the weather tool to include more detailed information about tool calls and input handling. chore: add Convex configuration file - Created convex.json to define Node.js version for the Convex framework. test: add agent registry tests - Implemented tests for agent registry to ensure all expected agents are present. chore: add OpenTelemetry instrumentation setup - Created instrumentation file for OpenTelemetry to enable tracing and monitoring of the application.
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.
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.
Summary by CodeRabbitRelease Notes
✏️ Tip: You can customize this high-level summary in your review settings. WalkthroughThis PR significantly expands the agent configuration surface by adding numerous new agents and networks (weatherAgent, graphSupervisorAgent, technicalAnalysisAgent, finnhubAgent, and many others), normalizes AGENT_CONFIGS keys to string literals, improves TypeScript type safety in tool component rendering with explicit UITool casts, refactors embedding model initialization across multiple config files to use ModelRouterEmbeddingModel, and extends the weather tool output schema to include a unit field. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ 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 |
|
🤖 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. |
Reviewer's GuideUpdates the weather agent to use cached content and enhanced logging, refactors Google and embedding model configuration to use the newer AI SDK APIs and ModelRouterEmbeddingModel, adjusts Mastra sampling behavior, expands and tightens agent registry configuration, and adds supporting Convex, OpenTelemetry, crawler state, and test fixtures. Sequence diagram for enhanced weather agent call with logging and cached contentsequenceDiagram
actor User
participant UI as ChatUI
participant MA as MastraAgentOrchestrator
participant WA as weatherAgent
participant WT as weatherTool
participant L as Logger
participant GA as GoogleAIProvider
User->>UI: Enter weather question
UI->>MA: sendMessage selectedAgent=weatherAgent
MA->>WA: invokeAgent messages
WA->>GA: initializeModel cachedContent
GA-->>WA: modelWithCache
WA->>WT: callTool get-weather input(location)
WT->>L: log onInputStart toolCallId_includes_get_weather
loop streaming_input
WT->>L: log onInputDelta toolCallId_includes_get_weather
end
WT->>L: log onInputAvailable location
alt cacheHit
GA-->>WT: returnCachedResponse
else cacheMiss
WT->>GA: callModelOrApi location
GA-->>WT: weatherData
end
WT->>L: log onOutput toolCallId_includes_get_weather
WT-->>WA: toolResult weatherData
WA-->>MA: agentResponse with weatherData
MA-->>UI: streamResponse
UI-->>User: renderWeatherCards
Class diagram for updated Google and embedding configurationsclassDiagram
class GoogleConfig {
+string apiKey
+google languageModel(string modelId)
+google image(string modelId)
+google embedding(string modelId)
}
class GoogleChatModels {
+any gemini3Pro
+any gemini3Flash
+any gemini25Pro
+any gemini25Flash
+any gemini25FlashLite
+any gemini25ComputerUse
+any gemini25FlashAlt
}
class GoogleImageModels {
+any gemini25FlashImage
+any imagen4Generate
+any imagen4Ultra
+any imagen4Fast
}
class GoogleEmbeddingModels {
+any geminiEmbedding001
}
class ModelRouterEmbeddingModel {
-string modelId
+ModelRouterEmbeddingModel(string modelId)
+embed(string text) any
+embedMany(string[] texts) any
}
class LanceConfig {
+number embeddingDimension
+ModelRouterEmbeddingModel embeddingModel
}
class MongoConfig {
+number embeddingDimension
+ModelRouterEmbeddingModel embeddingModel
}
class QdrantConfig {
+number embeddingDimension
+ModelRouterEmbeddingModel embeddingModel
}
class Memory {
+any storage
+any vector
+ModelRouterEmbeddingModel embedder
+Memory(any storage, any vector, ModelRouterEmbeddingModel embedder)
}
GoogleConfig <|.. GoogleChatModels
GoogleConfig <|.. GoogleImageModels
GoogleConfig <|.. GoogleEmbeddingModels
GoogleEmbeddingModels o-- ModelRouterEmbeddingModel : defaultEmbedding
LanceConfig o-- ModelRouterEmbeddingModel : embeddingModel
MongoConfig o-- ModelRouterEmbeddingModel : embeddingModel
QdrantConfig o-- ModelRouterEmbeddingModel : embeddingModel
Memory o-- ModelRouterEmbeddingModel : embedder
LanceConfig ..> Memory : usedBy
MongoConfig ..> Memory : usedBy
Class diagram for agent registry and new agent/network entriesclassDiagram
class AgentFeatures {
+boolean reasoning
+boolean chainOfThought
+boolean tools
+boolean artifacts
+boolean plan
+boolean task
+boolean sources
+boolean webPreview
+boolean canvas
+boolean images
}
class AgentConfig {
+string id
+string name
+string description
+string category
+AgentFeatures features
}
class AgentRegistry {
+Record~string,AgentConfig~ AGENT_CONFIGS
+string DEFAULT_AGENT_ID
}
class GraphSupervisorAgent {
}
class TechnicalAnalysisAgent {
}
class ChartJsAgent {
}
class MappingAgent {
}
class FetchAgent {
}
class FinnhubAgent {
}
class CodeGraphAgent {
}
class CodeMetricsAgent {
}
class SocialMediaAgent {
}
class SeoAgent {
}
class TranslationAgent {
}
class CustomerSupportAgent {
}
class ProjectManagementAgent {
}
class BgColorAgent {
}
class NoteTakerAgent {
}
class A2ACoordinatorAgent {
}
class CodingA2ACoordinator {
}
class DataPipelineNetwork {
}
class ReportGenerationNetwork {
}
class ResearchPipelineNetwork {
}
class ContentCreationNetwork {
}
class FinancialIntelligenceNetwork {
}
class LearningNetwork {
}
class MarketingAutomationNetwork {
}
class DevopsNetwork {
}
class BusinessIntelligenceNetwork {
}
class SecurityNetwork {
}
AgentRegistry o-- GraphSupervisorAgent
AgentRegistry o-- TechnicalAnalysisAgent
AgentRegistry o-- ChartJsAgent
AgentRegistry o-- MappingAgent
AgentRegistry o-- FetchAgent
AgentRegistry o-- FinnhubAgent
AgentRegistry o-- CodeGraphAgent
AgentRegistry o-- CodeMetricsAgent
AgentRegistry o-- SocialMediaAgent
AgentRegistry o-- SeoAgent
AgentRegistry o-- TranslationAgent
AgentRegistry o-- CustomerSupportAgent
AgentRegistry o-- ProjectManagementAgent
AgentRegistry o-- BgColorAgent
AgentRegistry o-- NoteTakerAgent
AgentRegistry o-- A2ACoordinatorAgent
AgentRegistry o-- CodingA2ACoordinator
AgentRegistry o-- DataPipelineNetwork
AgentRegistry o-- ReportGenerationNetwork
AgentRegistry o-- ResearchPipelineNetwork
AgentRegistry o-- ContentCreationNetwork
AgentRegistry o-- FinancialIntelligenceNetwork
AgentRegistry o-- LearningNetwork
AgentRegistry o-- MarketingAutomationNetwork
AgentRegistry o-- DevopsNetwork
AgentRegistry o-- BusinessIntelligenceNetwork
AgentRegistry o-- SecurityNetwork
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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 significantly enhances the system's agent capabilities by introducing several new specialized agents and networks, ranging from financial analysis to content creation and coding. It also refines core configurations, particularly for Google AI models and embedding providers, to improve model initialization, type safety, and overall flexibility. Performance is addressed through cached content options for the weather agent and an adjusted sampling strategy in Mastra. Furthermore, the PR improves maintainability and observability by adding a Convex configuration, setting up OpenTelemetry instrumentation, and introducing new tests for agent registration. 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.
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 a substantial set of features and refactorings, including adding many new agents, updating Google model configurations, and enhancing logging. The changes generally improve the system's capabilities and maintainability. However, there are a few critical points to address: a potential package downgrade for convex, the unexplained removal of sqlAgent, and an unusual file rename of instrumentation.ts which might break OpenTelemetry setup. Additionally, there are opportunities to improve type safety, code cleanliness by removing commented-out blocks, and consistency in configuration usage and logging.
I am having trouble creating individual review comments. Click here to see my feedback.
package.json (132)
The convex package appears to have been downgraded from version 1.31.4 to 1.26.2. This is unusual and could potentially introduce bugs or compatibility issues. Was this downgrade intentional? If so, could you please provide some context?
app/chat/components/agent-tools.tsx (313)
For better type safety, you should cast the output prop to its specific type, WeatherUITool['output'], instead of any. This aligns with the other type-safe changes made in this component.
output={latest.output as WeatherUITool['output']}
app/chat/components/agent-tools.tsx (319)
Similar to the WeatherCard, the output prop for ForecastView should be cast to WeatherUITool['output'] instead of any to improve type safety.
output={latest.output as WeatherUITool['output']}
app/chat/components/agent-tools.tsx (326-340)
This block of code for NewsCarousel is commented out. If this functionality is no longer needed, it's better to remove the dead code rather than leaving it commented out. This improves code readability and maintainability.
app/chat/components/agent-tools.tsx (354-364)
This block of code for SearchResultList is commented out. To keep the codebase clean, it's best to remove this dead code if it's no longer in use.
app/chat/config/agents.ts (605-612)
I noticed that the sqlAgent has been removed in this pull request. This seems like a significant change that wasn't mentioned in the PR description. Could you please confirm if this removal was intentional? If it's no longer needed, it might be good to mention it in the description for clarity.
src/mastra/config/qdrant.ts (141)
The embedding model is hardcoded here, but the QDRANT_CONFIG object at the top of the file also defines an embeddingModel. This creates an inconsistency. To improve maintainability, you should update the embeddingModel in QDRANT_CONFIG and reference it here.
Example update to the config:
const QDRANT_CONFIG = {
// ... other properties
embeddingModel: new ModelRouterEmbeddingModel('google/gemini-embedding-001'),
} as const model: QDRANT_CONFIG.embeddingModel,
src/mastra/config/qdrant.ts (263)
Similar to the processDocument function, the embedding model is hardcoded here. It would be better to update the embeddingModel in the QDRANT_CONFIG object and reference it here for consistency.
model: QDRANT_CONFIG.embeddingModel,
src/mastra/tools/weather-tool.ts (57)
Logging toolCallId as a boolean (toolCallId.includes('get-weather')) reduces the usefulness of this log message for tracing and debugging. It would be more informative to log the full toolCallId string.
toolCallId: toolCallId,
src/mastra/tools/weather-tool.ts (65)
The toolCallId is being logged as a boolean here. For better traceability, please consider logging the full toolCallId string instead.
toolCallId: toolCallId,
src/mastra/tools/weather-tool.ts (74)
The toolCallId is being logged as a boolean here. For better traceability, please consider logging the full toolCallId string instead.
toolCallId: toolCallId,
src/mastra/tools/weather-tool.ts (274)
The toolCallId is being logged as a boolean here. For better traceability, please consider logging the full toolCallId string instead.
toolCallId: toolCallId,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - I've found 5 issues, and left some high level feedback:
- In
weather-tool.tsthe logging now recordstoolCallId: toolCallId.includes('get-weather'), which replaces the actual ID with a boolean and makes tracing individual tool calls much harder; consider logging the realtoolCallIdand, if needed, an additionalisWeatherCallflag. - In the LanceDB, MongoDB, and Qdrant config files you switched to
new ModelRouterEmbeddingModel('google/gemini-embedding-001')but did not add an import forModelRouterEmbeddingModel, which will cause build/runtime errors; bring in the appropriate import from its package. - In
AgentToolstheNewsCarouselandSearchResultListrendering blocks forserpapi-*andfinnhub-company-newstools are fully commented out, effectively disabling those tool UIs while leaving the components and tool handlers in place—if this is intentional, consider adding a clear TODO or feature flag, otherwise re-enable or remove them to avoid confusing partial integration.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `weather-tool.ts` the logging now records `toolCallId: toolCallId.includes('get-weather')`, which replaces the actual ID with a boolean and makes tracing individual tool calls much harder; consider logging the real `toolCallId` and, if needed, an additional `isWeatherCall` flag.
- In the LanceDB, MongoDB, and Qdrant config files you switched to `new ModelRouterEmbeddingModel('google/gemini-embedding-001')` but did not add an import for `ModelRouterEmbeddingModel`, which will cause build/runtime errors; bring in the appropriate import from its package.
- In `AgentTools` the `NewsCarousel` and `SearchResultList` rendering blocks for `serpapi-*` and `finnhub-company-news` tools are fully commented out, effectively disabling those tool UIs while leaving the components and tool handlers in place—if this is intentional, consider adding a clear TODO or feature flag, otherwise re-enable or remove them to avoid confusing partial integration.
## Individual Comments
### Comment 1
<location> `src/mastra/tools/weather-tool.ts:56-57` </location>
<code_context>
onInputStart: ({ toolCallId, messages, abortSignal }) => {
log.info('Weather tool input streaming started', {
- toolCallId,
+ toolCallId: toolCallId.includes('get-weather'),
messageCount: messages.length,
hook: 'onInputStart',
</code_context>
<issue_to_address>
**issue (bug_risk):** Logging `toolCallId.includes('get-weather')` instead of the actual `toolCallId` is likely a bug and loses useful context.
This change makes `toolCallId` a boolean in several hooks (`onInputStart`, `onInputDelta`, `onInputAvailable`, `onOutput`), changing the field’s meaning and making it harder to trace specific calls. To keep both behaviors, keep `toolCallId` as the original string and add a separate field, e.g. `isWeatherToolCall: toolCallId.includes('get-weather')`.
</issue_to_address>
### Comment 2
<location> `app/chat/components/agent-tools.tsx:326` </location>
<code_context>
)
}
- if (
- (toolName === 'serpapi-news-trends' ||
- toolName === 'finnhub-company-news') &&
- hasOutput
- ) {
- return (
- <NewsCarousel
- key={`${id}-${toolName}-${toolState}-${groupIdx}`}
- toolCallId={id}
- input={latest.input as any}
- output={latest.output as any}
- errorText={errorText}
- />
- )
- }
+ // if (
+ // (toolName === 'serpapi-news-trends' ||
+ // toolName === 'finnhub-company-news') &&
</code_context>
<issue_to_address>
**question (bug_risk):** Commenting out the SerpAPI/Finnhub news and search UI branches changes UX and may be an unintentional regression.
`NewsCarousel` and `SearchResultList` handling for `serpapi-news-trends`, `finnhub-company-news`, and `serpapi-search` is now entirely commented out, so those tool calls will use the generic renderer instead, changing the UI. If this is intentional, consider a feature flag or explicit runtime check rather than commenting out code; if not, it’s likely an accidental regression to revert or adjust.
</issue_to_address>
### Comment 3
<location> `src/mastra/config/qdrant.ts:140-141` </location>
<code_context>
// Generate embeddings for all chunks
const { embeddings } = await embedMany({
values: chunks.map((chunk) => chunk.text),
- model: QDRANT_CONFIG.embeddingModel,
+ model: new ModelRouterEmbeddingModel('google/gemini-embedding-001'),
})
</code_context>
<issue_to_address>
**suggestion:** Embedding model configuration is now duplicated instead of reusing `QDRANT_CONFIG.embeddingModel`.
You’re now instantiating `new ModelRouterEmbeddingModel('google/gemini-embedding-001')` inline in multiple places while `QDRANT_CONFIG.embeddingModel` is still defined but unused. This risks config drift and adds unnecessary construction overhead. Consider either making `QDRANT_CONFIG.embeddingModel` the shared `ModelRouterEmbeddingModel` instance and reusing it, or removing the config field and centralizing the model selection in one shared constant.
Suggested implementation:
```typescript
// Generate embeddings for all chunks
const { embeddings } = await embedMany({
values: chunks.map((chunk) => chunk.text),
model: QDRANT_CONFIG.embeddingModel,
})
```
1. Ensure that `QDRANT_CONFIG.embeddingModel` is defined as a shared instance of `ModelRouterEmbeddingModel('google/gemini-embedding-001')` (or the desired router model) somewhere in this file, e.g.:
- `embeddingModel: new ModelRouterEmbeddingModel('google/gemini-embedding-001'),`
2. If there are other call sites in this file (or others) that also use `new ModelRouterEmbeddingModel('google/gemini-embedding-001')` inline, they should similarly be updated to use `QDRANT_CONFIG.embeddingModel` to keep configuration centralized.
</issue_to_address>
### Comment 4
<location> `src/mastra/config/lance.ts:22-23` </location>
<code_context>
embeddingDimension: parseInt(
process.env.LANCE_EMBEDDING_DIMENSION ?? '1536'
),
- embeddingModel: google.textEmbedding('gemini-embedding-001'),
+ embeddingModel: new ModelRouterEmbeddingModel('google/gemini-embedding-001'),
} as const
</code_context>
<issue_to_address>
**suggestion (performance):** Consider reusing a single `ModelRouterEmbeddingModel` instance rather than constructing it in multiple places.
In Lance, Mongo, and Qdrant you construct `new ModelRouterEmbeddingModel('google/gemini-embedding-001')` separately for `embeddingModel` and `embedder`. If this class is stateful or uses internal caches, consider creating a single shared instance (e.g. `const geminiEmbeddingModel = new ModelRouterEmbeddingModel('google/gemini-embedding-001')`) and reusing it to avoid redundant setup and keep configuration aligned across backends.
</issue_to_address>
### Comment 5
<location> `src/mastra/config/google.ts:41` </location>
<code_context>
// Image Generation Models
export const googleImageModels = {
// Gemini Flash Image model
- gemini25FlashImage: google('gemini-2.5-flash-image'),
- gemini3ProImage: google('gemini-3-pro-image-preview'),
+ gemini25FlashImage: google.languageModel('gemini-2.5-flash-image'),
+ // gemini3ProImage: google('gemini-3-pro-image-preview'),
// Imagen 4.0 models
</code_context>
<issue_to_address>
**issue (bug_risk):** Using `languageModel` for an image model name could be confusing and might not match the intended API.
`gemini25FlashImage` is now created via `google.languageModel('gemini-2.5-flash-image')` while other image models use `google.image(...)`. If this is intended for image generation, it should likely be constructed with `google.image` for consistency and to ensure it works correctly in image-generation flows.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| ) | ||
| } | ||
|
|
||
| if ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question (bug_risk): Commenting out the SerpAPI/Finnhub news and search UI branches changes UX and may be an unintentional regression.
NewsCarousel and SearchResultList handling for serpapi-news-trends, finnhub-company-news, and serpapi-search is now entirely commented out, so those tool calls will use the generic renderer instead, changing the UI. If this is intentional, consider a feature flag or explicit runtime check rather than commenting out code; if not, it’s likely an accidental regression to revert or adjust.
| embeddingModel: google.textEmbedding('gemini-embedding-001'), | ||
| embeddingModel: new ModelRouterEmbeddingModel('google/gemini-embedding-001'), | ||
| } as const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (performance): Consider reusing a single ModelRouterEmbeddingModel instance rather than constructing it in multiple places.
In Lance, Mongo, and Qdrant you construct new ModelRouterEmbeddingModel('google/gemini-embedding-001') separately for embeddingModel and embedder. If this class is stateful or uses internal caches, consider creating a single shared instance (e.g. const geminiEmbeddingModel = new ModelRouterEmbeddingModel('google/gemini-embedding-001')) and reusing it to avoid redundant setup and keep configuration aligned across backends.
| // Image Generation Models | ||
| export const googleImageModels = { | ||
| // Gemini Flash Image model | ||
| gemini25FlashImage: google('gemini-2.5-flash-image'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (bug_risk): Using languageModel for an image model name could be confusing and might not match the intended API.
gemini25FlashImage is now created via google.languageModel('gemini-2.5-flash-image') while other image models use google.image(...). If this is intended for image generation, it should likely be constructed with google.image for consistency and to ensure it works correctly in image-generation flows.
There was a problem hiding this 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 includes multiple refactoring improvements, configuration updates, and infrastructure additions to enhance the Mastra-based AI application. The changes focus on standardizing model initialization patterns, improving observability, and expanding agent capabilities.
Changes:
- Refactored Google AI SDK and embedding model initialization to use standardized methods (
languageModel(),embedding()) andModelRouterEmbeddingModelclass - Enhanced observability by adding OpenTelemetry instrumentation setup and increasing sampling probability from 0.5 to 0.75
- Expanded agent registry with 19 new agents and networks, adding comprehensive test coverage for agent configuration
Reviewed changes
Copilot reviewed 17 out of 19 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| types/instrumentation--nn.ts | Added OpenTelemetry SDK configuration for distributed tracing |
| tests/agents-config.test.ts | Created test suite to verify agent registry completeness |
| src/mastra/tools/weather-tool.ts | Modified logging to use boolean check instead of raw toolCallId |
| src/mastra/public/storage/key_value_stores/default/SDK_SESSION_POOL_STATE.json | Updated crawler session state with new session IDs and timestamps |
| src/mastra/public/storage/key_value_stores/default/SDK_CRAWLER_STATISTICS_0.json | Refreshed crawler metrics with current run statistics |
| src/mastra/index.ts | Increased telemetry sampling from 50% to 75% with outdated comment |
| src/mastra/config/qdrant.ts | Switched to ModelRouterEmbeddingModel for embedding generation |
| src/mastra/config/mongodb.ts | Standardized embedding model initialization pattern |
| src/mastra/config/lance.ts | Applied consistent ModelRouterEmbeddingModel usage |
| src/mastra/config/google.ts | Migrated to new Google SDK method names and commented unused code |
| src/mastra/agents/weather-agent.ts | Added cachedContent configuration option |
| package.json | Updated dependencies (@ai-sdk/react, @next/*, convex) and formatting |
| convex/schema.ts | Updated import source and reformatted for consistency |
| convex.json | Added Convex framework configuration file |
| app/chat/providers/chat-context-types.ts | Added comment for isFocusMode documentation |
| app/chat/config/agents.ts | Added 19 new agents/networks and applied consistent string literal syntax |
| app/chat/components/chat-input.tsx | Minor whitespace formatting changes |
| app/chat/components/agent-tools.tsx | Improved type safety and commented out unused tool renderers |
| onInputStart: ({ toolCallId, messages, abortSignal }) => { | ||
| log.info('Weather tool input streaming started', { | ||
| toolCallId, | ||
| toolCallId: toolCallId.includes('get-weather'), |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logging transformation changes toolCallId from a string identifier to a boolean value. This breaks the purpose of logging the tool call ID, which should be a unique identifier for tracing. Instead of logging whether the ID contains 'get-weather', the actual toolCallId string should be logged for proper request tracing and debugging.
| onInputDelta: ({ inputTextDelta, toolCallId, messages, abortSignal }) => { | ||
| log.info('Weather tool received input chunk', { | ||
| toolCallId, | ||
| toolCallId: toolCallId.includes('get-weather'), |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue as Comment 1: The boolean check replaces the actual toolCallId string, preventing proper correlation of log entries for this tool invocation.
| onInputAvailable: ({ input, toolCallId, messages, abortSignal }) => { | ||
| log.info('Weather tool received input', { | ||
| toolCallId, | ||
| toolCallId: toolCallId.includes('get-weather'), |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue as Comment 1: The boolean check replaces the actual toolCallId string, preventing proper correlation of log entries for this tool invocation.
| onOutput: ({ output, toolCallId, toolName, abortSignal }) => { | ||
| log.info('Weather tool completed', { | ||
| toolCallId, | ||
| toolCallId: toolCallId.includes('get-weather'), |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue as Comment 1: The boolean check replaces the actual toolCallId string, preventing proper correlation of log entries for this tool invocation.
| toolCallId: toolCallId.includes('get-weather'), | |
| toolCallId, | |
| isGetWeatherCall: toolCallId.includes('get-weather'), |
| type: SamplingStrategyType.RATIO, | ||
| probability: 0.5, | ||
| probability: 0.75, | ||
| }, // 50% sampling |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inline comment states '50% sampling' but the probability is set to 0.75 (75%). The comment should be updated to match the actual value: '// 75% sampling'.
| }, // 50% sampling | |
| }, // 75% sampling |
| includeThoughts: true, | ||
| thinkingBudget: -1, | ||
| }, | ||
| cachedContent: "Location data cached for weather queries", |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cachedContent property appears to be a string description, but the Google Generative AI API's cachedContent feature typically expects a cache configuration object or reference, not a descriptive string. This may not function as intended and could cause runtime errors or be silently ignored. Verify the correct usage in the @ai-sdk/google documentation.
| cachedContent: "Location data cached for weather queries", |
| export const AGENT_CONFIGS: Record<string, AgentConfig> = { | ||
| // Core Agents | ||
| weatherAgent: { | ||
| "weatherAgent": { |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrapping object keys in quotes when they are valid JavaScript identifiers is unnecessary and inconsistent with typical TypeScript/JavaScript style. While not incorrect, this change adds visual noise and deviates from the codebase's previous style without apparent benefit.
| import { embedMany } from 'ai' | ||
| import type { UIMessage } from 'ai' | ||
| import { log } from './logger' | ||
| import z from 'zod' |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'z' is defined but never used.
| import z from 'zod' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 14
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (7)
src/mastra/agents/weather-agent.ts (2)
80-83: Remove commented-out code.Per coding guidelines, commented-out code should be removed rather than left in place. Use version control history if this configuration is needed later.
🧹 Proposed fix
maxRetries: 5, - - // defaultOptions: { -// autoResumeSuspendedTools: true, - // }, })
42-50:cachedContentmust be a cached content resource ID, not a descriptive string.The
cachedContentvalue should be a fully-qualified cached content resource name returned from Google's cachedContents API (format:projects/{PROJECT_NUMBER}/locations/{LOCATION}/cachedContents/{CACHE_ID}), not a descriptive string. The current placeholder string will cause the API to reject the request.First create cached content via the Google AI API, then reference the returned resource ID.
src/mastra/tools/weather-tool.ts (2)
63-80: Same boolean logging issue in onInputDelta and onInputAvailable.Apply the same fix to these lifecycle hooks to preserve the actual
toolCallIdvalue.🐛 Proposed fix
onInputDelta: ({ inputTextDelta, toolCallId, messages, abortSignal }) => { log.info('Weather tool received input chunk', { - toolCallId: toolCallId.includes('get-weather'), + toolCallId, inputTextDelta, abortSignal: abortSignal?.aborted, messageCount: messages.length, hook: 'onInputDelta', }) }, onInputAvailable: ({ input, toolCallId, messages, abortSignal }) => { log.info('Weather tool received input', { - toolCallId: toolCallId.includes('get-weather'), + toolCallId, messageCount: messages.length, inputData: { location: input.location }, abortSignal: abortSignal?.aborted, hook: 'onInputAvailable', }) },
272-285: Same boolean logging issue in onOutput.🐛 Proposed fix
onOutput: ({ output, toolCallId, toolName, abortSignal }) => { log.info('Weather tool completed', { - toolCallId: toolCallId.includes('get-weather'), + toolCallId, toolName, outputData: { location: output.location, temperature: output.temperature, unit: output.unit, conditions: output.conditions, }, hook: 'onOutput', abortSignal: abortSignal?.aborted, }) },app/chat/components/agent-tools.tsx (1)
304-324: Inconsistent type casting: output still usesany.The
inputprop is properly typed asWeatherUITool['input'], butoutputstill usesany. Apply consistent typing for both props.♻️ Proposed fix
<WeatherCard toolCallId={id} input={latest.input as WeatherUITool['input']} - output={latest.output as any} + output={latest.output as WeatherUITool['output']} errorText={errorText} /> <ForecastView toolCallId={id} input={latest.input as WeatherUITool['input']} - output={latest.output as any} + output={latest.output as WeatherUITool['output']} errorText={errorText} />src/mastra/config/lance.ts (2)
46-46: Replace hardcoded placeholder path with configuration.The path
'/path/to/db'is a placeholder that will cause runtime failures or unexpected behavior. UseLANCE_CONFIG.dbPathor another environment-based configuration.🐛 Proposed fix
-const vectorStore = await LanceVectorStore.create('/path/to/db') +const vectorStore = await LanceVectorStore.create(LANCE_CONFIG.dbPath)
231-243: Type mismatch:options.modelisstringbutLANCE_CONFIG.embeddingModelisModelRouterEmbeddingModel.The function signature declares
options.modelasstring | undefined, but line 239 falls back toLANCE_CONFIG.embeddingModel, which is now aModelRouterEmbeddingModelinstance. This will cause a type error or unexpected behavior whenembedManyreceives an incompatible type.🐛 Proposed fix
Update the function signature and logic to handle the embedding model properly:
export async function generateEmbeddings( texts: string[], options: { - model?: string + model?: typeof LANCE_CONFIG.embeddingModel dimensions?: number } = {} ): Promise<number[][]> { try { const model = options.model ?? LANCE_CONFIG.embeddingModel
🤖 Fix all issues with AI agents
In `@app/chat/components/agent-tools.tsx`:
- Around line 326-340: Remove the commented-out UI blocks for NewsCarousel and
SearchResultList in the agent-tools.tsx component: delete the commented code
that references NewsCarousel (the block containing key
`${id}-${toolName}-${toolState}-${groupIdx}`, toolCallId, input, output,
errorText) and the similar commented SearchResultList block (the other commented
range noted); keep the surrounding logic intact and rely on git history if
restoration is needed.
In `@app/chat/config/agents.ts`:
- Around line 732-738: The agent definition for "daneChangeLog" has a mismatched
id vs name/description; update the name and description to reflect changelog
functionality (e.g., change name to "Dane Changelog" or "Dane Changelog
Publisher" and description to "Generate and publish changelogs for packages" or
similar) so the id `daneChangeLog` matches the agent purpose, keeping the
existing category and features intact.
In `@app/chat/providers/chat-context-types.ts`:
- Around line 103-104: The dangling comment refers to a missing state flag for
agent switching; add a boolean property named isAgentSwitching to the chat
context/type (e.g., the ChatContext/ChatState or ChatContextType interface in
chat-context-types.ts) and ensure the ChatProvider/createChatContext initializer
sets a default (false) and any setters/useEffects update it where agent switches
occur; alternatively, if the flag is not needed, remove the orphaned comment.
In `@src/mastra/config/google.ts`:
- Line 78: Remove the dead commented-out export line for googleNanoBanana (the
line "//export const googleNanoBanana = googleImageModels.gemini3ProImage // Pro
image") from the file so no stray commented exports remain; search for any other
commented exports named googleNanoBanana and delete them, leaving only active
exports and documentation.
- Line 2: Remove the commented-out import for logError in the google.ts file;
locate the line containing "//import { logError } from './logger'" and delete it
so no unused or commented import remains, relying on VCS to recover if needed.
- Line 51: The config uses google.embedding() for geminiEmbedding001 which is
inconsistent with other configs that call google.textEmbedding(); update this
file to use google.textEmbedding('gemini-embedding-001') so the symbol
geminiEmbedding001 and the call site match the rest of the codebase (or
alternatively change all other references to google.embedding()—but apply the
simpler fix: revert google.embedding() to google.textEmbedding() in this file).
- Around line 41-42: Remove the commented-out gemini3ProImage line to eliminate
dead code; delete the line referencing gemini3ProImage and, if you need to note
its unavailability or deprecation, add a brief comment or note in the project
documentation (e.g., README or changelog) instead of leaving an inline commented
config; ensure the remaining config key gemini25FlashImage and its call to
google.languageModel('gemini-2.5-flash-image') remain unchanged.
- Around line 23-35: The model registrations (e.g., gemini3Pro, gemini3Flash,
gemini25Pro, gemini25Flash, gemini25FlashLite, gemini25ComputerUse,
gemini25FlashAlt) incorrectly call google.languageModel(...); replace each call
with the `@ai-sdk/google` factory function form google('model-id') (for example
google('gemini-3-pro-preview')) so each symbol is assigned the LanguageModel
returned by google(...) instead of the non-existent google.languageModel(...)
method.
In `@src/mastra/config/qdrant.ts`:
- Around line 261-264: The embedMany call currently constructs a new
ModelRouterEmbeddingModel('google/gemini-embedding-001') which duplicates
processDocument and breaks vector compatibility; replace that inline
ModelRouterEmbeddingModel usage with the shared embedding model constant used
elsewhere (the same constant referenced by processDocument, e.g.,
SHARED_EMBEDDING_MODEL or EMBEDDING_MODEL), update any imports or references so
embedMany({ model: ... }) uses that shared constant, and ensure embedMany,
ModelRouterEmbeddingModel, and processDocument now all rely on the same shared
embedding model symbol.
- Around line 139-142: processDocument is instantiating new
ModelRouterEmbeddingModel('google/gemini-embedding-001') while qdrantQueryTool
and qdrantGraphTool use QDRANT_CONFIG.embeddingModel, risking vector-space
mismatch and extra allocations; extract a single shared embedding model instance
(e.g., EMBEDDING_MODEL = new
ModelRouterEmbeddingModel('google/gemini-embedding-001') or set
QDRANT_CONFIG.embeddingModel to that instance) and replace the inline new
ModelRouterEmbeddingModel call in processDocument and any uses in
querySimilarDocuments/qdrantQueryTool/qdrantGraphTool so all functions use the
same QDRANT_CONFIG.embeddingModel constant.
In `@src/mastra/index.ts`:
- Around line 435-437: Remove the commented-out instantiation of RequestContext
or implement it: if you need a per-request context, replace the commented line
with runtime creation of a RequestContext instance passed into the route
configuration (e.g., ensure the route option key requestContext receives a new
RequestContext() for each request using the appropriate middleware or factory),
otherwise delete the commented block entirely and open an issue referencing
RequestContext to track the requirement; locate the commented lines around the
requestContext key and update either the route setup to instantiate
RequestContext per request or remove the comment.
- Around line 293-296: The inline comment "// 50% sampling" is stale and does
not match the configured sampling.probability of 0.75 in the sampling block
using SamplingStrategyType.RATIO; update the comment to reflect 75% sampling or
remove the comment entirely so it no longer contradicts the actual configuration
in the sampling object (sampling.probability and SamplingStrategyType.RATIO).
In `@src/mastra/tools/weather-tool.ts`:
- Around line 55-61: The log in onInputStart incorrectly records toolCallId as a
boolean by calling toolCallId.includes('get-weather'); change the logged field
to the actual identifier by passing toolCallId itself (e.g., log.info(..., {
toolCallId, messageCount: messages.length, hook: 'onInputStart', abortSignal:
abortSignal?.aborted })) so the real ID is preserved for tracing and debugging.
In `@tests/agents-config.test.ts`:
- Around line 35-40: Replace the manual loop that checks each id with a single
assertion using Jest's expect.arrayContaining so failures list all missing IDs
at once; specifically, in the test that calls getAllAgentIds() and iterates
expectedIds, remove the for-loop and assert that the returned ids array contains
arrayContaining(expectedIds) (use
expect(ids).toEqual(expect.arrayContaining(expectedIds)) or equivalent)
referencing the getAllAgentIds call and the expectedIds variable.
📜 Review details
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (18)
app/chat/components/agent-tools.tsxapp/chat/components/chat-input.tsxapp/chat/config/agents.tsapp/chat/providers/chat-context-types.tsconvex.jsonconvex/schema.tspackage.jsonsrc/mastra/agents/weather-agent.tssrc/mastra/config/google.tssrc/mastra/config/lance.tssrc/mastra/config/mongodb.tssrc/mastra/config/qdrant.tssrc/mastra/index.tssrc/mastra/public/storage/key_value_stores/default/SDK_CRAWLER_STATISTICS_0.jsonsrc/mastra/public/storage/key_value_stores/default/SDK_SESSION_POOL_STATE.jsonsrc/mastra/tools/weather-tool.tstests/agents-config.test.tstypes/instrumentation--nn.ts
🧰 Additional context used
📓 Path-based instructions (42)
**/*.{js,ts,tsx,jsx,py,java,cs,go,rb,php,swift,kt}
📄 CodeRabbit inference engine (.github/instructions/code-review-generic.instructions.md)
**/*.{js,ts,tsx,jsx,py,java,cs,go,rb,php,swift,kt}: Use descriptive and meaningful names for variables, functions, and classes
Apply Single Responsibility Principle: each function/class should do one thing well
Avoid code duplication (DRY principle)
Keep functions small and focused, ideally under 20-30 lines
Avoid deeply nested code with maximum 3-4 levels of nesting
Avoid magic numbers and strings; use named constants instead
Code should be self-documenting; use comments only when necessary for non-obvious logic
Implement proper error handling at appropriate levels with meaningful error messages
Avoid silent failures and ignored exceptions; fail fast and validate inputs early
Use appropriate error types/exceptions rather than generic error handling
Validate and sanitize all user inputs
Use parameterized queries to prevent SQL injection; never use string concatenation for SQL
Implement proper authentication checks before accessing resources
Verify users have proper authorization permissions before allowing actions
Use established cryptography libraries; never implement custom cryptographic algorithms
Avoid N+1 query problems; use proper indexing and eager loading strategies
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
Implement pagination for large result sets
Load data only when needed (lazy loading)
Document all public APIs with clear purpose, parameters, and return values
Include explanatory comments for complex logic that is not immediately obvious
Files:
app/chat/providers/chat-context-types.tstests/agents-config.test.tssrc/mastra/config/mongodb.tssrc/mastra/tools/weather-tool.tssrc/mastra/config/qdrant.tsapp/chat/components/chat-input.tsxsrc/mastra/agents/weather-agent.tssrc/mastra/index.tsapp/chat/components/agent-tools.tsxsrc/mastra/config/lance.tssrc/mastra/config/google.tsapp/chat/config/agents.tsconvex/schema.ts
**/*.{js,ts,tsx,jsx,py,java,cs,go,rb,php,swift,kt,json,yaml,yml,env,properties,xml}
📄 CodeRabbit inference engine (.github/instructions/code-review-generic.instructions.md)
Never include passwords, API keys, tokens, or personally identifiable information (PII) in code or logs
Files:
app/chat/providers/chat-context-types.tstests/agents-config.test.tsconvex.jsonsrc/mastra/config/mongodb.tssrc/mastra/public/storage/key_value_stores/default/SDK_CRAWLER_STATISTICS_0.jsonsrc/mastra/tools/weather-tool.tssrc/mastra/config/qdrant.tsapp/chat/components/chat-input.tsxsrc/mastra/agents/weather-agent.tssrc/mastra/index.tsapp/chat/components/agent-tools.tsxsrc/mastra/config/lance.tssrc/mastra/config/google.tssrc/mastra/public/storage/key_value_stores/default/SDK_SESSION_POOL_STATE.jsonapp/chat/config/agents.tsconvex/schema.tspackage.json
app/**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)
Use the
app/directory structure (Next.js 13+) as the recommended approach for new projects, organizing routes withpage.tsx,layout.tsx,loading.tsx,error.tsx,route.tsfiles, and dynamic segments using brackets
Files:
app/chat/providers/chat-context-types.tsapp/chat/components/chat-input.tsxapp/chat/components/agent-tools.tsxapp/chat/config/agents.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)
**/*.{ts,tsx,js,jsx}: Usenext/dynamicfor lazy loading components to improve initial load time (e.g.,dynamic(() => import('../components/MyComponent')))
Use React Context, Zustand, Jotai, or Recoil for managing global state instead of Redux for smaller Next.js projects
Avoid over-fetching data—only fetch the data that is needed by the component
Avoid blocking the main thread with long-running synchronous operations
Usetry...catchblocks for handling errors in asynchronous operations
Use immutable data structures and avoid mutating data directly to prevent unexpected side effects
Implement secure authentication and authorization mechanisms; avoid storing secrets in client-side code
Always validate user input on the server-side for security; use client-side validation only for immediate feedback
Configure ESLint with recommended rules for JavaScript and React, and integrate it into the build process
Centralize error logging to a service like Sentry or Bugsnag for tracking and analyzing issues
Remove unused code using tree shaking to reduce bundle size
Files:
app/chat/providers/chat-context-types.tstests/agents-config.test.tssrc/mastra/config/mongodb.tssrc/mastra/tools/weather-tool.tssrc/mastra/config/qdrant.tsapp/chat/components/chat-input.tsxsrc/mastra/agents/weather-agent.tssrc/mastra/index.tsapp/chat/components/agent-tools.tsxsrc/mastra/config/lance.tssrc/mastra/config/google.tsapp/chat/config/agents.tsconvex/schema.ts
**/{components,lib,app}/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)
Store authentication tokens securely in HTTP-only cookies or local storage
Files:
app/chat/providers/chat-context-types.tsapp/chat/components/chat-input.tsxapp/chat/components/agent-tools.tsxapp/chat/config/agents.ts
**/{components,app,pages}/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)
Use a validation library like
zodoryupfor validating user input
Files:
app/chat/providers/chat-context-types.tsapp/chat/components/chat-input.tsxapp/chat/components/agent-tools.tsxapp/chat/config/agents.ts
**/*.{ts,js}
📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)
Encrypt sensitive data at rest and in transit
Files:
app/chat/providers/chat-context-types.tstests/agents-config.test.tssrc/mastra/config/mongodb.tssrc/mastra/tools/weather-tool.tssrc/mastra/config/qdrant.tssrc/mastra/agents/weather-agent.tssrc/mastra/index.tssrc/mastra/config/lance.tssrc/mastra/config/google.tsapp/chat/config/agents.tsconvex/schema.ts
**/*.{ts,tsx,js,jsx,json,css,scss}
📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)
Use a code formatter like Prettier to automatically format code on save
Files:
app/chat/providers/chat-context-types.tstests/agents-config.test.tsconvex.jsonsrc/mastra/config/mongodb.tssrc/mastra/public/storage/key_value_stores/default/SDK_CRAWLER_STATISTICS_0.jsonsrc/mastra/tools/weather-tool.tssrc/mastra/config/qdrant.tsapp/chat/components/chat-input.tsxsrc/mastra/agents/weather-agent.tssrc/mastra/index.tsapp/chat/components/agent-tools.tsxsrc/mastra/config/lance.tssrc/mastra/config/google.tssrc/mastra/public/storage/key_value_stores/default/SDK_SESSION_POOL_STATE.jsonapp/chat/config/agents.tsconvex/schema.tspackage.json
**/{components,pages,app}/**/*
📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)
Keep related components, styles, and tests in the same directory through co-location
Files:
app/chat/providers/chat-context-types.tsapp/chat/components/chat-input.tsxapp/chat/components/agent-tools.tsxapp/chat/config/agents.ts
**/*.{js,jsx,ts,tsx,py,java,c,cpp,cs,go,rb,php,swift,kt,scala,rs}
📄 CodeRabbit inference engine (.github/instructions/self-explanatory-code-commenting.instructions.md)
**/*.{js,jsx,ts,tsx,py,java,c,cpp,cs,go,rb,php,swift,kt,scala,rs}: Avoid obvious comments that state what the code already clearly expresses (e.g., 'Increment counter by one' for counter++).
Avoid redundant comments that simply repeat what the code already expresses.
Keep comments accurate and update them when code changes to avoid outdated comments that no longer match the implementation.
Write comments that explain WHY specific calculations or business logic is implemented the way it is, especially for complex or non-obvious approaches.
Comment non-obvious algorithms to explain the algorithm choice and why it was selected for the problem.
Comment regex patterns to explain what patterns they match and their intended purpose.
Comment API constraints, rate limits, gotchas, and external dependencies to explain non-obvious external requirements.
Comment configuration constants and magic numbers to explain their source, reasoning, or constraints.
Use annotation comments (TODO, FIXME, HACK, NOTE, WARNING, PERF, SECURITY, BUG, REFACTOR, DEPRECATED) to mark code requiring attention or special consideration.
Never comment out code; remove it instead and use version control history if needed.
Avoid using changelog comments in code; maintain version history in commit messages and documentation instead.
Avoid decorative divider comments (like //====); use code organization and clear function/class names instead.
Ensure comments are grammatically correct, clear, and use professional language.
Place comments appropriately above the code they describe, not inline or after code when possible.
Files:
app/chat/providers/chat-context-types.tstests/agents-config.test.tssrc/mastra/config/mongodb.tssrc/mastra/tools/weather-tool.tssrc/mastra/config/qdrant.tsapp/chat/components/chat-input.tsxsrc/mastra/agents/weather-agent.tssrc/mastra/index.tsapp/chat/components/agent-tools.tsxsrc/mastra/config/lance.tssrc/mastra/config/google.tsapp/chat/config/agents.tsconvex/schema.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/self-explanatory-code-commenting.instructions.md)
**/*.{ts,tsx}: Use TSDoc standards for documenting public APIs in TypeScript, including@param,@returns,@throws,@example, and@seetags.
Include file headers with@fileoverview,@author,@copyright, and@licenseTSDoc tags for TypeScript files.
Document interface and type definitions with TSDoc comments explaining their purpose and usage.
Use@templatetags to document generic type parameters in TypeScript functions and types.
Document type guards with clear explanations of validation logic and return type predicates.
Comment advanced type definitions to explain their purpose and when they should be used.
**/*.{ts,tsx}: Use strict equality (eqeqeq: ['error', 'always']) — always use===and!==instead of==and!=
Require curly braces for all blocks (curly: ['error', 'all']) — even single-statement blocks must have braces
Avoid unused variables (@typescript-eslint/no-unused-vars: ['warn', {}]) — remove all unused variable declarations
Avoid explicitanytypes (@typescript-eslint/no-explicit-any: 'warn') — use proper types orunknowninstead
Use object shorthand syntax (object-shorthand: 'error') — use{ name }instead of{ name: name }
Prefer arrow functions in callbacks (prefer-arrow-callback: 'error') — use=>syntax instead of function expressions
Useconstwhen possible (prefer-const: 'warn') — preferconstoverletfor variables that are not reassigned
Preferinterfacefor type definitions (@typescript-eslint/consistent-type-definitions: ['error', 'interface']) — use interfaces for object shapes in public APIs
Useimport typefor type-only imports — always useimport type { T } from 'module'for type declarations
Use optional chaining (?.) for nullable access — useobj?.propinstead ofobj && obj.prop
Use nullish coalescing (??) for defaults — prefervalue ?? defaultValueovervalue || defaultValuefor null checks
Require explicit return types for public functions — all public function declaratio...
Files:
app/chat/providers/chat-context-types.tstests/agents-config.test.tssrc/mastra/config/mongodb.tssrc/mastra/tools/weather-tool.tssrc/mastra/config/qdrant.tsapp/chat/components/chat-input.tsxsrc/mastra/agents/weather-agent.tssrc/mastra/index.tsapp/chat/components/agent-tools.tsxsrc/mastra/config/lance.tssrc/mastra/config/google.tsapp/chat/config/agents.tsconvex/schema.ts
**/*.{ts,tsx,js,jsx,mjs,cjs,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 generation tools appropriate for the language: JSDoc/TSDoc for JavaScript/TypeScript, Sphinx/pdoc for Python, Javadoc for Java, xmldoc for C#, godoc for Go, rustdoc for Rust
Files:
app/chat/providers/chat-context-types.tstests/agents-config.test.tssrc/mastra/config/mongodb.tssrc/mastra/tools/weather-tool.tssrc/mastra/config/qdrant.tsapp/chat/components/chat-input.tsxsrc/mastra/agents/weather-agent.tssrc/mastra/index.tsapp/chat/components/agent-tools.tsxsrc/mastra/config/lance.tssrc/mastra/config/google.tsapp/chat/config/agents.tsconvex/schema.ts
app/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use Next.js 16 App Router with React 19 — organize routes under
app/with proper layout and page components
Files:
app/chat/providers/chat-context-types.tsapp/chat/components/chat-input.tsxapp/chat/components/agent-tools.tsxapp/chat/config/agents.ts
app/**/*.{css,tsx,ts}
📄 CodeRabbit inference engine (app/AGENTS.md)
Use Tailwind CSS 4 with oklch color variables for styling Next.js App Directory pages and layouts
Files:
app/chat/providers/chat-context-types.tsapp/chat/components/chat-input.tsxapp/chat/components/agent-tools.tsxapp/chat/config/agents.ts
app/chat/**/*.{ts,tsx}
📄 CodeRabbit inference engine (app/chat/AGENTS.md)
Use AI SDK v5 type imports: UIMessage, DynamicToolUIPart, TextUIPart, ReasoningUIPart with helper functions (isTextUIPart, isReasoningUIPart, isToolOrDynamicToolUIPart) instead of direct content access
Files:
app/chat/providers/chat-context-types.tsapp/chat/components/chat-input.tsxapp/chat/components/agent-tools.tsxapp/chat/config/agents.ts
app/chat/providers/**/*.{ts,tsx}
📄 CodeRabbit inference engine (app/chat/AGENTS.md)
Handle Mastra stream chunk types: text-delta, reasoning-delta (not 'reasoning'), tool-call, tool-result, source, finish in the chat streaming implementation
Files:
app/chat/providers/chat-context-types.ts
**/*.{test,spec}.{js,ts,tsx,jsx,py,java,cs,go,rb,php,swift,kt}
📄 CodeRabbit inference engine (.github/instructions/code-review-generic.instructions.md)
**/*.{test,spec}.{js,ts,tsx,jsx,py,java,cs,go,rb,php,swift,kt}: Critical paths and new functionality must have appropriate test coverage
Use descriptive test names that clearly explain what is being tested
Structure tests with clear Arrange-Act-Assert or Given-When-Then pattern
Tests should be independent and not depend on each other or external state
Use specific assertions instead of generic assertTrue/assertFalse in tests
Test boundary conditions, null values, and empty collections (edge cases)
Mock external dependencies in tests, not domain logic
Files:
tests/agents-config.test.ts
**/*.{test,spec}.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)
**/*.{test,spec}.{ts,tsx,js,jsx}: Use Jest as the testing framework for unit and integration tests
Mock external dependencies during testing to isolate components
Test edge cases and error conditions to ensure components are robust
Use Mock Service Worker (msw) to intercept and mock API calls during testing
Co-locate test files with the components they are testing
Use a consistent naming convention for test files (e.g.,ComponentName.test.jsorComponentName.spec.ts)
Organize tests by feature to improve maintainability and clarity
Files:
tests/agents-config.test.ts
src/mastra/**/*
📄 CodeRabbit inference engine (src/AGENTS.md)
mastramodules can import fromutils, but must not import fromapporcli(excepttypes)
Files:
src/mastra/config/mongodb.tssrc/mastra/public/storage/key_value_stores/default/SDK_CRAWLER_STATISTICS_0.jsonsrc/mastra/tools/weather-tool.tssrc/mastra/config/qdrant.tssrc/mastra/agents/weather-agent.tssrc/mastra/index.tssrc/mastra/config/lance.tssrc/mastra/config/google.tssrc/mastra/public/storage/key_value_stores/default/SDK_SESSION_POOL_STATE.json
src/mastra/config/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
src/mastra/config/**/*.ts: Centralize all provider clients (Google, OpenAI, Anthropic, OpenRouter, Vertex), storage configuration, and role hierarchy insrc/mastra/config
Use environment-based configuration for all secrets and provider clients — store all sensitive values in environment variables
Files:
src/mastra/config/mongodb.tssrc/mastra/config/qdrant.tssrc/mastra/config/lance.tssrc/mastra/config/google.ts
src/mastra/{tools,config}/**
📄 CodeRabbit inference engine (src/mastra/AGENTS.md)
When adding new tools or providers, add environment variable placeholders to
.envand document them insrc/mastra/config/AGENTS.md
Files:
src/mastra/config/mongodb.tssrc/mastra/tools/weather-tool.tssrc/mastra/config/qdrant.tssrc/mastra/config/lance.tssrc/mastra/config/google.ts
src/mastra/tools/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
src/mastra/tools/**/*.ts: Implement tools usingcreateTool({ id, description, inputSchema, outputSchema, execute })with strict Zod schemas — all tools must follow this pattern
Use strict Zod schemas for all tool input and output validation — defineinputSchemaandoutputSchemawith proper type inference
src/mastra/tools/**/*.ts: Create tools using thecreateToolpattern with explicit Zod schemas for input/output validation
Keep tools small and side-effect-free when possible; delegate complex orchestration to agents
Files:
src/mastra/tools/weather-tool.ts
**/*-tool.ts
📄 CodeRabbit inference engine (AGENTS.md)
Name tool implementation files with
-tool.tssuffix (e.g.,weather-tool.ts)
Files:
src/mastra/tools/weather-tool.ts
src/mastra/tools/**/*.{ts,tsx}
📄 CodeRabbit inference engine (src/mastra/tools/AGENTS.md)
src/mastra/tools/**/*.{ts,tsx}: ImportSpanTypefrom@mastra/core/observabilityandTracingContextfrom@mastra/core/observabilityto maintain consistency and compatibility across the codebase
All tools must use Mastra's tracing helpers and execution-providedtracingContextinstead of importing or using OpenTelemetry APIs directly (do NOT import@opentelemetry/api)
Define a typedRequestContextinterface extendingRequestContextfor each tool to ensure type safety and clear documentation of expected context values
Create a child span usingtracingContext?.currentSpan?.createChildSpan()withtype: SpanType.TOOL_CALLfor the primary operation and passrequestContext: context?.requestContextfor automatic metadata extraction
Includetool.id,user.id, andworkspace.idin span metadata where applicable
Emitdata-tool-progressevents at the start and completion of tool execution withstatus('in-progress' or 'done') andstagematching the tool id
RespectabortSignalearly (fail fast) in tool execution and record cancellations in spans before long-running operations
Progress event format must haveidat the top level of the object (outsidedata), not inside thedataobject
Lifecycle hooks must be declared in order:onInputStart,onInputDelta,onInputAvailablebefore theexecuteproperty, andonOutputafterexecute
All lifecycle hooks (onInputStart,onInputDelta,onInputAvailable,onOutput) must be implemented with structured logging using the Mastra logger
Uselog.info()from the Mastra logger with structured logging objects containingtoolCallId,messageCount,inputData,abortSignal, andhookproperties in lifecycle hooks
Extract typed context in execute function with pattern:const requestContext = context?.requestContext as ToolNameContext
Provide sensible defaults for optional RequestContext properties (e.g.,const temperatureUnit = requestContext?.temperatureUnit ?? 'celsius')
Update spans...
Files:
src/mastra/tools/weather-tool.ts
**/{components,src/components,ui}/**/*.{jsx,tsx}
📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)
Name components using PascalCase (e.g.,
ComponentName.jsxorComponentName.tsx)
Files:
app/chat/components/chat-input.tsxapp/chat/components/agent-tools.tsx
app/**/*.{tsx,jsx}
📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)
app/**/*.{tsx,jsx}: Use server components by default in the app directory and only use client components when interactivity (event handlers, useState, useEffect) is required
Render as much as possible on the server using server components in the app directory to reduce client-side JavaScript
Files:
app/chat/components/chat-input.tsxapp/chat/components/agent-tools.tsx
**/{components,pages,app}/**/*.{tsx,jsx}
📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)
**/{components,pages,app}/**/*.{tsx,jsx}: Usenext/imagecomponent for automatic image optimization, including lazy loading and responsive images
UseSWRorReact Queryfor client-side data fetching and caching
Usereact-hook-formfor managing forms and validation
Always usesetStateor hooks to update state; never mutate state directly
UseReact.memoto memoize components and prevent unnecessary re-renders
Never write server-side code in client components to avoid exposing secrets or causing unexpected behavior
Create reusable error boundary components and implementgetDerivedStateFromErrororcomponentDidCatchlifecycle methods
Use the<Link prefetch>tag to prefetch pages that are likely to be visited for improved performance
Minimize re-renders by only updating state when necessary to reduce the number of re-renders
Use Intersection Observer API for manual lazy loading of content beyond image and component lazy loading
Sanitize user input to prevent Cross-Site Scripting (XSS) attacks, especially when rendering HTML directly from user input
Write unit tests for individual components using React Testing Library to test from a user perspective
Separate components that handle data fetching and state management (container components) from those that only render UI (presentational components)
Favor composition over inheritance to create flexible and reusable components
Group files by feature rather than by type (e.g.,components/user-profile/instead ofcomponents/button,components/form)
Files:
app/chat/components/chat-input.tsxapp/chat/components/agent-tools.tsx
**/*.{tsx,jsx,module.css,module.scss}
📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)
Use CSS Modules, Styled Components, or Tailwind CSS for component-level styling, with Tailwind CSS preferred for rapid development
Files:
app/chat/components/chat-input.tsxapp/chat/components/agent-tools.tsx
**/*.{tsx,jsx}
📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)
**/*.{tsx,jsx}: Use complete dependency arrays inuseEffecthooks to prevent unexpected behavior and infinite loops
Clean up event listeners and timers inuseEffecthooks to avoid memory leaks
Files:
app/chat/components/chat-input.tsxapp/chat/components/agent-tools.tsx
**/{components,src/components,ui}/**/*.{tsx,jsx}
📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)
Organize components into atoms, molecules, organisms, templates, and pages using atomic design principles
Files:
app/chat/components/chat-input.tsxapp/chat/components/agent-tools.tsx
**/*.tsx
📄 CodeRabbit inference engine (AGENTS.md)
Use kebab-case for directory names containing components (e.g.,
ai-elements/,public-components/)
Files:
app/chat/components/chat-input.tsxapp/chat/components/agent-tools.tsx
app/**/*.tsx
📄 CodeRabbit inference engine (AGENTS.md)
Use Tailwind CSS 4 with oklch color variables for styling — leverage shadcn/ui base components (34 components) and AI Elements (30 components)
Define React 19 component exports in files named with .tsx extension within the app directory
Files:
app/chat/components/chat-input.tsxapp/chat/components/agent-tools.tsx
app/chat/components/**/*.{ts,tsx}
📄 CodeRabbit inference engine (app/chat/AGENTS.md)
app/chat/components/**/*.{ts,tsx}: Access message text via message.parts?.find(isTextUIPart)?.text instead of message.content
Use message.parts?.filter(isToolOrDynamicToolUIPart) to retrieve tool parts with states: input-available, output-available, output-error
Import and use specific AI Elements components: Conversation, Message, PromptInput, ModelSelector, Reasoning, Tool, Sources, Artifact, Loader, CodeBlock in their designated files
Use feature flags from agent configuration to conditionally render Reasoning, Tool, Sources, and Artifact components
Files:
app/chat/components/chat-input.tsxapp/chat/components/agent-tools.tsx
app/chat/components/chat-input.tsx
📄 CodeRabbit inference engine (app/chat/AGENTS.md)
ChatInput component must implement PromptInput with Textarea, Footer, and Submit subcomponents
Files:
app/chat/components/chat-input.tsx
src/mastra/agents/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Implement agents using
new Agent({ id, name, description, instructions, model, tools, memory })— all agents must follow this patternWire tools together into agents to create higher-level behaviors; use
RequestContextor agent-specific runtime context types (e.g.,EditorRuntimeContext) to enforce access control
Files:
src/mastra/agents/weather-agent.ts
**/*-agent.ts
📄 CodeRabbit inference engine (AGENTS.md)
Name agent implementation files with
-agent.tssuffix (e.g.,research-agent.ts)
Files:
src/mastra/agents/weather-agent.ts
src/mastra/index.ts
📄 CodeRabbit inference engine (src/AGENTS.md)
Enforce registration pattern in
mastra/index.tsfor AI orchestration modules composition
Files:
src/mastra/index.ts
app/chat/components/agent-tools.tsx
📄 CodeRabbit inference engine (app/chat/AGENTS.md)
Display tool invocations using Tool component with Header, Content, Input, and Output subcomponents when agent tools feature is enabled
Files:
app/chat/components/agent-tools.tsx
app/chat/config/agents.ts
📄 CodeRabbit inference engine (app/chat/AGENTS.md)
app/chat/config/agents.ts: Agent configuration must define features object with properties: reasoning, chainOfThought, tools, sources, canvas, artifacts, fileUpload as boolean flags
Categorize agents into: core, research, content, data, financial, diagram, or utility categories in the agent configuration
Files:
app/chat/config/agents.ts
{package.json,package-lock.json,yarn.lock,requirements.txt,requirements-*.txt,Pipfile,Pipfile.lock,build.gradle,pom.xml,*.gemfile,composer.json,Cargo.toml,go.mod,go.sum}
📄 CodeRabbit inference engine (.github/instructions/code-review-generic.instructions.md)
Keep dependencies up-to-date and monitor for known security vulnerabilities
Files:
package.json
{package.json,package-lock.json,yarn.lock}
📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)
Regularly update dependencies to patch security vulnerabilities
Files:
package.json
package.json
📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)
Use a build script to automate the build process
Files:
package.json
🧬 Code graph analysis (3)
tests/agents-config.test.ts (1)
app/chat/config/agents.ts (1)
getAllAgentIds(942-944)
src/mastra/tools/weather-tool.ts (1)
src/mastra/config/logger.ts (1)
log(16-36)
app/chat/components/agent-tools.tsx (2)
src/components/ai-elements/tools/types.ts (4)
PolygonStockQuotesUITool(277-279)ListCommitsUITool(238-238)WeatherUITool(302-302)ArxivUITool(157-157)src/mastra/tools/weather-tool.ts (1)
WeatherUITool(353-353)
⏰ 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). (5)
- GitHub Check: Sourcery review
- GitHub Check: CodeQL analysis (javascript-typescript)
- GitHub Check: Agent
- GitHub Check: Codacy Security Scan
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (23)
src/mastra/public/storage/key_value_stores/default/SDK_SESSION_POOL_STATE.json (1)
1-53: Do not commit session state files containing authentication tokens to version control.This file contains actual session cookies (NID, GSP) with authentication token values that should not be stored in the repository. Per coding guidelines, tokens and credentials must never be included in code or logs.
Session state files are ephemeral runtime artifacts and should be excluded from version control to prevent exposure of session tokens, usage patterns, and accidental credential leaks.
src/mastra/public/storage/key_value_stores/default/SDK_CRAWLER_STATISTICS_0.json (1)
1-27: These auto-generated runtime data files are already properly excluded in.gitignore.The
src/mastra/public/storage/directory and its contents are already configured to be ignored by Git:
src/mastra/public/storage/key_value_stores/default/*.jsonsrc/mastra/public/storage/key_value_stores/default/SDK_CRAWLER_STATISTICS_0.json(explicitly listed)src/mastra/public/storage/request_queues/default/*.jsonNo further
.gitignorechanges are needed. If these files are currently committed to the repository, they should be removed from tracking usinggit rm --cachedwhile keeping the local files.Likely an incorrect or invalid review comment.
src/mastra/agents/weather-agent.ts (1)
18-78: Agent implementation follows the expected pattern.The agent correctly implements the required structure with
id,name,description,instructions,model,tools, andmemory. The use ofRequestContextfor tier-based model selection and typed runtime context (WeatherRuntimeContext) is well implemented.app/chat/components/chat-input.tsx (2)
74-76: LGTM - formatting-only change.This is a whitespace adjustment with no functional impact.
127-129: LGTM - formatting-only change.This is a whitespace adjustment with no functional impact.
src/mastra/config/qdrant.ts (1)
6-6: LGTM - Import for embedding model router.The import supports the refactored embedding model initialization pattern.
convex.json (1)
1-6: No issues found. Node.js version 24 is released and available as of January 2026.package.json (2)
214-214: Zod 4 dependency with override looks correct.The Zod 4 (
^4.2.1) dependency with a matching override ensures version consistency across all dependencies. Note that Zod 4 has significant breaking changes from Zod 3 (unified error customization, stricter number validation, default value behavior changes). Ensure all schemas in the codebase are compatible with Zod 4 semantics.Also applies to: 263-263
132-132: No action needed. The convex version (^1.26.2) is compatible with the codebase. Theconvex/schema.tsfile uses standard@mastra/convextable imports and thedefineSchemaAPI fromconvex/server, both of which are supported by version 1.26.2. There is no evidence in the repository history that a downgrade occurred.Likely an incorrect or invalid review comment.
src/mastra/tools/weather-tool.ts (1)
44-53: Good addition of unit field to output.The
unitfield in the output schema and the corresponding implementation correctly formats the temperature unit for display (°Cor°F). This enhances the tool's output clarity.Also applies to: 199-202
src/mastra/config/mongodb.ts (3)
10-10: Good refactor to ModelRouterEmbeddingModel.Using
ModelRouterEmbeddingModelprovides a flexible abstraction layer for embedding model selection. The model identifier'google/gemini-embedding-001'follows the expected router format.Also applies to: 27-27
68-72: Memory embedder refactored consistently.The
mongoMemoryconfiguration now usesModelRouterEmbeddingModelfor the embedder, maintaining consistency with theMONGODB_CONFIG.embeddingModelpattern used elsewhere in this file.
1-11: Imports are well-organized.The import structure follows the coding guidelines: external framework imports first, then type imports, then internal imports. The addition of
ModelRouterEmbeddingModelfrom@mastra/core/llmis properly placed.app/chat/components/agent-tools.tsx (2)
281-290: Good type safety improvements.Replacing
anycasts with specificUITooltypes (PolygonStockQuotesUITool,ListCommitsUITool,ArxivUITool) improves type safety and catches potential prop mismatches at compile time.Also applies to: 292-302, 342-352
43-43: Remove redundantWeatherUITooltype export fromsrc/mastra/tools/weather-tool.ts.
WeatherUIToolis exported from bothsrc/mastra/tools/weather-tool.ts(line 353) andsrc/components/ai-elements/tools/types.ts(line 302). Both reference the sameweatherToolconstant and produce identical types. The definition intypes.tsserves as the unified UI tool type interface; remove the duplicate export fromweather-tool.tsto follow the DRY principle.convex/schema.ts (1)
1-22: Import consolidation is correct; verify exports at build time.The schema imports are consolidated from
@mastra/convex, with all 8 table definitions properly imported and mapped to their corresponding table names. No stale imports from the previous@mastra/convex/schemapath remain in the codebase. These imports will be validated by the TypeScript compiler at build time; if the exports don't exist in@mastra/convex@0.1.0-beta.8, the build will fail with clear import errors.src/mastra/config/lance.ts (2)
7-7: LGTM on the ModelRouterEmbeddingModel integration.The consistent use of
ModelRouterEmbeddingModel('google/gemini-embedding-001')acrossLANCE_CONFIG.embeddingModelandlanceMemory.embedderaligns with the PR's goal of standardizing embedding model resolution via a router pattern.Also applies to: 23-23, 54-54
3-3: Remove unusedAfter switching to
ModelRouterEmbeddingModel, the@ai-sdk/googleis unused in this file. Remove it to keep imports clean.♻️ Suggested fix
-import { google } from '@ai-sdk/google'app/chat/config/agents.ts (4)
344-441: LGTM on new graphing/analysis and coding agents.The new agents (
graphSupervisorAgent,technicalAnalysisAgent,chartJsAgent,mappingAgent,fetchAgent,finnhubAgent,codeGraphAgent,codeMetricsAgent) are well-structured with appropriate categories and feature flags. The placement underfinancial,diagram,utility, andcodingcategories is logical.
443-491: LGTM on marketing and support agents.The
socialMediaAgent,seoAgent,translationAgent,customerSupportAgent, andprojectManagementAgentconfigurations follow the established pattern with appropriate feature flags for their use cases.
768-817: LGTM on misc utility and A2A coordinator agents.The
bgColorAgent,noteTakerAgent,a2aCoordinatorAgent, andcodingA2ACoordinatoragents are well-defined with sensible feature configurations for their respective purposes.
819-889: LGTM on network orchestration entries.The network configurations (
dataPipelineNetwork,reportGenerationNetwork, etc.) consistently enablechainOfThoughtandtoolsfeatures, which is appropriate for orchestration agents. Categories are correctly assigned based on the network's domain.tests/agents-config.test.ts (1)
1-41: LGTM on the new test coverage.This test effectively validates that the newly added agents and networks are properly registered in
AGENT_CONFIGS. The test is well-structured, independent, and follows the testing guidelines.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
| // if ( | ||
| // (toolName === 'serpapi-news-trends' || | ||
| // toolName === 'finnhub-company-news') && | ||
| // hasOutput | ||
| // ) { | ||
| // return ( | ||
| // <NewsCarousel | ||
| // key={`${id}-${toolName}-${toolState}-${groupIdx}`} | ||
| // toolCallId={id} | ||
| // input={latest.input as any} | ||
| // output={latest.output as any} | ||
| // errorText={errorText} | ||
| // /> | ||
| // ) | ||
| // } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Remove commented-out code.
Per coding guidelines: "Never comment out code; remove it instead and use version control history if needed." These commented blocks for NewsCarousel and SearchResultList should be deleted.
♻️ Proposed fix - remove commented code
- // if (
- // (toolName === 'serpapi-news-trends' ||
- // toolName === 'finnhub-company-news') &&
- // hasOutput
- // ) {
- // return (
- // <NewsCarousel
- // key={`${id}-${toolName}-${toolState}-${groupIdx}`}
- // toolCallId={id}
- // input={latest.input as any}
- // output={latest.output as any}
- // errorText={errorText}
- // />
- // )
- // }
...
- // if (toolName === 'serpapi-search' && hasOutput) {
- // return (
- // <SearchResultList
- // key={`${id}-${toolName}-${toolState}-${groupIdx}`}
- // toolCallId={id}
- // input={latest.input as any}
- // output={latest.output as any}
- // errorText={errorText}
- // />
- // )
- // }Also applies to: 354-364
🤖 Prompt for AI Agents
In `@app/chat/components/agent-tools.tsx` around lines 326 - 340, Remove the
commented-out UI blocks for NewsCarousel and SearchResultList in the
agent-tools.tsx component: delete the commented code that references
NewsCarousel (the block containing key
`${id}-${toolName}-${toolState}-${groupIdx}`, toolCallId, input, output,
errorText) and the similar commented SearchResultList block (the other commented
range noted); keep the surrounding logic intact and rely on git history if
restoration is needed.
| "daneChangeLog": { | ||
| id: 'daneChangeLog', | ||
| name: 'Dane Package Publisher', | ||
| description: 'Publish packages to npm', | ||
| category: 'utility', | ||
| features: { ...defaultFeatures, tools: false }, | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix mismatched id, name, and description for daneChangeLog.
The configuration has id: 'daneChangeLog' but the name is "Dane Package Publisher" and description is "Publish packages to npm". This appears to be a copy-paste error. Either the id should be updated or the name/description should reflect changelog functionality.
🐛 Proposed fix (assuming this should be a changelog agent)
"daneChangeLog": {
id: 'daneChangeLog',
- name: 'Dane Package Publisher',
- description: 'Publish packages to npm',
+ name: 'Dane Change Log',
+ description: 'Generate changelog entries from commits',
category: 'utility',
features: { ...defaultFeatures, tools: false },
},📝 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.
| "daneChangeLog": { | |
| id: 'daneChangeLog', | |
| name: 'Dane Package Publisher', | |
| description: 'Publish packages to npm', | |
| category: 'utility', | |
| features: { ...defaultFeatures, tools: false }, | |
| }, | |
| "daneChangeLog": { | |
| id: 'daneChangeLog', | |
| name: 'Dane Change Log', | |
| description: 'Generate changelog entries from commits', | |
| category: 'utility', | |
| features: { ...defaultFeatures, tools: false }, | |
| }, |
🤖 Prompt for AI Agents
In `@app/chat/config/agents.ts` around lines 732 - 738, The agent definition for
"daneChangeLog" has a mismatched id vs name/description; update the name and
description to reflect changelog functionality (e.g., change name to "Dane
Changelog" or "Dane Changelog Publisher" and description to "Generate and
publish changelogs for packages" or similar) so the id `daneChangeLog` matches
the agent purpose, keeping the existing category and features intact.
| // Temporarily indicates an agent switch is in progress and sends are blocked | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Orphaned comment without corresponding property.
This comment describes a temporary agent-switch-in-progress state but no corresponding property (e.g., isAgentSwitching: boolean) is defined. Either add the missing property or remove the dangling comment.
Suggested fix if property is intended
// Focus Mode
isFocusMode: boolean
- // Temporarily indicates an agent switch is in progress and sends are blocked
+ // Temporarily indicates an agent switch is in progress and sends are blocked
+ isAgentSwitching: boolean
// Actions🤖 Prompt for AI Agents
In `@app/chat/providers/chat-context-types.ts` around lines 103 - 104, The
dangling comment refers to a missing state flag for agent switching; add a
boolean property named isAgentSwitching to the chat context/type (e.g., the
ChatContext/ChatState or ChatContextType interface in chat-context-types.ts) and
ensure the ChatProvider/createChatContext initializer sets a default (false) and
any setters/useEffects update it where agent switches occur; alternatively, if
the flag is not needed, remove the orphaned comment.
| @@ -1,5 +1,5 @@ | |||
| import { createGoogleGenerativeAI } from '@ai-sdk/google' | |||
| import { logError } from './logger' | |||
| //import { logError } from './logger' | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Remove commented-out import instead of leaving it.
As per coding guidelines, commented-out code should be removed rather than left in place. If logError is no longer needed, delete the import entirely and rely on version control history.
🧹 Suggested fix
-//import { logError } from './logger'📝 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.
| //import { logError } from './logger' |
🤖 Prompt for AI Agents
In `@src/mastra/config/google.ts` at line 2, Remove the commented-out import for
logError in the google.ts file; locate the line containing "//import { logError
} from './logger'" and delete it so no unused or commented import remains,
relying on VCS to recover if needed.
| gemini3Pro: google.languageModel('gemini-3-pro-preview'), | ||
| // Gemini 3 Flash model | ||
| gemini3Flash: google('gemini-3-flash-preview'), | ||
| gemini3Flash: google.languageModel('gemini-3-flash-preview'), | ||
| // Gemini 2.5 Pro model for higher-performance applications | ||
| gemini25Pro: google('gemini-2.5-pro'), | ||
| gemini25Pro: google.languageModel('gemini-2.5-pro'), | ||
| // Gemini 2.5 Flash model for general-purpose applications | ||
| gemini25Flash: google('gemini-2.5-flash-preview-09-2025'), | ||
| gemini25Flash: google.languageModel('gemini-2.5-flash-preview-09-2025'), | ||
| // Gemini 2.5 Flash Lite model for free-tier applications | ||
| gemini25FlashLite: google('gemini-2.5-flash-lite-preview-09-2025'), | ||
| gemini25FlashLite: google.languageModel('gemini-2.5-flash-lite-preview-09-2025'), | ||
| // Gemini Computer Use model for tasks requiring higher accuracy and reliability | ||
| gemini25ComputerUse: google('gemini-2.5-computer-use-preview-10-2025'), | ||
| gemini25ComputerUse: google.languageModel('gemini-2.5-computer-use-preview-10-2025'), | ||
| // Additional variants | ||
| gemini25FlashAlt: google('gemini-2.5-flash-preview-09-2025'), | ||
| gemini25FlashAlt: google.languageModel('gemini-2.5-flash-preview-09-2025'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
@ai-sdk/google v3.0.8 languageModel API documentation
💡 Result:
I couldn't find any release or docs specifically for "@ai-sdk/google v3.0.8". The official AI SDK / Google provider documentation and package pages you can use instead:
- AI SDK — Google provider docs (LanguageModel usage and examples). [1]
- AI SDK reference for LanguageModel V3 middleware and language-model APIs. [2]
- npm package page for
@ai-sdk/google(current published versions and changelog). [3]
If you need docs for a specific version (v3.0.8), tell me where that version is hosted (GitHub repo, private registry, or a tarball) or I can continue searching—would you like me to search GitHub releases or a specific registry for v3.0.8?
Sources:
[1] https://ai-sdk.dev/providers/ai-sdk-providers/google-generative-ai
[2] https://ai-sdk.dev/docs/reference/ai-sdk-core/language-model-v2-middleware
[3] https://www.npmjs.com/package/%40ai-sdk/google
🌐 Web query:
@ai-sdk/google languageModel method ai-sdk.dev documentation
💡 Result:
The ai-sdk.dev docs for the Google provider (@ai-sdk/google) show how to create/use language model instances (the languageModel method is exposed via the google(...) factory) and examples for generateText/streamText. Example usage:
- Import provider and call model factory: import { google } from '@ai-sdk/google'; const model = google('gemini-1.5-pro-latest');
- Use with AI SDK core functions: await generateText({ model: google('gemini-2.5-flash'), messages: [{ role: 'user', content: [{ type: 'text', text: 'Your prompt' }] }] });
Docs:
- Google provider (Ai SDK) — usage, file inputs, examples. [1]
- AI SDK Core reference (generateText / streamText and language-model integration). [2]
- npm package page for
@ai-sdk/google. [3]
Sources:
[1] ai-sdk.dev — Google Generative AI provider documentation. (ai-sdk.dev)
[2] ai-sdk.dev — AI SDK Core reference (generateText, streamText, etc.). (v5.ai-sdk.dev)
[3] npm: @ai-sdk/google package (readme/examples). (npmjs.com)
Would you like the exact code snippet for a specific model or use-case (streaming, files, embeddings)?
Citations:
- 1: https://ai-sdk.dev/providers/ai-sdk-providers/google-generative-ai?utm_source=openai
- 2: https://v5.ai-sdk.dev/docs/reference/ai-sdk-core?utm_source=openai
- 3: https://www.npmjs.com/package/%40ai-sdk/google?utm_source=openai
🌐 Web query:
@ai-sdk/google google() factory function returns languageModel property
💡 Result:
Short answer: Calling google('model-id') (the @ai-sdk/google factory) returns a LanguageModel instance (a provider model function/object) — it does not return an object with a separate languageModel property. See the Google provider docs and the AI SDK core provider API. [1][2]
Sources:
@ai-sdk/googledocs (provider usage / examples). [1]- AI SDK core / provider registry docs (languageModel() returns a LanguageModel). [2]
Use google('model-id') directly instead of google.languageModel('model-id').
The @ai-sdk/google factory function google() returns a LanguageModel instance directly. The pattern google.languageModel() does not exist in the API. Update all model definitions to use google('gemini-3-pro-preview') instead of google.languageModel('gemini-3-pro-preview').
🤖 Prompt for AI Agents
In `@src/mastra/config/google.ts` around lines 23 - 35, The model registrations
(e.g., gemini3Pro, gemini3Flash, gemini25Pro, gemini25Flash, gemini25FlashLite,
gemini25ComputerUse, gemini25FlashAlt) incorrectly call
google.languageModel(...); replace each call with the `@ai-sdk/google` factory
function form google('model-id') (for example google('gemini-3-pro-preview')) so
each symbol is assigned the LanguageModel returned by google(...) instead of the
non-existent google.languageModel(...) method.
| } = await embedMany({ | ||
| values: [queryText], | ||
| model: QDRANT_CONFIG.embeddingModel, | ||
| model: new ModelRouterEmbeddingModel('google/gemini-embedding-001'), | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same inconsistency as processDocument - use shared embedding model.
This duplicates the issue in processDocument. Use the same shared embedding model constant to ensure vector compatibility across all operations.
🤖 Prompt for AI Agents
In `@src/mastra/config/qdrant.ts` around lines 261 - 264, The embedMany call
currently constructs a new
ModelRouterEmbeddingModel('google/gemini-embedding-001') which duplicates
processDocument and breaks vector compatibility; replace that inline
ModelRouterEmbeddingModel usage with the shared embedding model constant used
elsewhere (the same constant referenced by processDocument, e.g.,
SHARED_EMBEDDING_MODEL or EMBEDDING_MODEL), update any imports or references so
embedMany({ model: ... }) uses that shared constant, and ensure embedMany,
ModelRouterEmbeddingModel, and processDocument now all rely on the same shared
embedding model symbol.
| sampling: { | ||
| type: SamplingStrategyType.RATIO, | ||
| probability: 0.5, | ||
| probability: 0.75, | ||
| }, // 50% sampling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stale comment contradicts actual sampling probability.
The comment on line 296 says "// 50% sampling" but the probability is now 0.75 (75%). Update or remove the comment to match the actual configuration.
Suggested fix
sampling: {
type: SamplingStrategyType.RATIO,
probability: 0.75,
- }, // 50% sampling
+ }, // 75% sampling📝 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.
| sampling: { | |
| type: SamplingStrategyType.RATIO, | |
| probability: 0.5, | |
| probability: 0.75, | |
| }, // 50% sampling | |
| sampling: { | |
| type: SamplingStrategyType.RATIO, | |
| probability: 0.75, | |
| }, // 75% sampling |
🤖 Prompt for AI Agents
In `@src/mastra/index.ts` around lines 293 - 296, The inline comment "// 50%
sampling" is stale and does not match the configured sampling.probability of
0.75 in the sampling block using SamplingStrategyType.RATIO; update the comment
to reflect 75% sampling or remove the comment entirely so it no longer
contradicts the actual configuration in the sampling object
(sampling.probability and SamplingStrategyType.RATIO).
| // Use an instance of RequestContext (not the class) so the route has a proper context per request | ||
| // requestContext: new RequestContext() | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Remove commented-out code or implement the feature.
Per coding guidelines, avoid commenting out code. If RequestContext per-request instantiation is needed, implement it; otherwise, remove this commented block and track the requirement in an issue.
🤖 Prompt for AI Agents
In `@src/mastra/index.ts` around lines 435 - 437, Remove the commented-out
instantiation of RequestContext or implement it: if you need a per-request
context, replace the commented line with runtime creation of a RequestContext
instance passed into the route configuration (e.g., ensure the route option key
requestContext receives a new RequestContext() for each request using the
appropriate middleware or factory), otherwise delete the commented block
entirely and open an issue referencing RequestContext to track the requirement;
locate the commented lines around the requestContext key and update either the
route setup to instantiate RequestContext per request or remove the comment.
| onInputStart: ({ toolCallId, messages, abortSignal }) => { | ||
| log.info('Weather tool input streaming started', { | ||
| toolCallId, | ||
| toolCallId: toolCallId.includes('get-weather'), | ||
| messageCount: messages.length, | ||
| hook: 'onInputStart', | ||
| abortSignal: abortSignal?.aborted, | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: toolCallId logged as boolean instead of actual ID.
Logging toolCallId.includes('get-weather') returns a boolean (true/false), losing the actual tool call identifier needed for debugging and tracing. This appears unintentional.
🐛 Proposed fix to log the actual toolCallId
onInputStart: ({ toolCallId, messages, abortSignal }) => {
log.info('Weather tool input streaming started', {
- toolCallId: toolCallId.includes('get-weather'),
+ toolCallId,
messageCount: messages.length,
hook: 'onInputStart',
abortSignal: abortSignal?.aborted,
})
},🤖 Prompt for AI Agents
In `@src/mastra/tools/weather-tool.ts` around lines 55 - 61, The log in
onInputStart incorrectly records toolCallId as a boolean by calling
toolCallId.includes('get-weather'); change the logged field to the actual
identifier by passing toolCallId itself (e.g., log.info(..., { toolCallId,
messageCount: messages.length, hook: 'onInputStart', abortSignal:
abortSignal?.aborted })) so the real ID is preserved for tracing and debugging.
| it('contains newly added agents and networks', () => { | ||
| const ids = getAllAgentIds() | ||
| for (const id of expectedIds) { | ||
| expect(ids).toContain(id) | ||
| } | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Consider using expect.arrayContaining for more concise assertions.
The current loop is clear, but using expect.arrayContaining provides better error messages showing all missing IDs at once rather than failing on the first missing one.
♻️ Alternative approach
it('contains newly added agents and networks', () => {
const ids = getAllAgentIds()
- for (const id of expectedIds) {
- expect(ids).toContain(id)
- }
+ expect(ids).toEqual(expect.arrayContaining(expectedIds))
})🤖 Prompt for AI Agents
In `@tests/agents-config.test.ts` around lines 35 - 40, Replace the manual loop
that checks each id with a single assertion using Jest's expect.arrayContaining
so failures list all missing IDs at once; specifically, in the test that calls
getAllAgentIds() and iterates expectedIds, remove the for-loop and assert that
the returned ids array contains arrayContaining(expectedIds) (use
expect(ids).toEqual(expect.arrayContaining(expectedIds)) or equivalent)
referencing the getAllAgentIds call and the expectedIds variable.

refactor: modify embedding model initialization
fix: adjust sampling probability in Mastra configuration
chore: update crawler statistics and session pool state
feat: implement weather tool logging enhancements
chore: add Convex configuration file
test: add agent registry tests
chore: add OpenTelemetry instrumentation setup
Summary by Sourcery
Update agent configuration, observability, and vector storage integrations while refining Google provider usage and tooling around the weather and agent registry flows.
New Features:
Enhancements:
Build:
Tests:
Chores: