Skip to content

feat: Enhance stock analysis agent and other components#65

Merged
ssdeanx merged 1 commit intomainfrom
develop
Jan 3, 2026
Merged

feat: Enhance stock analysis agent and other components#65
ssdeanx merged 1 commit intomainfrom
develop

Conversation

@ssdeanx
Copy link
Copy Markdown
Owner

@ssdeanx ssdeanx commented Jan 3, 2026

  • Refactored stock analysis agent's reasoning protocol for clarity and conciseness, consolidating multiple analysis frameworks into a streamlined process.
  • Updated data gathering and analysis phases in the stock analysis agent to improve efficiency and clarity.
  • Added tool efficiency guidelines to the weather agent to prevent repetitive tool usage.
  • Changed index configuration in pg-storage from 'flat' to 'hnsw' for improved performance with high-dimensional embeddings.
  • Cleaned up memory template in pg-storage for better readability and organization.
  • Updated web scraper tool to introduce new schemas for crawling, extraction, request, and storage options, enhancing configurability.
  • Improved output structure in web scraper tool to better organize extracted content and analysis results.
  • Introduced a new chat sidebar component for displaying agent details, features, checkpoints, and memory settings in a user-friendly manner.

Summary by Sourcery

Streamline multiple agents’ system prompts and reasoning protocols while enhancing chat UI, web scraping tool schemas, and pg-vector storage configuration.

New Features:

  • Introduce a chat sidebar to surface agent details, capabilities, checkpoints, and memory configuration alongside the main conversation.
  • Add in-input agent and model selectors, speech input, checkpoints, and context usage controls to the chat input experience.
  • Register new Gemini 3 Flash and updated Gemini 3 Pro preview models in the Google model configuration.
  • Add structured crawling, extraction, request, and storage option schemas to the web scraper tool input, and restructure its output into content, storage, and analysis sections.

Bug Fixes:

  • Fix conditional rendering in agent chain-of-thought, agent queue sections, inline citations, and checkpoint timestamp parsing to avoid runtime issues.
  • Correct default model selection logic and minor className/prop inconsistencies in headers and selectors.

Enhancements:

  • Simplify and standardize reasoning protocols and rules across stock analysis, research, knowledge indexing, document processing, evaluation, editing, research paper, copywriting, ingestion, content strategy, coding, legal, learning extraction, reporting, scripting, ACP, and other agents, including new tool-efficiency guidelines.
  • Refine financial Recharts-related agents to use concise reasoning protocols, standardized rules, and tool efficiency constraints.
  • Improve middleware to populate request context (user, tier, language, research phase) and re-enable request timing logging.
  • Tighten various UI components’ behavior and styling (model/agent selectors, chain-of-thought, agent queue, checkpoints, inline citations, workflows layout, chat header placement).
  • Update pg-vector memory configuration to use HNSW indexes and a more concise memory template for user context.

Documentation:

  • Revise internal Copilot processing notes to describe the new chat UI improvements and Gemini 3 model support.

Chores:

  • Re-enable bgColorAgent and MCP server wiring and clean up route/middleware configuration in the main Mastra setup.

- Refactored stock analysis agent's reasoning protocol for clarity and conciseness, consolidating multiple analysis frameworks into a streamlined process.
- Updated data gathering and analysis phases in the stock analysis agent to improve efficiency and clarity.
- Added tool efficiency guidelines to the weather agent to prevent repetitive tool usage.
- Changed index configuration in pg-storage from 'flat' to 'hnsw' for improved performance with high-dimensional embeddings.
- Cleaned up memory template in pg-storage for better readability and organization.
- Updated web scraper tool to introduce new schemas for crawling, extraction, request, and storage options, enhancing configurability.
- Improved output structure in web scraper tool to better organize extracted content and analysis results.
- Introduced a new chat sidebar component for displaying agent details, features, checkpoints, and memory settings in a user-friendly manner.
Copilot AI review requested due to automatic review settings January 3, 2026 19:30
@continue
Copy link
Copy Markdown

continue Bot commented Jan 3, 2026

All Green - Keep your PRs mergeable

Learn more

All Green is an AI agent that automatically:

✅ Addresses code review comments

✅ Fixes failing CI checks

✅ Resolves merge conflicts


Unsubscribe from All Green comments

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

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

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Jan 3, 2026

Reviewer's Guide

Refactors multiple agents’ system prompts for a more concise reasoning protocol while adding a cross-cutting 'tool efficiency' rule, restructures the web scraper tool’s input/output schemas, switches Postgres pg-vector indexes to HNSW with a simplified memory template, and significantly enhances the chat UI with model/agent selection, context display, checkpoints, speech input, and a new sidebar layout plus Gemini 3 model support.

Sequence diagram for enhanced chat interaction with model/agent selection and sidebar

sequenceDiagram
  actor User
  participant ChatPage
  participant ChatInput
  participant ChatSidebar
  participant ChatContext
  participant AgentBackend

  User->>ChatPage: Open /chat
  ChatPage->>ChatContext: Initialize with defaultAgent
  ChatPage->>ChatHeader: Render with context
  ChatPage->>ChatSidebar: Render with agentConfig, checkpoints, memory
  ChatPage->>ChatInput: Render with selectedAgent, selectedModel

  User->>ChatInput: Select model via ModelSelector
  ChatInput->>ChatContext: selectModel(modelId)
  ChatContext-->>ChatInput: updated selectedModel
  ChatContext-->>ChatSidebar: updated selectedModel (indirect via provider)

  User->>ChatInput: Select agent via AgentSelector
  ChatInput->>ChatContext: selectAgent(agentId)
  ChatContext-->>ChatSidebar: updated agentConfig

  User->>ChatInput: Dictate message via SpeechButton
  ChatInput->>SpeechButton: start transcription
  SpeechButton-->>ChatInput: onTranscriptionChange(text)

  User->>ChatInput: Press Send
  ChatInput->>ChatContext: sendMessage(text, files)
  ChatContext->>AgentBackend: invoke agent with selectedModel and agentConfig
  AgentBackend-->>ChatContext: streamed response
  ChatContext-->>ChatMessages: append messages

  User->>ChatInput: Create checkpoint
  ChatInput->>ChatContext: createCheckpoint(lastMessageIndex)
  ChatContext-->>ChatSidebar: checkpoints updated

  User->>ChatSidebar: Update threadId/resourceId
  ChatSidebar->>ChatContext: setThreadId, setResourceId
  ChatContext-->>AgentBackend: use updated memory config on next call
Loading

Class diagram for updated webScraperTool schemas

classDiagram
  class WebScraperInput {
    +string url
    +string? selector
    +string[]? attributes
    +CrawlingOptions? crawling
    +ExtractionOptions? extraction
    +RequestOptions? request
    +StorageOptions? storage
  }

  class CrawlingOptions {
    +int? depth
    +int? maxPages
    +bool? followLinks
    +bool? respectRobotsTxt
    +int? delayBetweenRequests
  }

  class ExtractionOptions {
    +bool? includeImages
    +bool? extractMetadata
    +ContentType? contentType
    +bool? extractStructuredData
    +bool? languageDetection
    +ContentFilteringOptions? contentFiltering
  }

  class ContentFilteringOptions {
    +int? minLength
    +int? maxLength
    +string[]? keywords
    +string[]? excludePatterns
  }

  class RequestOptions {
    +int? timeout
    +string? userAgent
    +Map~string,string~? headers
    +int? retryAttempts
    +bool? compression
    +Map~string,string~? cookies
  }

  class StorageOptions {
    +bool? saveMarkdown
    +string? markdownFileName
    +OutputFormat? outputFormat
  }

  class WebScraperOutput {
    +string url
    +string status
    +string? errorMessage
    +ScrapedContent content
    +StorageInfo? storage
    +AnalysisResult? analysis
  }

  class ScrapedContent {
    +Map~string,string~[] extractedData
    +string? rawContent
    +string? markdownContent
  }

  class StorageInfo {
    +string? savedFilePath
  }

  class AnalysisResult {
    +Map~string,string~? metadata
    +ImageInfo[]? images
    +any[]? structuredData
    +string? detectedLanguage
  }

  class ImageInfo {
    +string src
    +string? alt
    +string? title
  }

  class ContentType {
  }

  class OutputFormat {
  }

  WebScraperInput --> CrawlingOptions : uses
  WebScraperInput --> ExtractionOptions : uses
  WebScraperInput --> RequestOptions : uses
  WebScraperInput --> StorageOptions : uses

  ExtractionOptions --> ContentFilteringOptions : uses

  WebScraperOutput --> ScrapedContent : contains
  WebScraperOutput --> StorageInfo : contains
  WebScraperOutput --> AnalysisResult : contains

  AnalysisResult --> ImageInfo : contains

  ExtractionOptions --> ContentType : enum
  StorageOptions --> OutputFormat : enum
Loading

Class diagram for enhanced Chat UI layout and components

classDiagram
  class ChatPage {
    +render()
  }

  class ChatProvider {
    +string defaultAgent
    +provideChatContext()
  }

  class ChatHeader {
    +render()
  }

  class ChatMessages {
    +render()
  }

  class ChatInput {
    -string input
    -TextareaRef textareaRef
    +handleSubmit(message)
    +setInput(value)
  }

  class ChatSidebar {
    +render()
  }

  class ChatContext {
    +bool isLoading
    +string status
    +AgentConfig agentConfig
    +string selectedAgent
    +ModelConfig selectedModel
    +Message[] messages
    +Usage usage
    +Checkpoint[] checkpoints
    +string threadId
    +string resourceId
    +sendMessage(text,files)
    +stopGeneration()
    +selectModel(modelId)
    +selectAgent(agentId)
    +createCheckpoint(index)
    +restoreCheckpoint(id)
    +setThreadId(id)
    +setResourceId(id)
  }

  class AgentConfig {
    +string name
    +string category
    +string description
    +AgentFeatures features
  }

  class AgentFeatures {
    +bool reasoning
    +bool tools
    +bool sources
    +bool canvas
    +bool artifacts
    +bool plan
    +bool task
    +bool webPreview
  }

  class ModelConfig {
    +string id
    +string name
    +string provider
    +int contextWindow
    +bool? isDefault
  }

  class Checkpoint {
    +string id
    +string? label
    +int messageCount
    +Date timestamp
  }

  class ChatInputToolbar {
    +ModelSelector
    +AgentSelector
    +ContextDisplay
    +SpeechButton
    +AttachmentMenu
    +CheckpointButton
  }

  class ModelSelector {
    +open()
    +selectModel(modelId)
  }

  class ContextDisplay {
    +int usedTokens
    +int maxTokens
  }

  class SpeechButton {
    +onTranscriptionChange(text)
  }

  ChatPage --> ChatProvider : wraps
  ChatPage --> ChatHeader : contains
  ChatPage --> ChatMessages : contains
  ChatPage --> ChatInput : contains
  ChatPage --> ChatSidebar : contains

  ChatProvider --> ChatContext : provides

  ChatHeader --> ChatContext : uses
  ChatMessages --> ChatContext : uses
  ChatInput --> ChatContext : uses
  ChatSidebar --> ChatContext : uses

  ChatInput --> ChatInputToolbar : contains
  ChatInputToolbar --> ModelSelector : uses
  ChatInputToolbar --> ContextDisplay : uses
  ChatInputToolbar --> SpeechButton : uses

  ChatContext --> AgentConfig : returns
  ChatContext --> ModelConfig : returns
  ChatContext --> Checkpoint : manages
  AgentConfig --> AgentFeatures : has

  ModelSelector --> ModelConfig : lists
Loading

File-Level Changes

Change Details Files
Simplified reasoning protocols and added tool-efficiency rules across key agents, including stock analysis and research-related agents.
  • Replaced verbose multi-section reasoning frameworks in stockAnalysisAgent, researchAgent, and other domain agents with shorter reasoning_protocol/process/rules blocks focused on concrete steps and JSON outputs.
  • Introduced a shared rule across many agents to avoid repetitive or back-to-back tool calls for the same query, explicitly documented in their system prompts.
  • Updated task- and domain-specific guidance (e.g., knowledge indexing, document processing, research papers, copywriting, data ingestion/export, content strategy, ACP, reporting, script writing, learning extraction, coding/testing/business-legal agents) to be more concise while preserving capabilities.
src/mastra/agents/stockAnalysisAgent.ts
src/mastra/agents/recharts.ts
src/mastra/agents/researchAgent.ts
src/mastra/agents/knowledgeIndexingAgent.ts
src/mastra/agents/documentProcessingAgent.ts
src/mastra/agents/evaluationAgent.ts
src/mastra/agents/editorAgent.ts
src/mastra/agents/researchPaperAgent.ts
src/mastra/agents/copywriterAgent.ts
src/mastra/agents/dataIngestionAgent.ts
src/mastra/agents/contentStrategistAgent.ts
src/mastra/agents/acpAgent.ts
src/mastra/agents/reportAgent.ts
src/mastra/agents/dataExportAgent.ts
src/mastra/agents/learningExtractionAgent.ts
src/mastra/agents/scriptWriterAgent.ts
src/mastra/agents/codingAgents.ts
src/mastra/agents/businessLegalAgents.ts
src/mastra/agents/weather-agent.ts
src/mastra/agents/dane.ts
Restructured the web scraper tool API into nested option schemas and a more organized output shape.
  • Introduced dedicated zod schemas for crawling, extraction, request, and storage options and wired them into the main webScraperInputSchema under namespaced keys (crawling, extraction, request, storage).
  • Refactored webScraperOutputSchema to group scraped content, storage info, and analysis data into nested content, storage, and analysis objects instead of flat fields.
  • Updated the webScraperTool implementation to use the new nested input (e.g., request.headers/userAgent, crawling.depth/maxPages) and to emit the new structured output while keeping logging and progress reporting consistent.
src/mastra/tools/web-scraper-tool.ts
Switched pg-storage memory indexes from flat to HNSW and simplified the long-term memory template.
  • Changed pgMemory and related Memory config indexConfig.type from 'flat' to 'hnsw' and replaced IVF list configuration with HNSW-specific parameters (m, efConstruction).
  • Replaced a verbose multi-section user profile/memory template with a shorter, more compact user context template to guide long-term memory summarization.
src/mastra/config/pg-storage.ts
Enhanced the chat UI with a richer input bar, model/agent selection, token context display, checkpoints, and a new sidebar, plus layout adjustments.
  • Extended ChatInput to manage local input state, integrate PromptInputHeader/Body, add an action menu for attachments, speech-to-text button, checkpoint creation button, agent and model selectors, and a context popover showing token usage.
  • Added a new ChatSidebar component that surfaces agent details (name, category, description, capabilities), checkpoint history with restore actions, and editable memory settings (thread/resource IDs) wired into chat context.
  • Updated ChatHeader, ChatPage, and related components to account for a fixed navbar (adding mt-16 and height calculations), adjust selector sizing, and ensure model/agent selectors and context window formatting behave correctly.
  • Made minor robustness tweaks to chat/network components (e.g., guarding empty arrays, using Boolean checks, refining AgentCheckpoint date parsing, and getDefaultModel default selection).
app/chat/components/chat-input.tsx
app/chat/components/chat-sidebar.tsx
app/chat/components/chat-header.tsx
app/chat/components/agent-chain-of-thought.tsx
app/chat/components/agent-queue.tsx
app/chat/components/agent-inline-citation.tsx
app/chat/components/agent-checkpoint.tsx
app/chat/config/models.ts
app/chat/page.tsx
app/networks/components/network-header.tsx
app/workflows/page.tsx
Added Gemini 3 model support and clarified package publisher guidance and internal docs.
  • Registered new Gemini 3 Flash and updated Gemini 3 Pro model configs with pricing, capabilities, and large context windows in the Google models configuration.
  • Simplified the package-publisher agent’s package location rules into a concise bullet list for core, deployer, store, and speech packages.
  • Updated Copilot-Processing.md summary to describe the new Chat UI and Google 3 model support instead of previous GitHub tool changes.
app/chat/config/google-models.ts
src/mastra/agents/package-publisher.ts
Copilot-Processing.md
Tightened server configuration, middleware, and routes in mastra index, including pg storage and MCP servers.
  • Enabled mcpServers configuration for a2aCoordinator and notes servers in the Mastra instance instead of leaving it commented out.
  • Adjusted the PostgresStore connectionString to assert a non-null SUPABASE env var, cleaned up indentation, and re-enabled requestContext middleware to derive temperature-unit, userId, user-tier, language, and researchPhase from headers.
  • Re-enabled a request timing logger middleware and removed some unused chat routes (weatherAgent, bgColorAgent) that were previously commented or duplicated in other forms.
src/mastra/index.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 3, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Added Gemini 3 model support with Flash and Pro variants
    • Enhanced chat interface with model/agent selector, speech-to-text input, and token usage tracking
    • New sidebar displaying agent capabilities, history checkpoints, and memory settings
    • Introduced Gemini 3 Expert agent configuration
  • Improvements

    • Optimized chat layout positioning and responsive sizing
    • Refined agent instruction workflows and tool efficiency guidelines
    • Updated memory indexing strategy for improved performance

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

Walkthrough

This PR introduces extensive chat UI enhancements with model/agent selection, a new ChatSidebar for agent configuration, Gemini 3 model support, refactors 20+ agent prompts to simplified formats, restructures the web-scraper tool's input/output schemas, updates storage indexing to HNSW, and enables new mastra runtime features.

Changes

Cohort / File(s) Summary
Chat UI Components
app/chat/components/agent-chain-of-thought.tsx, agent-checkpoint.tsx, agent-inline-citation.tsx, agent-queue.tsx
Defensive null/undefined checks replaced with explicit truthy/boolean casts; logic preserves rendering behavior while clarifying intent (e.g., Boolean(step.duration), explicit undefined checks)
Chat Input & Context
app/chat/components/chat-input.tsx, app/chat/providers/chat-context.ts
Extensive ChatInput redesign adds model/agent selector UI, state management for controlled textarea, speech-to-text button, checkpoint creation, and attachment workflow; context provider exposes new methods selectModel(), selectAgent(), createCheckpoint()
Chat Layout & Sidebar
app/chat/components/chat-header.tsx, chat-sidebar.tsx, app/chat/page.tsx
ChatHeader adds top margin (mt-16) and shrinks ModelSelector widths; new ChatSidebar component displays agent capabilities, checkpoints, and memory config; ChatPage restructured to two-pane layout with reduced height accounting for navbar
Model & Agent Configuration
app/chat/config/google-models.ts, models.ts
Added Gemini 3 Flash/Pro Preview models to GOOGLE_MODELS; default model selection now requires explicit isDefault === true flag instead of truthy check
Page Layout & Styling
app/networks/components/network-header.tsx, app/workflows/page.tsx
ModelSelector widths reduced (w-340px → w-85, max-h-400px → max-h-100); workflows page adds top padding (pt-16) for navbar clearance
Mastra Agent Prompts
src/mastra/agents/*.ts (20+ files: acpAgent, businessLegalAgents, codingAgents, contentStrategistAgent, copywriterAgent, dane, dataExportAgent, dataIngestionAgent, documentProcessingAgent, editorAgent, evaluationAgent, knowledgeIndexingAgent, learningExtractionAgent, package-publisher, recharts, reportAgent, researchAgent, researchPaperAgent, scriptWriterAgent, stockAnalysisAgent, weather-agent)
Systematic refactoring: verbose multi-section instruction blocks simplified to concise Markdown-style content with sections like "Process", "Rules", "Methodology"; removed legacy XML-like tags and extensive reasoning scaffolds; added/standardized "Tool Efficiency" rules across multiple agents
Mastra Runtime & Middleware
src/mastra/index.ts
Enabled documentProcessingWorkflow and bgColorAgent; fixed SUPABASE env assertion; implemented full RequestContext population from headers (country, authHeader, userId, userTier, language, researchPhase); added temperature-unit computation; removed weatherAgent chatRoute; added active timing logger middleware
Storage Configuration
src/mastra/config/pg-storage.ts
Changed vector indexing from 'flat'/IVF to 'hnsw' with parameters (m: 16, efConstruction: 64); simplified working memory template from detailed Markdown to compact "User Context" structure
Web Scraper Tool
src/mastra/tools/web-scraper-tool.ts
Restructured input schema from flat fields to nested structure (crawling, extraction, request, storage); output schema reorganized into content/storage/analysis objects; updated code paths to read from nested structure and reflect changes in logging/configuration

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant ChatInput
    participant ChatContext
    participant AgentProvider

    User->>ChatInput: Select Agent (dropdown)
    ChatInput->>ChatContext: selectAgent(agentId)
    ChatContext->>ChatContext: Update agent state
    
    User->>ChatInput: Select Model (dropdown)
    ChatInput->>ChatContext: selectModel(modelId)
    ChatContext->>ChatContext: Update model state
    
    User->>ChatInput: Type message & attach files
    ChatInput->>ChatInput: Manage input state + attachments
    
    User->>ChatInput: Click Send or Create Checkpoint
    alt Create Checkpoint
        ChatInput->>ChatContext: createCheckpoint(messageIndex)
        ChatContext->>ChatContext: Store checkpoint state
        ChatContext-->>ChatInput: Checkpoint created
    else Send Message
        ChatInput->>ChatContext: Submit with selected agent/model
        ChatContext->>AgentProvider: Route to agent with model
        AgentProvider-->>ChatContext: Response
        ChatContext-->>ChatInput: Update messages
        ChatInput->>ChatInput: Clear input, refresh sidebar
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • PR #42: Adds UI components (WebScraperTool, BatchWebScraperTool, etc.) that directly consume the web-scraper tool types being restructured in this PR's schema changes
  • PR #64: Modifies Google/Gemini model surface to add/expose Gemini 3 models, directly overlapping with the Gemini 3 model entries added in google-models.ts
  • PR #61: Overlaps on multiple fronts—adds Gemini 3 model entries, updates dane agent configuration, and modifies web-scraper tool usage across agents

Poem

🐰 Whiskers twitching with delight,
New sidebar sparkles, models bright,
Gemini flashes, prompts refined,
Web scrapers nested—well designed!
Our Warren of agents, sleek and lean,
The finest chat UI we've seen!

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'feat: Enhance stock analysis agent and other components' is partially related to the changeset. While it mentions the stock analysis agent, the PR contains numerous substantial changes across chat UI, Gemini 3 models, web scraper schemas, pg-storage indexing, and many agent prompts that go well beyond stock analysis. Revise the title to reflect the comprehensive scope of changes. Consider: 'feat: Enhance chat UI with sidebar and improve agent prompts, models, and tool configurations' or similar to better capture the main improvements.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The description comprehensively covers the major changes including stock analysis refactoring, chat UI enhancements (sidebar, input improvements), Gemini 3 models, web scraper tool updates, pg-storage configuration, and agent prompt simplifications across multiple agents.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch develop

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 3, 2026

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

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @ssdeanx, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a suite of enhancements across the application, primarily focusing on improving the user experience in the chat interface, expanding AI model capabilities, and optimizing backend agent logic and data storage. Key changes include a redesigned chat UI with a new sidebar and advanced input features, integration of the latest Google Gemini 3 models, and a widespread refactoring of agent prompts to improve their reasoning and tool-use efficiency. Additionally, data storage mechanisms have been optimized, and the web scraping tool has gained more sophisticated configuration options.

Highlights

  • Enhanced Chat UI: The chat interface has been significantly upgraded with a new sidebar for agent details, checkpoints, and memory settings, alongside a richer input component featuring model/agent selectors, speech-to-text, and attachment options.
  • Google Gemini 3 Model Support: Support for new Google Gemini 3 models, specifically 'gemini-3-flash-preview' and an updated 'gemini-3-pro-preview', has been integrated, including a new 'Gemini 3 Expert' agent.
  • Agent Reasoning Protocol Refinement: Numerous agents, including the stock analysis agent, have had their system prompts refactored for improved clarity, conciseness, and a more streamlined reasoning protocol, often consolidating multiple analysis frameworks.
  • Tool Efficiency Guidelines for Agents: A new 'Tool Efficiency' rule has been added to many agent prompts, instructing them to avoid repetitive or back-to-back tool usage for the same query, promoting smarter tool orchestration.
  • Pg-Storage Optimization: The pg-storage configuration has been updated to use the 'hnsw' index type instead of 'flat' for improved performance with high-dimensional embeddings, and the memory template has been cleaned up for better readability.
  • Web Scraper Tool Enhancements: The web scraper tool now features new, more granular schemas for crawling, extraction, request, and storage options, significantly enhancing its configurability and improving the structure of its output.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

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

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 3, 2026

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

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • The webScraperTool input/output schemas now use nested crawling/extraction/request/storage objects and wrap content/metadata into content, storage, and analysis; if any existing tools or agents are still calling the old flat schema or reading top-level extractedData/metadata/images, they will break—consider either adding compatibility shims or updating all known call sites in this PR.
  • In pg-storage.ts, the comment on the indexConfig still describes a flat index and IVF lists, but the config was switched to type: 'hnsw' with HNSW params—update the comment to match the actual index type and parameters so future tuning isn't misled by stale documentation in code.
  • Several Tailwind class changes (e.g., min-w-35, w-85, max-h-100, min-w-30) in chat-header.tsx and network-header.tsx don't correspond to standard Tailwind utility names; if these aren't custom tokens in your config they will be ignored—consider switching to valid classes (e.g., min-w-[140px], w-[340px], max-h-[400px]) or defining matching custom sizes.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `webScraperTool` input/output schemas now use nested `crawling/extraction/request/storage` objects and wrap content/metadata into `content`, `storage`, and `analysis`; if any existing tools or agents are still calling the old flat schema or reading top-level `extractedData/metadata/images`, they will break—consider either adding compatibility shims or updating all known call sites in this PR.
- In `pg-storage.ts`, the comment on the `indexConfig` still describes a flat index and IVF lists, but the config was switched to `type: 'hnsw'` with HNSW params—update the comment to match the actual index type and parameters so future tuning isn't misled by stale documentation in code.
- Several Tailwind class changes (e.g., `min-w-35`, `w-85`, `max-h-100`, `min-w-30`) in `chat-header.tsx` and `network-header.tsx` don't correspond to standard Tailwind utility names; if these aren't custom tokens in your config they will be ignored—consider switching to valid classes (e.g., `min-w-[140px]`, `w-[340px]`, `max-h-[400px]`) or defining matching custom sizes.

## Individual Comments

### Comment 1
<location> `src/mastra/config/pg-storage.ts:99-101` </location>
<code_context>
             scope: 'resource', // 'resource' | 'thread'
             // HNSW index configuration to support high-dimensional embeddings (>2000 dimensions)
             indexConfig: {
-                type: 'flat', // flat index type (supports dimensions > 4000, unlike HNSW limit of 2000)
+                type: 'hnsw', // flat index type (supports dimensions > 4000, unlike HNSW limit of 2000)
                 metric: 'cosine', // Distance metric for normalized embeddings
-                ivf: {lists: parseInt(process.env.LISTS ?? '3072')}, // IVF configuration for flat index
+                hnsw: { m: 16, efConstruction: 64 } // hnsw configuration
                 },
             threshold: 0.75, // Similarity threshold for semantic recall
</code_context>

<issue_to_address>
**nitpick:** Index type was switched to `hnsw` but the inline comments still reference `flat`/IVF and high-dimension constraints.

Comments still describe a flat/IVF index and dimension limits that no longer apply. Please update them to reflect the HNSW config and its actual trade-offs (e.g., memory vs recall, M/efConstruction) so future tuning isn’t based on outdated assumptions.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines -99 to -101
type: 'flat', // flat index type (supports dimensions > 4000, unlike HNSW limit of 2000)
type: 'hnsw', // flat index type (supports dimensions > 4000, unlike HNSW limit of 2000)
metric: 'cosine', // Distance metric for normalized embeddings
ivf: {lists: parseInt(process.env.LISTS ?? '3072')}, // IVF configuration for flat index
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nitpick: Index type was switched to hnsw but the inline comments still reference flat/IVF and high-dimension constraints.

Comments still describe a flat/IVF index and dimension limits that no longer apply. Please update them to reflect the HNSW config and its actual trade-offs (e.g., memory vs recall, M/efConstruction) so future tuning isn’t based on outdated assumptions.

Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a wide range of enhancements, including a major UI overhaul for the chat interface with a new sidebar and improved input controls, support for new Gemini models, and significant refactoring of agent prompts for conciseness and clarity. The changes are generally well-implemented. My review includes a few suggestions to improve code clarity, fix a potential runtime error related to date parsing, and address some minor inconsistencies and cleanup opportunities. Specifically, I've pointed out some redundant boolean checks, an incorrect comment in the pg-storage configuration, and some cleanup opportunities in the newly added components and middleware.

className,
}: AgentCheckpointProps) {
const date = timestamp ? (typeof timestamp === 'string' ? new Date(timestamp) : timestamp) : undefined
const date = timestamp !== undefined ? (typeof timestamp === 'string' ? new Date(timestamp) : timestamp) : undefined
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

This change might introduce a runtime error. The original check timestamp ? ... correctly handled falsy values like an empty string (''), treating it as undefined. The new check timestamp !== undefined will be true for an empty string. This leads to new Date(''), which creates an Invalid Date object. If formatTime doesn't handle invalid dates, this will likely throw a RangeError. It's safer to stick with the original truthiness check or add a specific check for empty strings.

Suggested change
const date = timestamp !== undefined ? (typeof timestamp === 'string' ? new Date(timestamp) : timestamp) : undefined
const date = timestamp ? (typeof timestamp === 'string' ? new Date(timestamp) : timestamp) : undefined

Comment on lines 29 to +32
const completedCount = useMemo(() => steps.filter((s) => s.status === "complete").length, [steps])
const activeStep = useMemo(() => steps.find((s) => s.status === "active"), [steps])

if (steps.length === 0) {return null}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

For better performance, it's a good practice to have early returns at the beginning of the function body, before any hooks like useMemo are called. This avoids unnecessary computations when the component is going to return null anyway. Consider moving the if (steps.length === 0) check to be the first line in the component.

status={step.status}
>
{step.duration && step.status === "complete" && (
{(Boolean(step.duration)) && step.status === "complete" && (
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The explicit (Boolean(step.duration)) check is redundant. The original step.duration check is idiomatic in JavaScript/TypeScript for checking for truthy values (non-zero numbers, non-empty strings, etc.) and is more concise. I'd recommend simplifying this for better readability.

Suggested change
{(Boolean(step.duration)) && step.status === "complete" && (
{step.duration && step.status === "complete" && (

</QueueItemActions>
</div>
{task.description && (
{(Boolean(task.description)) && (
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The explicit (Boolean(task.description)) check is redundant. A simple truthiness check task.description && ... is more idiomatic and readable for conditional rendering.

Suggested change
{(Boolean(task.description)) && (
{task.description && (

<QueueItemDescription>{task.description}</QueueItemDescription>
)}
{task.error && (
{(Boolean(task.error)) && (
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Similar to the check for task.description, the explicit (Boolean(task.error)) is redundant. A simple truthiness check task.error && ... is more idiomatic and readable.

Suggested change
{(Boolean(task.error)) && (
{task.error && (

Comment on lines +211 to +217
<ModelSelectorItem
key={agent.id}
onSelect={() => selectAgent(agent.id)}
className={cn(selectedAgent === agent.id && "bg-accent")}
>
{agent.name}
</ModelSelectorItem>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

For consistency with chat-header.tsx and to ensure search functionality within the ModelSelector works as expected, it's a good practice to add the value prop to ModelSelectorItem. In chat-header.tsx, this was explicitly set to agent.name.

                            <ModelSelectorItem
                              key={agent.id}
                              value={agent.name}
                              onSelect={() => selectAgent(agent.id)}
                              className={cn(selectedAgent === agent.id && "bg-accent")}
                            >
                              {agent.name}
                            </ModelSelectorItem>

Comment on lines +7 to +19
import {
BotIcon,
CpuIcon,
HistoryIcon,
BookmarkIcon,
SettingsIcon,
DatabaseIcon,
HashIcon,
UserIcon,
CheckCircle2Icon,
CircleIcon,
InfoIcon,
} from "lucide-react"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The CpuIcon is imported but it's not used within the ChatSidebar component. It's good practice to remove unused imports to keep the code clean.

import {
  BotIcon,
  HistoryIcon,
  BookmarkIcon,
  SettingsIcon,
  DatabaseIcon,
  HashIcon,
  UserIcon,
  CheckCircle2Icon,
  CircleIcon,
  InfoIcon,
} from "lucide-react"

// HNSW index configuration to support high-dimensional embeddings (>2000 dimensions)
indexConfig: {
type: 'flat', // flat index type (supports dimensions > 4000, unlike HNSW limit of 2000)
type: 'hnsw', // flat index type (supports dimensions > 4000, unlike HNSW limit of 2000)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The index type has been changed to hnsw, but the comment still describes the flat index type and its dimension limits. This comment is now misleading and should be updated to reflect the use of HNSW.

Suggested change
type: 'hnsw', // flat index type (supports dimensions > 4000, unlike HNSW limit of 2000)
type: 'hnsw', // HNSW index type for improved performance with high-dimensional embeddings

Comment thread src/mastra/index.ts
// if (requestContext?.set) {
const requestContext = c.get('requestContext') as RequestContext | undefined
if (requestContext?.set) {
// // Temperature unit (from Cloudflare geo header)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This comment describing the temperature unit logic appears to be commented out, while the code itself is active. For clarity, the comment should be active as well.

Suggested change
// // Temperature unit (from Cloudflare geo header)
// Temperature unit (from Cloudflare geo header)

Comment thread src/mastra/index.ts
// runtime API key (for tools that may accept runtimeContext.apiKey)
// if (apiKeyHeader !== null && apiKeyHeader !== '') { requestContext.set('apiKey', apiKeyHeader) }
// }
// if (apiKeyHeader !== null && apiKeyHeader !== '') { requestContext.set('apiKey', apiKeyHeader) }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This commented-out line references an undefined apiKeyHeader. It seems to be leftover code and can be safely removed to improve clarity.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 20

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (8)
app/chat/components/agent-queue.tsx (1)

120-127: Remove unnecessary parentheses around Boolean() calls.

The extra parentheses wrapping Boolean(task.description) and Boolean(task.error) add visual clutter without providing value. Standard syntax {Boolean(value) && ...} is clearer.

Additionally, note the inconsistency with line 128, which uses a direct truthy check task.createdAt && without Boolean(). For string properties (which description and error likely are), both approaches behave identically. Consider applying the same pattern consistently throughout.

🔎 Proposed refactor to simplify
-              {(Boolean(task.description)) && (
+              {Boolean(task.description) && (
                <QueueItemDescription>{task.description}</QueueItemDescription>
              )}
-              {(Boolean(task.error)) && (
+              {Boolean(task.error) && (
                <QueueItemDescription className="text-destructive">
                  {task.error}
                </QueueItemDescription>
              )}

Or, for consistency with line 128, you could use direct truthy checks if description and error are typed as string | undefined:

-              {(Boolean(task.description)) && (
+              {task.description && (
                <QueueItemDescription>{task.description}</QueueItemDescription>
              )}
-              {(Boolean(task.error)) && (
+              {task.error && (
                <QueueItemDescription className="text-destructive">
                  {task.error}
                </QueueItemDescription>
              )}
src/mastra/agents/scriptWriterAgent.ts (3)

5-5: Remove unused import BaseSpan.

BaseSpan is imported but never used in this file. Per coding guidelines, eliminate dead code.

🔎 Proposed fix
-import { BaseSpan } from '@mastra/observability';

59-61: Update misleading comment.

The comment states "Chat bison for pro as well" but the code returns googleAI, which is a configured model instance from ../config/google. The comment should accurately reflect what model is being used.

🔎 Proposed fix
     } else if (userTier === 'pro') {
-      // Chat bison for pro as well
+      // Use configured Google AI model for pro tier
       return googleAI
     }

67-69: Consider removing empty configuration objects.

The options: {} and scorers: {} are empty and could be omitted if they're not required by the Agent interface, reducing visual noise.

🔎 Proposed fix (if not required by interface)
   memory: pgMemory,
-  options: {},
-  scorers: {
-  },
   tools: {
src/mastra/agents/acpAgent.ts (2)

20-23: Add TSDoc documentation for the public interface.

The ACPContext interface lacks documentation. According to coding guidelines, public APIs should be documented with TSDoc comments.

🔎 Suggested TSDoc documentation
+/**
+ * Context information for ACP Agent requests.
+ * 
+ * @property userId - Optional user identifier for the request
+ * @property userRole - Optional role constraint for the user (e.g., 'user', 'admin')
+ */
 export interface ACPContext {
     userId?: string
     userRole?: string
 }

95-97: Remove the commented-out supermemory tools integration.

The commented-out code at lines 95-97 should be removed entirely. Maintaining commented code blocks violates the coding guideline: "Avoid commenting out dead code. Use version control instead." There are no associated TODOs, FIXMEs, or tracking issues indicating planned development on this feature. If supermemory integration is planned, either add a TODO comment with the tracking issue reference or implement the feature with a proper configuration/feature flag approach instead of keeping commented code.

src/mastra/agents/package-publisher.ts (1)

171-172: Remove commented-out code or convert to proper TODO.

The commented-out tracingPolicy configuration violates the coding guideline: "No commented-out code or unresolved TODO comments without associated tickets should remain in commits."

If the tracing policy is not needed, remove the commented code entirely. If this is a feature that needs to be implemented later, convert it to a proper TODO comment with an associated ticket reference.

As per coding guidelines, rely on git history rather than maintaining commented code blocks.

app/chat/components/chat-header.tsx (1)

283-298: Inconsistent value prop: uses agent.name instead of agent.id.

The ModelSelectorItem for agents uses value={agent.name} (line 285), while the model selector uses value={model.id} (line 235). Using display names as values can cause issues if two agents share the same name, and creates inconsistency between selectors.

🔎 Proposed fix
                      <ModelSelectorItem
                        key={agent.id}
-                        value={agent.name}
+                        value={agent.id}
                        onSelect={() => handleSelectAgent(agent)}
                        className="flex items-center justify-between"
                      >
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4ca7c03 and 5a0b5d6.

📒 Files selected for processing (37)
  • Copilot-Processing.md
  • app/chat/components/agent-chain-of-thought.tsx
  • app/chat/components/agent-checkpoint.tsx
  • app/chat/components/agent-inline-citation.tsx
  • app/chat/components/agent-queue.tsx
  • app/chat/components/chat-header.tsx
  • app/chat/components/chat-input.tsx
  • app/chat/components/chat-sidebar.tsx
  • app/chat/config/google-models.ts
  • app/chat/config/models.ts
  • app/chat/page.tsx
  • app/networks/components/network-header.tsx
  • app/workflows/page.tsx
  • src/mastra/agents/acpAgent.ts
  • src/mastra/agents/businessLegalAgents.ts
  • src/mastra/agents/codingAgents.ts
  • src/mastra/agents/contentStrategistAgent.ts
  • src/mastra/agents/copywriterAgent.ts
  • src/mastra/agents/dane.ts
  • src/mastra/agents/dataExportAgent.ts
  • src/mastra/agents/dataIngestionAgent.ts
  • src/mastra/agents/documentProcessingAgent.ts
  • src/mastra/agents/editorAgent.ts
  • src/mastra/agents/evaluationAgent.ts
  • src/mastra/agents/knowledgeIndexingAgent.ts
  • src/mastra/agents/learningExtractionAgent.ts
  • src/mastra/agents/package-publisher.ts
  • src/mastra/agents/recharts.ts
  • src/mastra/agents/reportAgent.ts
  • src/mastra/agents/researchAgent.ts
  • src/mastra/agents/researchPaperAgent.ts
  • src/mastra/agents/scriptWriterAgent.ts
  • src/mastra/agents/stockAnalysisAgent.ts
  • src/mastra/agents/weather-agent.ts
  • src/mastra/config/pg-storage.ts
  • src/mastra/index.ts
  • src/mastra/tools/web-scraper-tool.ts
🧰 Additional context used
📓 Path-based instructions (35)
**/app/**

📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)

Use the app/ directory structure for route handlers, server components, and client components (Next.js 13+). Prefer this over the pages/ directory for new projects.

Files:

  • app/workflows/page.tsx
  • app/chat/config/models.ts
  • app/chat/components/chat-header.tsx
  • app/chat/components/chat-sidebar.tsx
  • app/chat/page.tsx
  • app/chat/components/agent-queue.tsx
  • app/chat/components/agent-chain-of-thought.tsx
  • app/networks/components/network-header.tsx
  • app/chat/config/google-models.ts
  • app/chat/components/chat-input.tsx
  • app/chat/components/agent-checkpoint.tsx
  • app/chat/components/agent-inline-citation.tsx
**/app/**/page.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)

Represent route UIs using page.tsx or page.jsx files within the app/ directory structure.

Files:

  • app/workflows/page.tsx
  • app/chat/page.tsx
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)

**/*.{js,jsx,ts,tsx}: Use next/dynamic for dynamic imports to load components only when needed, improving initial load time.
Use next/image component for automatic image optimization, including lazy loading and responsive images.
Use React.memo to prevent unnecessary re-renders of components.
Use the <Link prefetch> tag to prefetch pages that are likely to be visited.
Use getServerSideProps, getStaticProps, or server components for fetching data on the server-side.
Use SWR or React Query for client-side data fetching and caching.
Use CSS Modules, Styled Components, or Tailwind CSS for component-level styling. Prefer Tailwind CSS for rapid development.
Use React Context, Zustand, Jotai, or Recoil for managing global state. Avoid Redux unless necessary.
Use react-hook-form for managing forms and validation.
Only fetch the data that is needed by the component to avoid over-fetching.
Avoid long-running synchronous operations in the main thread to prevent blocking.
Always use setState or hooks to update state instead of mutating state directly.
Include a complete dependency array in useEffect hooks to prevent unexpected behavior.
Avoid writing server-side code in client components to prevent exposing secrets or causing unexpected behavior.
Use try...catch blocks for handling errors in asynchronous operations.
Implement error boundary components using getDerivedStateFromError or componentDidCatch lifecycle methods.
Sanitize user input to prevent Cross-Site Scripting (XSS) attacks. Be especially careful when rendering HTML directly from user input.
Store authentication tokens in HTTP-only cookies or local storage securely.
Implement role-based access control to restrict access to sensitive resources.
Clean up event listeners and timers in useEffect hooks to avoid memory leaks.
Only update state when necessary to reduce the number of re-renders and improve performance.
Use immutable data structures and avoid mutating data directly to prevent unexpected...

Files:

  • app/workflows/page.tsx
  • src/mastra/agents/editorAgent.ts
  • src/mastra/agents/researchAgent.ts
  • src/mastra/agents/evaluationAgent.ts
  • app/chat/config/models.ts
  • app/chat/components/chat-header.tsx
  • src/mastra/agents/scriptWriterAgent.ts
  • src/mastra/agents/weather-agent.ts
  • src/mastra/agents/codingAgents.ts
  • app/chat/components/chat-sidebar.tsx
  • src/mastra/agents/contentStrategistAgent.ts
  • app/chat/page.tsx
  • src/mastra/agents/knowledgeIndexingAgent.ts
  • src/mastra/agents/recharts.ts
  • src/mastra/agents/dataExportAgent.ts
  • src/mastra/agents/businessLegalAgents.ts
  • app/chat/components/agent-queue.tsx
  • app/chat/components/agent-chain-of-thought.tsx
  • src/mastra/agents/learningExtractionAgent.ts
  • app/networks/components/network-header.tsx
  • app/chat/config/google-models.ts
  • src/mastra/agents/package-publisher.ts
  • src/mastra/agents/stockAnalysisAgent.ts
  • src/mastra/agents/researchPaperAgent.ts
  • src/mastra/agents/acpAgent.ts
  • src/mastra/index.ts
  • src/mastra/agents/copywriterAgent.ts
  • app/chat/components/chat-input.tsx
  • src/mastra/agents/dane.ts
  • app/chat/components/agent-checkpoint.tsx
  • src/mastra/config/pg-storage.ts
  • src/mastra/tools/web-scraper-tool.ts
  • src/mastra/agents/reportAgent.ts
  • src/mastra/agents/documentProcessingAgent.ts
  • app/chat/components/agent-inline-citation.tsx
  • src/mastra/agents/dataIngestionAgent.ts
app/**/*.{tsx,ts}

📄 CodeRabbit inference engine (app/AGENTS.md)

app/**/*.{tsx,ts}: Use Tailwind CSS 4 with oklch color variables for styling in Next.js App Router pages and layouts
Use React 19 latest features in component implementations within the app directory

Files:

  • app/workflows/page.tsx
  • app/chat/config/models.ts
  • app/chat/components/chat-header.tsx
  • app/chat/components/chat-sidebar.tsx
  • app/chat/page.tsx
  • app/chat/components/agent-queue.tsx
  • app/chat/components/agent-chain-of-thought.tsx
  • app/networks/components/network-header.tsx
  • app/chat/config/google-models.ts
  • app/chat/components/chat-input.tsx
  • app/chat/components/agent-checkpoint.tsx
  • app/chat/components/agent-inline-citation.tsx
**/*.{ts,tsx,js,jsx,py,java,cs,rb,go,rs,cpp,c,h,hpp,swift,kotlin,php,scala,clj,groovy,lua,sh,bash}

📄 CodeRabbit inference engine (.github/instructions/self-explanatory-code-commenting.instructions.md)

**/*.{ts,tsx,js,jsx,py,java,cs,rb,go,rs,cpp,c,h,hpp,swift,kotlin,php,scala,clj,groovy,lua,sh,bash}: Write code that speaks for itself. Comment only when necessary to explain WHY, not WHAT. Avoid obvious comments that state what the code literally does.
Avoid redundant comments that simply repeat what the code is doing
Keep comments accurate and up-to-date with code changes. Remove or update outdated comments that no longer match the implementation.
Write comments for complex business logic that explain the WHY behind specific calculations or business rules
Document non-obvious algorithms with comments explaining the algorithm choice and its reasoning
Add comments explaining what regex patterns match, especially for complex patterns
Document API constraints, rate limits, gotchas, and external dependencies with explanatory comments
Avoid commenting out dead code. Use version control instead of maintaining commented code blocks.
Do not maintain code change history or modification logs as comments. Rely on git history and commit messages instead.
Avoid decorative divider comments (e.g., lines of equals signs or asterisks) for section separation
Ensure comments are placed appropriately above or adjacent to the code they describe
Write comments using proper grammar, spelling, and professional language
Prefer self-documenting code with clear variable/function names over adding comments to explain unclear code

Files:

  • app/workflows/page.tsx
  • src/mastra/agents/editorAgent.ts
  • src/mastra/agents/researchAgent.ts
  • src/mastra/agents/evaluationAgent.ts
  • app/chat/config/models.ts
  • app/chat/components/chat-header.tsx
  • src/mastra/agents/scriptWriterAgent.ts
  • src/mastra/agents/weather-agent.ts
  • src/mastra/agents/codingAgents.ts
  • app/chat/components/chat-sidebar.tsx
  • src/mastra/agents/contentStrategistAgent.ts
  • app/chat/page.tsx
  • src/mastra/agents/knowledgeIndexingAgent.ts
  • src/mastra/agents/recharts.ts
  • src/mastra/agents/dataExportAgent.ts
  • src/mastra/agents/businessLegalAgents.ts
  • app/chat/components/agent-queue.tsx
  • app/chat/components/agent-chain-of-thought.tsx
  • src/mastra/agents/learningExtractionAgent.ts
  • app/networks/components/network-header.tsx
  • app/chat/config/google-models.ts
  • src/mastra/agents/package-publisher.ts
  • src/mastra/agents/stockAnalysisAgent.ts
  • src/mastra/agents/researchPaperAgent.ts
  • src/mastra/agents/acpAgent.ts
  • src/mastra/index.ts
  • src/mastra/agents/copywriterAgent.ts
  • app/chat/components/chat-input.tsx
  • src/mastra/agents/dane.ts
  • app/chat/components/agent-checkpoint.tsx
  • src/mastra/config/pg-storage.ts
  • src/mastra/tools/web-scraper-tool.ts
  • src/mastra/agents/reportAgent.ts
  • src/mastra/agents/documentProcessingAgent.ts
  • app/chat/components/agent-inline-citation.tsx
  • src/mastra/agents/dataIngestionAgent.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/instructions/self-explanatory-code-commenting.instructions.md)

**/*.{ts,tsx,js,jsx}: Document public APIs with TSDoc/JSDoc comments including parameter descriptions, return types, examples, and thrown exceptions
Add TSDoc comments to configuration constants and environment variables explaining their source, reasoning, or constraints
Use TSDoc annotation tags (TODO, FIXME, HACK, NOTE, WARNING, PERF, SECURITY, BUG, REFACTOR, DEPRECATED) to mark special comments
Include file headers with @fileoverview, @author, @copyright, and @license tags to document file purpose and ownership
Document function parameters with @param tags, return values with @returns tags, and exceptions with @throws tags in TSDoc comments
Use @see tags in TSDoc comments to reference related functions, methods, or documentation
Include @example tags in public API documentation with code examples showing typical usage

Use ESLint configuration from eslint.config.cjs with TypeScript rules and Prettier integration

Files:

  • app/workflows/page.tsx
  • src/mastra/agents/editorAgent.ts
  • src/mastra/agents/researchAgent.ts
  • src/mastra/agents/evaluationAgent.ts
  • app/chat/config/models.ts
  • app/chat/components/chat-header.tsx
  • src/mastra/agents/scriptWriterAgent.ts
  • src/mastra/agents/weather-agent.ts
  • src/mastra/agents/codingAgents.ts
  • app/chat/components/chat-sidebar.tsx
  • src/mastra/agents/contentStrategistAgent.ts
  • app/chat/page.tsx
  • src/mastra/agents/knowledgeIndexingAgent.ts
  • src/mastra/agents/recharts.ts
  • src/mastra/agents/dataExportAgent.ts
  • src/mastra/agents/businessLegalAgents.ts
  • app/chat/components/agent-queue.tsx
  • app/chat/components/agent-chain-of-thought.tsx
  • src/mastra/agents/learningExtractionAgent.ts
  • app/networks/components/network-header.tsx
  • app/chat/config/google-models.ts
  • src/mastra/agents/package-publisher.ts
  • src/mastra/agents/stockAnalysisAgent.ts
  • src/mastra/agents/researchPaperAgent.ts
  • src/mastra/agents/acpAgent.ts
  • src/mastra/index.ts
  • src/mastra/agents/copywriterAgent.ts
  • app/chat/components/chat-input.tsx
  • src/mastra/agents/dane.ts
  • app/chat/components/agent-checkpoint.tsx
  • src/mastra/config/pg-storage.ts
  • src/mastra/tools/web-scraper-tool.ts
  • src/mastra/agents/reportAgent.ts
  • src/mastra/agents/documentProcessingAgent.ts
  • app/chat/components/agent-inline-citation.tsx
  • src/mastra/agents/dataIngestionAgent.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/instructions/self-explanatory-code-commenting.instructions.md)

**/*.{ts,tsx}: Document interface and type definitions with TSDoc comments explaining their purpose and usage context
Document interface properties with /** */ comments explaining each field's purpose and constraints
Document generic type parameters with @template tags explaining what each type parameter represents
Use type guards with comments explaining the runtime validation logic being performed
Document advanced/complex TypeScript types with explanatory comments about their purpose and use cases

Files:

  • app/workflows/page.tsx
  • src/mastra/agents/editorAgent.ts
  • src/mastra/agents/researchAgent.ts
  • src/mastra/agents/evaluationAgent.ts
  • app/chat/config/models.ts
  • app/chat/components/chat-header.tsx
  • src/mastra/agents/scriptWriterAgent.ts
  • src/mastra/agents/weather-agent.ts
  • src/mastra/agents/codingAgents.ts
  • app/chat/components/chat-sidebar.tsx
  • src/mastra/agents/contentStrategistAgent.ts
  • app/chat/page.tsx
  • src/mastra/agents/knowledgeIndexingAgent.ts
  • src/mastra/agents/recharts.ts
  • src/mastra/agents/dataExportAgent.ts
  • src/mastra/agents/businessLegalAgents.ts
  • app/chat/components/agent-queue.tsx
  • app/chat/components/agent-chain-of-thought.tsx
  • src/mastra/agents/learningExtractionAgent.ts
  • app/networks/components/network-header.tsx
  • app/chat/config/google-models.ts
  • src/mastra/agents/package-publisher.ts
  • src/mastra/agents/stockAnalysisAgent.ts
  • src/mastra/agents/researchPaperAgent.ts
  • src/mastra/agents/acpAgent.ts
  • src/mastra/index.ts
  • src/mastra/agents/copywriterAgent.ts
  • app/chat/components/chat-input.tsx
  • src/mastra/agents/dane.ts
  • app/chat/components/agent-checkpoint.tsx
  • src/mastra/config/pg-storage.ts
  • src/mastra/tools/web-scraper-tool.ts
  • src/mastra/agents/reportAgent.ts
  • src/mastra/agents/documentProcessingAgent.ts
  • app/chat/components/agent-inline-citation.tsx
  • src/mastra/agents/dataIngestionAgent.ts
app/workflows/page.tsx

📄 CodeRabbit inference engine (app/workflows/AGENTS.md)

Main page component in app/workflows/page.tsx should be clean and minimal, delegating UI logic to subcomponents

Files:

  • app/workflows/page.tsx
**/*.{js,ts,jsx,tsx,java,py,cs,go,rb,php,swift,kt,scala,rs,cpp,c,h}

📄 CodeRabbit inference engine (.github/instructions/code-review-generic.instructions.md)

**/*.{js,ts,jsx,tsx,java,py,cs,go,rb,php,swift,kt,scala,rs,cpp,c,h}: Use descriptive and meaningful names for variables, functions, and classes
Apply Single Responsibility Principle: each function/class does one thing well
Follow DRY (Don't Repeat Yourself): eliminate code duplication
Keep functions small and focused (ideally < 20-30 lines)
Avoid deeply nested code (max 3-4 levels)
Avoid magic numbers and strings; use named constants instead
Code should be self-documenting; use comments only when necessary
Implement proper error handling at appropriate levels with meaningful error messages
Avoid silent failures or ignored exceptions; fail fast and validate inputs early
Use appropriate error types/exceptions with meaningful context
Validate and sanitize all user inputs
Use parameterized queries for database access; never use string concatenation for SQL queries
Implement proper authentication checks before accessing resources
Verify user has permission to perform actions; implement proper authorization
Use established cryptographic libraries; never roll your own crypto implementation
Avoid N+1 query problems; use proper indexing and eager loading for database queries
Use appropriate algorithms with suitable time/space complexity for the use case
Utilize caching for expensive or repeated operations
Ensure proper cleanup of connections, files, and streams to prevent resource leaks
Implement pagination for large result sets
Load data only when needed (lazy loading pattern)
Document all public APIs with purpose, parameters, and return values
Add explanatory comments for non-obvious logic
No commented-out code or unresolved TODO comments without associated tickets should remain in commits
Ensure code follows consistent style and conventions with the rest of the codebase

Files:

  • app/workflows/page.tsx
  • src/mastra/agents/editorAgent.ts
  • src/mastra/agents/researchAgent.ts
  • src/mastra/agents/evaluationAgent.ts
  • app/chat/config/models.ts
  • app/chat/components/chat-header.tsx
  • src/mastra/agents/scriptWriterAgent.ts
  • src/mastra/agents/weather-agent.ts
  • src/mastra/agents/codingAgents.ts
  • app/chat/components/chat-sidebar.tsx
  • src/mastra/agents/contentStrategistAgent.ts
  • app/chat/page.tsx
  • src/mastra/agents/knowledgeIndexingAgent.ts
  • src/mastra/agents/recharts.ts
  • src/mastra/agents/dataExportAgent.ts
  • src/mastra/agents/businessLegalAgents.ts
  • app/chat/components/agent-queue.tsx
  • app/chat/components/agent-chain-of-thought.tsx
  • src/mastra/agents/learningExtractionAgent.ts
  • app/networks/components/network-header.tsx
  • app/chat/config/google-models.ts
  • src/mastra/agents/package-publisher.ts
  • src/mastra/agents/stockAnalysisAgent.ts
  • src/mastra/agents/researchPaperAgent.ts
  • src/mastra/agents/acpAgent.ts
  • src/mastra/index.ts
  • src/mastra/agents/copywriterAgent.ts
  • app/chat/components/chat-input.tsx
  • src/mastra/agents/dane.ts
  • app/chat/components/agent-checkpoint.tsx
  • src/mastra/config/pg-storage.ts
  • src/mastra/tools/web-scraper-tool.ts
  • src/mastra/agents/reportAgent.ts
  • src/mastra/agents/documentProcessingAgent.ts
  • app/chat/components/agent-inline-citation.tsx
  • src/mastra/agents/dataIngestionAgent.ts
**/*.{js,ts,jsx,tsx,java,py,cs,go,rb,php,swift,kt,scala,rs,cpp,c,h,json,yaml,yml,env,config}

📄 CodeRabbit inference engine (.github/instructions/code-review-generic.instructions.md)

Never include passwords, API keys, tokens, or PII in code or logs

Files:

  • app/workflows/page.tsx
  • src/mastra/agents/editorAgent.ts
  • src/mastra/agents/researchAgent.ts
  • src/mastra/agents/evaluationAgent.ts
  • app/chat/config/models.ts
  • app/chat/components/chat-header.tsx
  • src/mastra/agents/scriptWriterAgent.ts
  • src/mastra/agents/weather-agent.ts
  • src/mastra/agents/codingAgents.ts
  • app/chat/components/chat-sidebar.tsx
  • src/mastra/agents/contentStrategistAgent.ts
  • app/chat/page.tsx
  • src/mastra/agents/knowledgeIndexingAgent.ts
  • src/mastra/agents/recharts.ts
  • src/mastra/agents/dataExportAgent.ts
  • src/mastra/agents/businessLegalAgents.ts
  • app/chat/components/agent-queue.tsx
  • app/chat/components/agent-chain-of-thought.tsx
  • src/mastra/agents/learningExtractionAgent.ts
  • app/networks/components/network-header.tsx
  • app/chat/config/google-models.ts
  • src/mastra/agents/package-publisher.ts
  • src/mastra/agents/stockAnalysisAgent.ts
  • src/mastra/agents/researchPaperAgent.ts
  • src/mastra/agents/acpAgent.ts
  • src/mastra/index.ts
  • src/mastra/agents/copywriterAgent.ts
  • app/chat/components/chat-input.tsx
  • src/mastra/agents/dane.ts
  • app/chat/components/agent-checkpoint.tsx
  • src/mastra/config/pg-storage.ts
  • src/mastra/tools/web-scraper-tool.ts
  • src/mastra/agents/reportAgent.ts
  • src/mastra/agents/documentProcessingAgent.ts
  • app/chat/components/agent-inline-citation.tsx
  • src/mastra/agents/dataIngestionAgent.ts
**/*.{ts,tsx,java,cs,go,php,swift,kt,scala}

📄 CodeRabbit inference engine (.github/instructions/code-review-generic.instructions.md)

Prefer small, focused interfaces (Interface Segregation Principle)

Files:

  • app/workflows/page.tsx
  • src/mastra/agents/editorAgent.ts
  • src/mastra/agents/researchAgent.ts
  • src/mastra/agents/evaluationAgent.ts
  • app/chat/config/models.ts
  • app/chat/components/chat-header.tsx
  • src/mastra/agents/scriptWriterAgent.ts
  • src/mastra/agents/weather-agent.ts
  • src/mastra/agents/codingAgents.ts
  • app/chat/components/chat-sidebar.tsx
  • src/mastra/agents/contentStrategistAgent.ts
  • app/chat/page.tsx
  • src/mastra/agents/knowledgeIndexingAgent.ts
  • src/mastra/agents/recharts.ts
  • src/mastra/agents/dataExportAgent.ts
  • src/mastra/agents/businessLegalAgents.ts
  • app/chat/components/agent-queue.tsx
  • app/chat/components/agent-chain-of-thought.tsx
  • src/mastra/agents/learningExtractionAgent.ts
  • app/networks/components/network-header.tsx
  • app/chat/config/google-models.ts
  • src/mastra/agents/package-publisher.ts
  • src/mastra/agents/stockAnalysisAgent.ts
  • src/mastra/agents/researchPaperAgent.ts
  • src/mastra/agents/acpAgent.ts
  • src/mastra/index.ts
  • src/mastra/agents/copywriterAgent.ts
  • app/chat/components/chat-input.tsx
  • src/mastra/agents/dane.ts
  • app/chat/components/agent-checkpoint.tsx
  • src/mastra/config/pg-storage.ts
  • src/mastra/tools/web-scraper-tool.ts
  • src/mastra/agents/reportAgent.ts
  • src/mastra/agents/documentProcessingAgent.ts
  • app/chat/components/agent-inline-citation.tsx
  • src/mastra/agents/dataIngestionAgent.ts
**/*.{js,mjs,cjs,ts,tsx,jsx,py,java,cs,go,rb,php,rs,cpp,c,h,hpp}

📄 CodeRabbit inference engine (.github/instructions/update-docs-on-code-change.instructions.md)

Use automated documentation generators for code documentation - JSDoc/TSDoc for JavaScript/TypeScript, Sphinx/pdoc for Python, Javadoc for Java, xmldoc for C#, godoc for Go, rustdoc for Rust

Files:

  • app/workflows/page.tsx
  • src/mastra/agents/editorAgent.ts
  • src/mastra/agents/researchAgent.ts
  • src/mastra/agents/evaluationAgent.ts
  • app/chat/config/models.ts
  • app/chat/components/chat-header.tsx
  • src/mastra/agents/scriptWriterAgent.ts
  • src/mastra/agents/weather-agent.ts
  • src/mastra/agents/codingAgents.ts
  • app/chat/components/chat-sidebar.tsx
  • src/mastra/agents/contentStrategistAgent.ts
  • app/chat/page.tsx
  • src/mastra/agents/knowledgeIndexingAgent.ts
  • src/mastra/agents/recharts.ts
  • src/mastra/agents/dataExportAgent.ts
  • src/mastra/agents/businessLegalAgents.ts
  • app/chat/components/agent-queue.tsx
  • app/chat/components/agent-chain-of-thought.tsx
  • src/mastra/agents/learningExtractionAgent.ts
  • app/networks/components/network-header.tsx
  • app/chat/config/google-models.ts
  • src/mastra/agents/package-publisher.ts
  • src/mastra/agents/stockAnalysisAgent.ts
  • src/mastra/agents/researchPaperAgent.ts
  • src/mastra/agents/acpAgent.ts
  • src/mastra/index.ts
  • src/mastra/agents/copywriterAgent.ts
  • app/chat/components/chat-input.tsx
  • src/mastra/agents/dane.ts
  • app/chat/components/agent-checkpoint.tsx
  • src/mastra/config/pg-storage.ts
  • src/mastra/tools/web-scraper-tool.ts
  • src/mastra/agents/reportAgent.ts
  • src/mastra/agents/documentProcessingAgent.ts
  • app/chat/components/agent-inline-citation.tsx
  • src/mastra/agents/dataIngestionAgent.ts
app/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

app/**/*.{ts,tsx}: Use Next.js 16 App Router with React 19 for frontend development
Use MastraClient for fetching agent, workflow, tool, and thread data in frontend applications

Files:

  • app/workflows/page.tsx
  • app/chat/config/models.ts
  • app/chat/components/chat-header.tsx
  • app/chat/components/chat-sidebar.tsx
  • app/chat/page.tsx
  • app/chat/components/agent-queue.tsx
  • app/chat/components/agent-chain-of-thought.tsx
  • app/networks/components/network-header.tsx
  • app/chat/config/google-models.ts
  • app/chat/components/chat-input.tsx
  • app/chat/components/agent-checkpoint.tsx
  • app/chat/components/agent-inline-citation.tsx
**/*.tsx

📄 CodeRabbit inference engine (AGENTS.md)

Style UI components with Tailwind CSS 4 using oklch color variables

Files:

  • app/workflows/page.tsx
  • app/chat/components/chat-header.tsx
  • app/chat/components/chat-sidebar.tsx
  • app/chat/page.tsx
  • app/chat/components/agent-queue.tsx
  • app/chat/components/agent-chain-of-thought.tsx
  • app/networks/components/network-header.tsx
  • app/chat/components/chat-input.tsx
  • app/chat/components/agent-checkpoint.tsx
  • app/chat/components/agent-inline-citation.tsx
**/*.{ts,tsx,js,jsx,json,md}

📄 CodeRabbit inference engine (AGENTS.md)

Use Prettier for code formatting with ES5 trailing commas, 4-space tabs, and single quotes

Files:

  • app/workflows/page.tsx
  • src/mastra/agents/editorAgent.ts
  • src/mastra/agents/researchAgent.ts
  • src/mastra/agents/evaluationAgent.ts
  • app/chat/config/models.ts
  • app/chat/components/chat-header.tsx
  • src/mastra/agents/scriptWriterAgent.ts
  • src/mastra/agents/weather-agent.ts
  • src/mastra/agents/codingAgents.ts
  • app/chat/components/chat-sidebar.tsx
  • src/mastra/agents/contentStrategistAgent.ts
  • app/chat/page.tsx
  • Copilot-Processing.md
  • src/mastra/agents/knowledgeIndexingAgent.ts
  • src/mastra/agents/recharts.ts
  • src/mastra/agents/dataExportAgent.ts
  • src/mastra/agents/businessLegalAgents.ts
  • app/chat/components/agent-queue.tsx
  • app/chat/components/agent-chain-of-thought.tsx
  • src/mastra/agents/learningExtractionAgent.ts
  • app/networks/components/network-header.tsx
  • app/chat/config/google-models.ts
  • src/mastra/agents/package-publisher.ts
  • src/mastra/agents/stockAnalysisAgent.ts
  • src/mastra/agents/researchPaperAgent.ts
  • src/mastra/agents/acpAgent.ts
  • src/mastra/index.ts
  • src/mastra/agents/copywriterAgent.ts
  • app/chat/components/chat-input.tsx
  • src/mastra/agents/dane.ts
  • app/chat/components/agent-checkpoint.tsx
  • src/mastra/config/pg-storage.ts
  • src/mastra/tools/web-scraper-tool.ts
  • src/mastra/agents/reportAgent.ts
  • src/mastra/agents/documentProcessingAgent.ts
  • app/chat/components/agent-inline-citation.tsx
  • src/mastra/agents/dataIngestionAgent.ts
app/**/*.tsx

📄 CodeRabbit inference engine (AGENTS.md)

Use TanStack Query hooks from lib/hooks/use-dashboard-queries.ts for agents, workflows, tools, traces, threads, and messages

Files:

  • app/workflows/page.tsx
  • app/chat/components/chat-header.tsx
  • app/chat/components/chat-sidebar.tsx
  • app/chat/page.tsx
  • app/chat/components/agent-queue.tsx
  • app/chat/components/agent-chain-of-thought.tsx
  • app/networks/components/network-header.tsx
  • app/chat/components/chat-input.tsx
  • app/chat/components/agent-checkpoint.tsx
  • app/chat/components/agent-inline-citation.tsx
**/*.{js,ts}

📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)

Use parameterized queries or an ORM to prevent SQL injection attacks.

Files:

  • src/mastra/agents/editorAgent.ts
  • src/mastra/agents/researchAgent.ts
  • src/mastra/agents/evaluationAgent.ts
  • app/chat/config/models.ts
  • src/mastra/agents/scriptWriterAgent.ts
  • src/mastra/agents/weather-agent.ts
  • src/mastra/agents/codingAgents.ts
  • src/mastra/agents/contentStrategistAgent.ts
  • src/mastra/agents/knowledgeIndexingAgent.ts
  • src/mastra/agents/recharts.ts
  • src/mastra/agents/dataExportAgent.ts
  • src/mastra/agents/businessLegalAgents.ts
  • src/mastra/agents/learningExtractionAgent.ts
  • app/chat/config/google-models.ts
  • src/mastra/agents/package-publisher.ts
  • src/mastra/agents/stockAnalysisAgent.ts
  • src/mastra/agents/researchPaperAgent.ts
  • src/mastra/agents/acpAgent.ts
  • src/mastra/index.ts
  • src/mastra/agents/copywriterAgent.ts
  • src/mastra/agents/dane.ts
  • src/mastra/config/pg-storage.ts
  • src/mastra/tools/web-scraper-tool.ts
  • src/mastra/agents/reportAgent.ts
  • src/mastra/agents/documentProcessingAgent.ts
  • src/mastra/agents/dataIngestionAgent.ts
src/mastra/agents/*.ts

📄 CodeRabbit inference engine (src/mastra/agents/AGENTS.md)

src/mastra/agents/*.ts: Agent file naming convention: Create agent files using kebab-case with .ts extension in /src/mastra/agents/ directory (e.g., your-agent-name.ts)
Each agent must follow the pattern: export agent as const yourAgent = new Agent({ id: 'your-agent-id', name: 'Your Agent Name', description: '...' })

Files:

  • src/mastra/agents/editorAgent.ts
  • src/mastra/agents/researchAgent.ts
  • src/mastra/agents/evaluationAgent.ts
  • src/mastra/agents/scriptWriterAgent.ts
  • src/mastra/agents/weather-agent.ts
  • src/mastra/agents/codingAgents.ts
  • src/mastra/agents/contentStrategistAgent.ts
  • src/mastra/agents/knowledgeIndexingAgent.ts
  • src/mastra/agents/recharts.ts
  • src/mastra/agents/dataExportAgent.ts
  • src/mastra/agents/businessLegalAgents.ts
  • src/mastra/agents/learningExtractionAgent.ts
  • src/mastra/agents/package-publisher.ts
  • src/mastra/agents/stockAnalysisAgent.ts
  • src/mastra/agents/researchPaperAgent.ts
  • src/mastra/agents/acpAgent.ts
  • src/mastra/agents/copywriterAgent.ts
  • src/mastra/agents/dane.ts
  • src/mastra/agents/reportAgent.ts
  • src/mastra/agents/documentProcessingAgent.ts
  • src/mastra/agents/dataIngestionAgent.ts
src/mastra/**/*

📄 CodeRabbit inference engine (src/AGENTS.md)

mastra modules can import from utils, but must not import from app or cli (except types)

Files:

  • src/mastra/agents/editorAgent.ts
  • src/mastra/agents/researchAgent.ts
  • src/mastra/agents/evaluationAgent.ts
  • src/mastra/agents/scriptWriterAgent.ts
  • src/mastra/agents/weather-agent.ts
  • src/mastra/agents/codingAgents.ts
  • src/mastra/agents/contentStrategistAgent.ts
  • src/mastra/agents/knowledgeIndexingAgent.ts
  • src/mastra/agents/recharts.ts
  • src/mastra/agents/dataExportAgent.ts
  • src/mastra/agents/businessLegalAgents.ts
  • src/mastra/agents/learningExtractionAgent.ts
  • src/mastra/agents/package-publisher.ts
  • src/mastra/agents/stockAnalysisAgent.ts
  • src/mastra/agents/researchPaperAgent.ts
  • src/mastra/agents/acpAgent.ts
  • src/mastra/index.ts
  • src/mastra/agents/copywriterAgent.ts
  • src/mastra/agents/dane.ts
  • src/mastra/config/pg-storage.ts
  • src/mastra/tools/web-scraper-tool.ts
  • src/mastra/agents/reportAgent.ts
  • src/mastra/agents/documentProcessingAgent.ts
  • src/mastra/agents/dataIngestionAgent.ts
src/mastra/agents/**/*.ts

📄 CodeRabbit inference engine (src/mastra/AGENTS.md)

Add agents under src/mastra/agents that wire tools together into higher-level behaviors

Implement agents by composing tools into specialized behaviors using the Mastra agents DSL

Files:

  • src/mastra/agents/editorAgent.ts
  • src/mastra/agents/researchAgent.ts
  • src/mastra/agents/evaluationAgent.ts
  • src/mastra/agents/scriptWriterAgent.ts
  • src/mastra/agents/weather-agent.ts
  • src/mastra/agents/codingAgents.ts
  • src/mastra/agents/contentStrategistAgent.ts
  • src/mastra/agents/knowledgeIndexingAgent.ts
  • src/mastra/agents/recharts.ts
  • src/mastra/agents/dataExportAgent.ts
  • src/mastra/agents/businessLegalAgents.ts
  • src/mastra/agents/learningExtractionAgent.ts
  • src/mastra/agents/package-publisher.ts
  • src/mastra/agents/stockAnalysisAgent.ts
  • src/mastra/agents/researchPaperAgent.ts
  • src/mastra/agents/acpAgent.ts
  • src/mastra/agents/copywriterAgent.ts
  • src/mastra/agents/dane.ts
  • src/mastra/agents/reportAgent.ts
  • src/mastra/agents/documentProcessingAgent.ts
  • src/mastra/agents/dataIngestionAgent.ts
src/mastra/**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

Use maskSensitiveMessageData() helper from src/mastra/config/pg-storage.ts to mask secrets in logs

Files:

  • src/mastra/agents/editorAgent.ts
  • src/mastra/agents/researchAgent.ts
  • src/mastra/agents/evaluationAgent.ts
  • src/mastra/agents/scriptWriterAgent.ts
  • src/mastra/agents/weather-agent.ts
  • src/mastra/agents/codingAgents.ts
  • src/mastra/agents/contentStrategistAgent.ts
  • src/mastra/agents/knowledgeIndexingAgent.ts
  • src/mastra/agents/recharts.ts
  • src/mastra/agents/dataExportAgent.ts
  • src/mastra/agents/businessLegalAgents.ts
  • src/mastra/agents/learningExtractionAgent.ts
  • src/mastra/agents/package-publisher.ts
  • src/mastra/agents/stockAnalysisAgent.ts
  • src/mastra/agents/researchPaperAgent.ts
  • src/mastra/agents/acpAgent.ts
  • src/mastra/index.ts
  • src/mastra/agents/copywriterAgent.ts
  • src/mastra/agents/dane.ts
  • src/mastra/config/pg-storage.ts
  • src/mastra/tools/web-scraper-tool.ts
  • src/mastra/agents/reportAgent.ts
  • src/mastra/agents/documentProcessingAgent.ts
  • src/mastra/agents/dataIngestionAgent.ts
**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

Use TypeScript with ES2022 target and Next.js path aliases configured in tsconfig.json

Files:

  • src/mastra/agents/editorAgent.ts
  • src/mastra/agents/researchAgent.ts
  • src/mastra/agents/evaluationAgent.ts
  • app/chat/config/models.ts
  • src/mastra/agents/scriptWriterAgent.ts
  • src/mastra/agents/weather-agent.ts
  • src/mastra/agents/codingAgents.ts
  • src/mastra/agents/contentStrategistAgent.ts
  • src/mastra/agents/knowledgeIndexingAgent.ts
  • src/mastra/agents/recharts.ts
  • src/mastra/agents/dataExportAgent.ts
  • src/mastra/agents/businessLegalAgents.ts
  • src/mastra/agents/learningExtractionAgent.ts
  • app/chat/config/google-models.ts
  • src/mastra/agents/package-publisher.ts
  • src/mastra/agents/stockAnalysisAgent.ts
  • src/mastra/agents/researchPaperAgent.ts
  • src/mastra/agents/acpAgent.ts
  • src/mastra/index.ts
  • src/mastra/agents/copywriterAgent.ts
  • src/mastra/agents/dane.ts
  • src/mastra/config/pg-storage.ts
  • src/mastra/tools/web-scraper-tool.ts
  • src/mastra/agents/reportAgent.ts
  • src/mastra/agents/documentProcessingAgent.ts
  • src/mastra/agents/dataIngestionAgent.ts
**/components/**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)

Use PascalCase for component file names (e.g., ComponentName.jsx or ComponentName.tsx).

Files:

  • app/chat/components/chat-header.tsx
  • app/chat/components/chat-sidebar.tsx
  • app/chat/components/agent-queue.tsx
  • app/chat/components/agent-chain-of-thought.tsx
  • app/networks/components/network-header.tsx
  • app/chat/components/chat-input.tsx
  • app/chat/components/agent-checkpoint.tsx
  • app/chat/components/agent-inline-citation.tsx
app/chat/components/**/*.{ts,tsx}

📄 CodeRabbit inference engine (app/chat/AGENTS.md)

app/chat/components/**/*.{ts,tsx}: Use AI SDK v5 types and patterns in chat components: import types like UIMessage, DynamicToolUIPart, TextUIPart, ReasoningUIPart from 'ai' and use type guard functions like isTextUIPart, isReasoningUIPart, isToolOrDynamicToolUIPart to filter message parts
Access message content through message.parts array using type guards rather than message.content, extracting specific parts like text using const textPart = message.parts?.find(isTextUIPart)
Handle Mastra stream chunk types correctly: use 'text-delta' for streaming text, 'reasoning-delta' for streaming reasoning (NOT 'reasoning'), 'tool-call' for tool invocation, 'tool-result' for tool completion, 'source' for research sources, and 'finish' for completion with usage data
Use AI Elements components (Conversation, Message, PromptInput, ModelSelector, Reasoning, Tool, Sources, Artifact) from the AI Elements library in their respective chat component files as specified in the architecture

Files:

  • app/chat/components/chat-header.tsx
  • app/chat/components/chat-sidebar.tsx
  • app/chat/components/agent-queue.tsx
  • app/chat/components/agent-chain-of-thought.tsx
  • app/chat/components/chat-input.tsx
  • app/chat/components/agent-checkpoint.tsx
  • app/chat/components/agent-inline-citation.tsx
app/chat/components/chat-header.tsx

📄 CodeRabbit inference engine (app/chat/AGENTS.md)

Implement ChatHeader component with ModelSelector to allow users to select from 26+ configured agents and switch between them

Files:

  • app/chat/components/chat-header.tsx
app/chat/**/*.tsx

📄 CodeRabbit inference engine (AGENTS.md)

Use @ai-sdk/react for streaming and AI-powered React hooks in chat interfaces

Files:

  • app/chat/components/chat-header.tsx
  • app/chat/components/chat-sidebar.tsx
  • app/chat/page.tsx
  • app/chat/components/agent-queue.tsx
  • app/chat/components/agent-chain-of-thought.tsx
  • app/chat/components/chat-input.tsx
  • app/chat/components/agent-checkpoint.tsx
  • app/chat/components/agent-inline-citation.tsx
**/*.md

📄 CodeRabbit inference engine (.github/instructions/markdown.instructions.md)

**/*.md: Use appropriate heading levels (H2, H3, etc.) to structure markdown content. Do not use H1 headings, as these will be generated from the title. Use ## for H2 and ### for H3 in a hierarchical manner. Recommend restructuring if content includes H4 or higher levels.
Use bullet points (with -) or numbered lists (with 1.) for lists in markdown. Indent nested lists with two spaces and ensure proper indentation and spacing.
Use fenced code blocks (triple backticks) for code snippets in markdown. Specify the language after the opening backticks for syntax highlighting (e.g., csharp).
Use proper markdown syntax for links: [link text](URL). Ensure that link text is descriptive and URLs are valid and accessible.
Use proper markdown syntax for images: ![alt text](image URL). Include a brief description of the image in the alt text for accessibility.
Use markdown tables (with | delimiters) for tabular data. Ensure proper formatting, alignment, and inclusion of headers.
Limit line length to 80 characters in markdown for readability. Use soft line breaks for long paragraphs.
Use appropriate whitespace in markdown to separate sections and improve readability. Use blank lines between sections and avoid excessive whitespace.
Include YAML front matter at the beginning of markdown files with required metadata fields: post_title, author1, post_slug, microsoft_alias, featured_image, categories (from /categories.txt), tags, ai_note, summary, and post_date.

Files:

  • Copilot-Processing.md
app/networks/**/*.tsx

📄 CodeRabbit inference engine (app/networks/AGENTS.md)

app/networks/**/*.tsx: Use useChat from @ai-sdk/react with DefaultChatTransport for streaming responses from the /network route in the networks feature
Support real-time streaming with stop/cancel functionality, reasoning visualization for chain-of-thought models, and tool invocation display showing agent tool calls
Provide a responsive layout with collapsible sidebar on mobile for the networks feature

Files:

  • app/networks/components/network-header.tsx
src/mastra/index.ts

📄 CodeRabbit inference engine (src/AGENTS.md)

Enforce registration pattern in mastra/index.ts for AI orchestration modules composition

Files:

  • src/mastra/index.ts
app/chat/components/chat-input.tsx

📄 CodeRabbit inference engine (app/chat/AGENTS.md)

Implement ChatInput component with PromptInput AI Elements for message submission, including support for file attachments when fileUpload is enabled for the selected agent

Files:

  • app/chat/components/chat-input.tsx
src/mastra/config/pg-storage.ts

📄 CodeRabbit inference engine (src/mastra/config/AGENTS.md)

src/mastra/config/pg-storage.ts: PostgreSQL storage configuration must include PgVector support for embeddings, memory, and thread persistence
Database connection must use the SUPABASE environment variable with optional performance tuning via DB_MAX_CONNECTIONS, DB_IDLE_TIMEOUT, and DB_CONNECTION_TIMEOUT
Memory configuration must support MEMORY_LAST_MESSAGES, SEMANTIC_TOP_K, SEMANTIC_RANGE_BEFORE, SEMANTIC_RANGE_AFTER, and LISTS environment variables
RAG configuration must support GRAPH_THRESHOLD, GRAPH_RANDOM_WALK_STEPS, GRAPH_RESTART_PROB, PG_MIN_SCORE, and PG_EF environment variables

Files:

  • src/mastra/config/pg-storage.ts
src/mastra/config/**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

src/mastra/config/**/*.ts: Use PostgreSQL with PgVector for vector storage and persistence in pg-storage
Store centralized provider clients (Google, OpenAI, Anthropic, OpenRouter, Vertex) in src/mastra/config

Files:

  • src/mastra/config/pg-storage.ts
src/mastra/tools/**/*.ts

📄 CodeRabbit inference engine (src/mastra/AGENTS.md)

src/mastra/tools/**/*.ts: Add new tools under src/mastra/tools following the createTool pattern with Zod schemas
Use explicit Zod schemas for every tool input/output
Keep tools small and side-effect-free when possible; agents orchestrate tools and handle context

src/mastra/tools/**/*.ts: Use Zod schemas for strict validation of tool inputs and outputs in Mastra tools
Implement tools with createTool() pattern: createTool({ id, inputSchema, outputSchema, execute })

Files:

  • src/mastra/tools/web-scraper-tool.ts
src/mastra/{tools,workflows}/**/*.ts

📄 CodeRabbit inference engine (src/mastra/AGENTS.md)

Use RequestContext (per-request) or agent-specific runtime context types (e.g. EditorRuntimeContext) to enforce access control in tools and workflows

Files:

  • src/mastra/tools/web-scraper-tool.ts
src/mastra/tools/**/{web-scraper-tool.ts,browser-tool.ts}

📄 CodeRabbit inference engine (src/mastra/tools/AGENTS.md)

Web scraping tools (Web Scraper, Browser Tool) must use Playwright and Cheerio for HTML parsing

Files:

  • src/mastra/tools/web-scraper-tool.ts
🧬 Code graph analysis (6)
app/chat/components/chat-header.tsx (1)
src/components/ai-elements/model-selector.tsx (4)
  • ModelSelectorTrigger (29-31)
  • ModelSelectorContent (37-49)
  • ModelSelectorInput (59-64)
  • ModelSelectorList (68-70)
app/chat/components/chat-sidebar.tsx (4)
app/chat/providers/chat-context.tsx (1)
  • useChatContext (137-143)
ui/badge.tsx (1)
  • Badge (46-46)
ui/input.tsx (1)
  • Input (21-21)
ui/button.tsx (1)
  • Button (60-60)
app/chat/page.tsx (3)
app/chat/providers/chat-context.tsx (1)
  • ChatProvider (154-578)
app/chat/components/chat-messages.tsx (1)
  • ChatMessages (763-907)
app/chat/components/chat-sidebar.tsx (1)
  • ChatSidebar (24-198)
app/chat/components/agent-queue.tsx (1)
src/components/ai-elements/queue.tsx (1)
  • QueueItemDescription (92-107)
app/networks/components/network-header.tsx (2)
ui/button.tsx (1)
  • Button (60-60)
src/components/ai-elements/model-selector.tsx (4)
  • ModelSelectorTrigger (29-31)
  • ModelSelectorContent (37-49)
  • ModelSelectorInput (59-64)
  • ModelSelectorList (68-70)
src/mastra/index.ts (1)
src/mastra/config/logger.ts (1)
  • log (14-18)
🪛 Biome (2.1.2)
app/chat/components/chat-sidebar.tsx

[error] 162-165: A form label must be associated with an input.

Consider adding a for or htmlFor attribute to the label element or moving the input element to inside the label element.

(lint/a11y/noLabelWithoutControl)


[error] 174-177: A form label must be associated with an input.

Consider adding a for or htmlFor attribute to the label element or moving the input element to inside the label element.

(lint/a11y/noLabelWithoutControl)


[error] 133-137: Provide an explicit type prop for the button element.

The default type of a button is submit, which causes the submission of a form when placed inside a form element. This is likely not the behaviour that you want inside a React application.
Allowed button types are: submit, button or reset

(lint/a11y/useButtonType)

⏰ 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: CodeQL analysis (javascript-typescript)
  • GitHub Check: Agent
  • GitHub Check: Sourcery review
  • GitHub Check: Codacy Security Scan
  • GitHub Check: Analyze (javascript-typescript)

status={step.status}
>
{step.duration && step.status === "complete" && (
{(Boolean(step.duration)) && step.status === "complete" && (
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Consider removing redundant Boolean() wrapper.

The explicit Boolean() wrapper is unnecessary since JavaScript already performs implicit truthiness evaluation in conditional contexts. The code would be cleaner as:

-{(Boolean(step.duration)) && step.status === "complete" && (
+{step.duration && step.status === "complete" && (
🤖 Prompt for AI Agents
In app/chat/components/agent-chain-of-thought.tsx around line 62, the
conditional uses an unnecessary Boolean() wrapper: "(Boolean(step.duration)) &&
step.status === 'complete' && (". Remove the Boolean(...) wrapper so the
expression relies on JS truthiness (e.g., "step.duration && step.status ===
'complete' && (") to simplify the code while preserving behavior.

export function AgentInlineCitation({ citations, text }: AgentInlineCitationProps) {
const citation = citations[0]
if (!citation) {return <span>{text}</span>}
if (citations.length === 0) {return <span>{text}</span>}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Suggest formatting the conditional return for readability.

The logic is correct, but placing the return statement on the same line reduces readability.

🔎 Proposed formatting improvement
-  if (citations.length === 0) {return <span>{text}</span>}
+  if (citations.length === 0) {
+    return <span>{text}</span>
+  }
📝 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.

Suggested change
if (citations.length === 0) {return <span>{text}</span>}
if (citations.length === 0) {
return <span>{text}</span>
}
🤖 Prompt for AI Agents
In app/chat/components/agent-inline-citation.tsx around line 27, the conditional
return is written inline ("if (citations.length === 0) {return
<span>{text}</span>}"), which harms readability; refactor it to a multi-line
conditional (use braces and place the return on its own line) so the
empty-citations early-return is clear and consistent with surrounding code
formatting.

Comment on lines +85 to +91
const agentsByCategory = useMemo(() => getAgentsByCategory(), [])

/* Agent Selector - compact dropdown in input toolbar */

// Model Selector


Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Remove empty comment blocks.

Lines 87-90 contain placeholder comments without implementation. Either implement the intended functionality or remove these artifacts.

🔎 Proposed fix
  const agentsByCategory = useMemo(() => getAgentsByCategory(), [])
-
-  /* Agent Selector - compact dropdown in input toolbar */
-  
-  // Model Selector
-  

  const handleSubmit = async (message: { text: string; files: unknown[] }) => {
📝 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.

Suggested change
const agentsByCategory = useMemo(() => getAgentsByCategory(), [])
/* Agent Selector - compact dropdown in input toolbar */
// Model Selector
const agentsByCategory = useMemo(() => getAgentsByCategory(), [])
const handleSubmit = async (message: { text: string; files: unknown[] }) => {
🤖 Prompt for AI Agents
In app/chat/components/chat-input.tsx around lines 85 to 91 there are empty
placeholder comment blocks (lines 87–90) that should be removed or implemented;
delete the unused comment markers and any leftover scaffolding if no feature is
intended, or replace them with the actual Agent Selector / Model Selector
implementation (hook/state/UI) if you planned to add functionality—ensure there
are no naked comment blocks left behind and that the code compiles after removal
or replacement.

Comment on lines +229 to +234
<PromptInputButton title="Select model">
<SparklesIcon className="size-4" />
<span className="hidden sm:inline ml-1 text-xs">
{selectedModel.name.split(" ")[0]}
</span>
</PromptInputButton>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Brittle string manipulation for model name display.

selectedModel.name.split(" ")[0] assumes the first word is meaningful. This could produce unexpected results for models with names like "Gemini 3 Flash Preview" (shows only "Gemini"). Consider using a truncation approach or a dedicated short name field.

🔎 Alternative approach
                  <PromptInputButton title="Select model">
                    <SparklesIcon className="size-4" />
                    <span className="hidden sm:inline ml-1 text-xs truncate max-w-20">
-                     {selectedModel.name.split(" ")[0]}
+                     {selectedModel.name}
                    </span>
                  </PromptInputButton>

Or add a shortName field to ModelConfig for explicit control over the abbreviated display.

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

Suggested change
<PromptInputButton title="Select model">
<SparklesIcon className="size-4" />
<span className="hidden sm:inline ml-1 text-xs">
{selectedModel.name.split(" ")[0]}
</span>
</PromptInputButton>
<PromptInputButton title="Select model">
<SparklesIcon className="size-4" />
<span className="hidden sm:inline ml-1 text-xs truncate max-w-20">
{selectedModel.name}
</span>
</PromptInputButton>
🤖 Prompt for AI Agents
In app/chat/components/chat-input.tsx around lines 229 to 234, the UI currently
uses selectedModel.name.split(" ")[0] which is brittle; replace this with a
stable short-display value: prefer a new selectedModel.shortName (add shortName
to ModelConfig/type and populate where models are defined), and fall back to a
safe truncation of selectedModel.name (e.g., take the first N characters and add
“…” if longer) instead of splitting by spaces; update usages and tests
accordingly so the button shows either shortName or a truncated name.

Comment on lines +33 to +34
selectedModel,
} = useChatContext()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Unused variable: selectedModel is destructured but never used.

Remove unused destructured value to keep the code clean.

🔎 Proposed fix
  const {
    agentConfig,
    checkpoints,
    restoreCheckpoint,
    threadId,
    resourceId,
    setThreadId,
    setResourceId,
-   selectedModel,
  } = useChatContext()
📝 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.

Suggested change
selectedModel,
} = useChatContext()
const {
agentConfig,
checkpoints,
restoreCheckpoint,
threadId,
resourceId,
setThreadId,
setResourceId,
} = useChatContext()
🤖 Prompt for AI Agents
In app/chat/components/chat-sidebar.tsx around lines 33 to 34, the hook
destructures selectedModel from useChatContext but the variable is never used;
remove selectedModel from the destructuring to eliminate the unused variable and
keep imports/usage unchanged (only delete selectedModel from the object pattern)
so lint/errors go away.

Comment on lines +18 to 24
# Package Location Rules
- **Core**: packages/{core,deployer,cli,engine,evals,rag,memory,mcp,loggers}
- **Deployers**: deployers/{cloudflare,vercel,netlify} (STRICT: No other dirs)
- **Stores**: stores/{name} (e.g., @mastra/pg -> stores/pg)
- **Speech**: speech/{name} (e.g., @mastra/speech-google -> speech/google)
- **Validation**: No examples/ or integrations/ in paths. Exact matches only.
`;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, let's check the file size and read the entire file to verify line numbers
wc -l src/mastra/agents/package-publisher.ts
cat -n src/mastra/agents/package-publisher.ts | head -180

Repository: ssdeanx/AgentStack

Length of output: 8332


Clarify the inconsistency between package location rules and build execution plan.

The package location schema on line 23 states "No examples/ or integrations/ in paths. Exact matches only," but the BUILD_PACKAGES_PROMPT (lines 65-68) explicitly includes a parallel phase to "Build integrations/ directory packages" using pnpmBuild for each @mastra/integration-* package.

This contradiction requires clarification: Are integrations/ packages excluded from the standardized package locations (per the validation rule) but still built when they exist, or should the validation rule be updated to include integrations/ as a supported location category?

🤖 Prompt for AI Agents
In src/mastra/agents/package-publisher.ts around lines 18 to 24, the package
location rules forbid examples/ or integrations/ while the BUILD_PACKAGES_PROMPT
(lines ~65-68) includes a build phase for @mastra/integration-* packages;
reconcile this by either (A) updating the validation rules to explicitly allow
integrations/ (add integrations/{name} or @mastra/integration-* to the allowed
locations and examples) or (B) removing the integrations build phase from
BUILD_PACKAGES_PROMPT so it matches the validation policy—pick one approach and
update the text and prompt consistently so rules and build plan align.

Comment on lines +180 to 184
- Generate TypeScript React components using Recharts v3.5.0+.
- Create responsive, accessible, and performant chart components.
- Implement proper data typing and prop interfaces.
- Follow React best practices and Recharts patterns.
</expertise>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let's check the actual file content at lines 180-184
cat -n src/mastra/agents/recharts.ts | sed -n '170,195p'

Repository: ssdeanx/AgentStack

Length of output: 1092


🏁 Script executed:

# Check the package.json for Recharts dependency
find . -name "package.json" -type f -exec grep -l "recharts" {} \;

Repository: ssdeanx/AgentStack

Length of output: 76


🏁 Script executed:

# Get more details about the recharts dependency version in package.json
jq '.dependencies, .devDependencies, .optionalDependencies' package.json 2>/dev/null | grep -A 2 -B 2 "recharts"

Repository: ssdeanx/AgentStack

Length of output: 208


🌐 Web query:

Recharts latest stable version npm package

💡 Result:

The latest stable Recharts npm version is 3.6.0 (as of January 3, 2026). [1][2]

Sources:
[1] Snyk package page (recharts) — lists latest version 3.6.0.
[2] jsDocs.io (recharts) — version 3.6.0 published.


Update Recharts version reference to match installed dependency.

The prompt instructs AI to generate components for Recharts v3.5.0+, but the project's package.json specifies "recharts": "^2.15.4". This is a breaking incompatibility—v2.x and v3.x have different APIs. Update the prompt to target Recharts v2.15.4 or upgrade the project dependency to v3.6.0 (latest stable) and test accordingly.

🤖 Prompt for AI Agents
In src/mastra/agents/recharts.ts around lines 180 to 184, the prompt text
references Recharts v3.5.0+ while package.json has "recharts": "^2.15.4",
causing an API mismatch; either change the prompt to target Recharts v2.15.4
(update wording to "Recharts v2.15.4" and adjust any API expectations to v2.x)
or upgrade the project dependency to a compatible v3.x (e.g., update
package.json to "recharts": "^3.6.0", run npm/yarn install, update any code
using v2 APIs to v3 where needed, and run tests) — pick one approach, make the
corresponding change, and ensure generated component code and tests match the
chosen Recharts version.

Comment on lines 98 to 102
indexConfig: {
type: 'flat', // flat index type (supports dimensions > 4000, unlike HNSW limit of 2000)
type: 'hnsw', // flat index type (supports dimensions > 4000, unlike HNSW limit of 2000)
metric: 'cosine', // Distance metric for normalized embeddings
ivf: {lists: parseInt(process.env.LISTS ?? '3072')}, // IVF configuration for flat index
hnsw: { m: 16, efConstruction: 64 } // hnsw configuration
},
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

# Find and check pgvector version in dependencies
fd -E node_modules -type f \( -name "package.json" -o -name "package-lock.json" -o -name "yarn.lock" -o -name "pnpm-lock.yaml" \) | head -5 | xargs -I {} sh -c 'echo "File: {}"; head -100 {}'

Repository: ssdeanx/AgentStack

Length of output: 232


🏁 Script executed:

# Check the current pg-storage.ts file for context
cat -n src/mastra/config/pg-storage.ts | head -120

Repository: ssdeanx/AgentStack

Length of output: 5981


🏁 Script executed:

# Search for any pgvector or dimension-related configuration
rg -n "pgvector|version.*pg|dimension" src/mastra/config/ --type ts

Repository: ssdeanx/AgentStack

Length of output: 5400


🏁 Script executed:

# Look for any README or docs mentioning pgvector requirements
fd -e md "README|INSTALL|SETUP|requirements" | xargs rg -l "pgvector" 2>/dev/null

Repository: ssdeanx/AgentStack

Length of output: 99


🏁 Script executed:

# Search for pgvector version in package.json
jq '.dependencies, .devDependencies' package.json 2>/dev/null | grep -A2 -B2 "pg\|pgvector\|mastra"

Repository: ssdeanx/AgentStack

Length of output: 1230


🏁 Script executed:

# Check for any version specifications in lock files
fd -type f \( -name "package-lock.json" -o -name "pnpm-lock.yaml" -o -name "yarn.lock" \) -exec grep -l "pgvector\|@mastra/pg" {} \;

Repository: ssdeanx/AgentStack

Length of output: 232


🏁 Script executed:

# Search for any documentation or comments about pgvector requirements
rg -n "pgvector.*version|HNSW.*dimension|dimension.*HNSW" --type md

Repository: ssdeanx/AgentStack

Length of output: 277


🏁 Script executed:

# Check @mastra/pg or similar imports to understand the package version
rg -n "@mastra/pg|from.*mastra/pg" src/mastra/config/pg-storage.ts -A 2 -B 2

Repository: ssdeanx/AgentStack

Length of output: 273


🏁 Script executed:

# Check the ADR document for more details about pgvector and dimension decisions
cat -n docs/adr/0001-why-pgvector-and-gemini-embeddings.md

Repository: ssdeanx/AgentStack

Length of output: 1877


🏁 Script executed:

# Search for any pgvector version constraints or documentation about HNSW/flat index support
rg -n "flat|hnsw|pgvector" docs/ -A 2 -B 2

Repository: ssdeanx/AgentStack

Length of output: 2520


🏁 Script executed:

# Check if there are any other references to indexConfig type in the codebase
rg -n "indexConfig.*type|type.*hnsw|type.*flat" src/

Repository: ssdeanx/AgentStack

Length of output: 833


🏁 Script executed:

# Verify the exact line 142 usage in pg-storage.ts
sed -n '138,145p' src/mastra/config/pg-storage.ts

Repository: ssdeanx/AgentStack

Length of output: 360


🏁 Script executed:

# Check mongodb.ts to see both incorrect and correct patterns
sed -n '82,120p' src/mastra/config/mongodb.ts

Repository: ssdeanx/AgentStack

Length of output: 1870


Fix indexConfig to match architectural decision and correct misleading comment.

Line 99's comment contradicts the code and misleads maintainers. More critically, the indexConfig uses type: 'hnsw' which violates ADR 0001 (dated 2025-11-15). The architectural decision explicitly recommends type: 'flat' for 3072-dimensional embeddings due to HNSW dimension limits. Using HNSW with 3072 dimensions may cause runtime failures.

Update to use type: 'flat' as documented in the ADR, following the pattern already implemented in mongodb.ts line 116:

Recommended fix
             indexConfig: {
-                type: 'hnsw', // flat index type (supports dimensions > 4000, unlike HNSW limit of 2000)
+                type: 'flat', // flat index for high-dimensional vectors (3072 dimensions)
                 metric: 'cosine', // Distance metric for normalized embeddings
-                hnsw: { m: 16, efConstruction: 64 } // hnsw configuration
+                ivf: { lists: 4000 } // IVF configuration for flat index
                 },
🤖 Prompt for AI Agents
In src/mastra/config/pg-storage.ts around lines 98 to 102, the indexConfig
incorrectly sets type: 'hnsw' and contains a misleading comment about flat vs
HNSW; update indexConfig to use type: 'flat' to comply with ADR 0001 for
3072-dimensional embeddings, remove the hnsw-specific settings (or omit them
entirely), keep metric: 'cosine', and replace the comment with a short accurate
note stating that flat is used for high-dimensional embeddings as in mongodb.ts
line 116.

Comment thread src/mastra/index.ts
Comment on lines +184 to 185
process.env.SUPABASE! ??
'postgresql://user:password@localhost:5432/mydb',
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Non-null assertion ! is misleading with nullish coalescing ??.

The ! asserts SUPABASE is non-null, but then ?? provides a fallback for null/undefined anyway. If SUPABASE is truly expected to be set, remove the ?? fallback; otherwise, remove the ! to avoid confusion.

🔎 Suggested fix
    connectionString:
-      process.env.SUPABASE! ??
+      process.env.SUPABASE ??
      'postgresql://user:password@localhost:5432/mydb',
📝 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.

Suggested change
process.env.SUPABASE! ??
'postgresql://user:password@localhost:5432/mydb',
process.env.SUPABASE ??
'postgresql://user:password@localhost:5432/mydb',
🤖 Prompt for AI Agents
In src/mastra/index.ts around lines 184-185, the code uses a non-null assertion
on process.env.SUPABASE together with a nullish-coalescing fallback which is
contradictory; either make SUPABASE required by removing the "??
'postgresql://...'" fallback so the non-null assertion is meaningful, or make it
optional by removing the "!" and keeping the fallback (or handling undefined
explicitly). Update the line to choose one of those two options and ensure
surrounding code/types reflect whether SUPABASE can be undefined.

Comment thread src/mastra/index.ts
Comment on lines +341 to +346
async (c, next) => {
const start = Date.now()
await next()
const duration = Date.now() - start
log.info(`${c.req.method} ${c.req.url} - ${duration}ms`)
},
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Request URL logging may expose sensitive query parameters.

The timing logger logs the full c.req.url which could include sensitive query parameters (tokens, PII, etc.). Consider logging only the pathname or sanitizing the URL.

🔎 Suggested fix
      async (c, next) => {
        const start = Date.now()
        await next()
        const duration = Date.now() - start
-        log.info(`${c.req.method} ${c.req.url} - ${duration}ms`)
+        const url = new URL(c.req.url)
+        log.info(`${c.req.method} ${url.pathname} - ${duration}ms`)
      },
🤖 Prompt for AI Agents
In src/mastra/index.ts around lines 341 to 346, the timing middleware currently
logs c.req.url which may include sensitive query parameters; change the log to
exclude or sanitize query data by logging only the request pathname (or parse
the URL and remove/whitelist query params) and optionally mask known sensitive
keys (e.g., token, password, ssn) before logging, preserving method and duration
output.

@ssdeanx ssdeanx merged commit 601fecd into main Jan 3, 2026
225 of 227 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors agent prompts for conciseness, restructures the web scraper tool with improved schema organization, updates vector storage configuration, and introduces new chat UI components.

Key Changes:

  • Agent prompts streamlined from verbose frameworks to condensed protocols across 15+ agents
  • Web scraper tool reorganized into separate schemas (crawling, extraction, request, storage) with nested output structure
  • Vector index changed from 'flat' to 'hnsw' with condensed memory template

Reviewed changes

Copilot reviewed 37 out of 37 changed files in this pull request and generated 31 comments.

Show a summary per file
File Description
src/mastra/tools/web-scraper-tool.ts Restructured input schemas into logical groups and nested output structure (content/storage/analysis)
src/mastra/index.ts Uncommented middleware, routes, and MCP servers; added non-null assertion to SUPABASE env var
src/mastra/config/pg-storage.ts Changed index type from 'flat' to 'hnsw'; condensed memory template
src/mastra/agents/*.ts Consolidated verbose reasoning frameworks into concise protocols; added tool efficiency rules
app/chat/components/chat-sidebar.tsx New component displaying agent details, capabilities, checkpoints, and memory config
app/chat/components/chat-input.tsx Enhanced with model/agent selectors, speech button, checkpoint creation, and context display
app/chat/components/chat-header.tsx Added mt-16 margin and updated Tailwind classes
app/chat/config/google-models.ts Added Gemini 3 Flash Preview and reordered Gemini 3 Pro Preview
app/chat/page.tsx Updated layout to include sidebar with adjusted height calculation
app/workflows/page.tsx Added pt-16 padding for navbar clearance

Comment thread src/mastra/index.ts
// },
await next()
},
//Request timing logger
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

Comment text has irregular spacing: "//Request timing logger" should be "// Request timing logger" (with a space after the slashes). This is inconsistent with standard JavaScript comment formatting conventions.

Copilot uses AI. Check for mistakes.
Comment on lines +51 to +52
# Senior Research Analyst
Tier: ${userTier} | Lang: ${language} | Phase: ${researchPhase}
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

The 'userId' variable has been removed from the agent's system prompt in the refactored version (line 46 of the diff context shows it was previously used). If this was intentional cleanup of unused context, that's fine, but if userId was meant to be included in the new condensed format, it should be added back to line 52.

Copilot uses AI. Check for mistakes.
setResourceId(tempResourceId)
}, [tempThreadId, tempResourceId, setThreadId, setResourceId])

if (!agentConfig) {return null}
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

Early return with missing closing brace. The condition checks if (!agentConfig) {return null} but the opening brace placement on line 44 suggests it should be if (!agentConfig) { return null } with the return statement on the same line or properly formatted. The current formatting is non-standard.

Suggested change
if (!agentConfig) {return null}
if (!agentConfig) {
return null
}

Copilot uses AI. Check for mistakes.
<ModelSelectorEmpty>No agents found.</ModelSelectorEmpty>
{CATEGORY_ORDER.map((category) => {
const agents = agentsByCategory[category]
if (agents.length === 0) {return null}
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

Similar early return formatting issue. The condition if (agents.length === 0) {return null} should be formatted as if (agents.length === 0) return null or with proper spacing around braces for consistency with JavaScript/TypeScript style conventions.

Suggested change
if (agents.length === 0) {return null}
if (agents.length === 0) return null

Copilot uses AI. Check for mistakes.
export function AgentInlineCitation({ citations, text }: AgentInlineCitationProps) {
const citation = citations[0]
if (!citation) {return <span>{text}</span>}
if (citations.length === 0) {return <span>{text}</span>}
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

The original code assigned citations[0] to a variable and checked if it exists. The refactored version checks citations.length === 0 directly which is correct and more efficient. However, the original code would have handled the case where citations array exists but is empty, while this new check might behave differently if citations is undefined (though TypeScript should prevent that). The change is likely fine but verify that citations is always defined as an array.

Copilot uses AI. Check for mistakes.
@@ -32,98 +32,23 @@ export const documentProcessingAgent = new Agent({
const chunkSize = requestContext.get('chunkSize') ?? 512
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

'chunkSize' is assigned a value but never used.

Copilot uses AI. Check for mistakes.
@@ -32,98 +32,23 @@ export const documentProcessingAgent = new Agent({
const chunkSize = requestContext.get('chunkSize') ?? 512
const chunkOverlap = requestContext.get('chunkOverlap') ?? 50
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

'chunkOverlap' is assigned a value but never used.

Copilot uses AI. Check for mistakes.
@@ -32,100 +32,23 @@ export const knowledgeIndexingAgent = new Agent({
const chunkOverlap = requestContext.get('chunkOverlap') ?? 50
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

'chunkOverlap' is assigned a value but never used.

Suggested change
const chunkOverlap = requestContext.get('chunkOverlap') ?? 50

Copilot uses AI. Check for mistakes.
Comment on lines +7 to +19
import {
BotIcon,
CpuIcon,
HistoryIcon,
BookmarkIcon,
SettingsIcon,
DatabaseIcon,
HashIcon,
UserIcon,
CheckCircle2Icon,
CircleIcon,
InfoIcon,
} from "lucide-react"
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

Unused import CpuIcon.

Copilot uses AI. Check for mistakes.
resourceId,
setThreadId,
setResourceId,
selectedModel,
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

Unused variable selectedModel.

Suggested change
selectedModel,

Copilot uses AI. Check for mistakes.
@coderabbitai coderabbitai Bot mentioned this pull request Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants