Conversation
- Introduced Convex RAG tools including: - `convexChunker`: A tool for processing document content and storing chunk embeddings in ConvexVector with configurable chunking strategies and embedding generation. - `convexGraphQueryTool`: A graph-based retrieval augmented generation tool using ConvexVector for semantic search. - `convexVectorQueryTool`: A similarity search tool for semantic content retrieval and question answering using ConvexVector. - `convexRerankerTool`: A tool for reranking initial ConvexVector search results using a semantic reranker with configurable weights. - Implemented input and output schemas for each tool using Zod for validation. - Added logging and tracing capabilities for better observability during tool execution. - Created tests for the calendar tool to ensure functionality: - Validated default source selection based on platform. - Checked explicit source overrides. - Parsed events from ICS calendar exports. - Loaded events from an ICS file on Linux. - Ensured an ICS file is required when falling back to the ICS source on Linux. Co-authored-by: Copilot <copilot@github.com>
…y, agents response are 10x faster. - Overhauled hooks for every tools to be much smoother data flow through each hook and toModelOutput then toOutput - p50 and p99 latency timing is 10x faster for both - Stablized all but one error in git-local.tool feat: add LocalFilesystem commands documentation - Created a new markdown file for LocalFilesystem commands detailing methods such as init, destroy, setAllowedPaths, readFile, writeFile, appendFile, deleteFile, copyFile, moveFile, mkdir, rmdir, readdir, exists, stat, getInfo, and getInstructions. - Included examples for each method and explained path resolution and basePath behavior. feat: add Moltbook API command examples - Introduced a new markdown file with example commands for interacting with the Moltbook API, covering registration, post creation, comments, voting, and community management. feat: implement Moltbook tools - Developed multiple tools for interacting with the Moltbook API, including: - `moltbookRegisterAgentTool`: Registers a new agent profile. - `moltbookGetProfileTool`: Fetches the current agent profile. - `moltbookUpdateProfileTool`: Updates the agent profile. - `moltbookCreatePostTool`: Creates a new post. - `moltbookSearchTool`: Searches Moltbook content. - `moltbookSendMessageTool`: Sends direct messages. - Each tool includes input and output schemas, logging for input and output events, and error handling for missing API keys. Co-authored-by: Copilot <copilot@github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
|
🤖 Hi @ssdeanx, I've received your request, and I'm working on it now! You can track my progress in the logs for more details. |
There was a problem hiding this comment.
Sorry @ssdeanx, your pull request is larger than the review limit of 150000 diff characters
|
🤖 I'm sorry @ssdeanx, but I was unable to process your request. Please see the logs for more details. |
|
Caution Review failedPull request was closed or merged during review Summary by CodeRabbit
WalkthroughThis comprehensive update introduces Convex-backed infrastructure, refactors tool validation and output formatting across 60+ tools, adds new Moltbook API integration, migrates agent memory backends from LibSQL to Convex, and establishes channel configuration abstractions for agent-adapter integration. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
|
There was a problem hiding this comment.
Remark-lint (reported by Codacy) found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
There was a problem hiding this comment.
Code Review
This pull request significantly expands the agent framework by introducing new skills, refactoring channel configurations, and adding a wide array of tools for financial, document, and social media tasks. It also migrates agent memory to Convex and updates the project's environment and dependency structure. Feedback identifies several critical issues, including widespread invalid Zod schema usage across multiple tool files and a potential runtime crash in the Discord webhook tool when handling empty responses. Furthermore, the Cloudflare configuration contains undefined global variables, the calendar tool implementation has regressed into stubs, and a typo was found in the Gemma model versioning. Finally, browser instances should be set to headless mode for production environments.
| startDate: z.iso.datetime({ offset: true }), | ||
| endDate: z.iso.datetime({ offset: true }), |
There was a problem hiding this comment.
Invalid Zod usage: z.iso is not a valid property. To validate ISO 8601 datetimes, use z.string().datetime().
| startDate: z.iso.datetime({ offset: true }), | |
| endDate: z.iso.datetime({ offset: true }), | |
| startDate: z.string().datetime({ offset: true }), | |
| endDate: z.string().datetime({ offset: true }), |
| threads: THREADS_KV, // KVNamespace binding for threads table | ||
| messages: MESSAGES_KV, // KVNamespace binding for messages table |
There was a problem hiding this comment.
THREADS_KV and MESSAGES_KV are used as global variables but are not defined in this scope. In a Cloudflare Worker environment using ES modules, these bindings are typically provided on the env object passed to the handler. If this file is evaluated outside of a Worker context or in an ES module Worker, this will cause a ReferenceError at runtime.
| description: z.string().optional(), | ||
| owner_email: z.email().optional(), | ||
| bio: z.string().optional(), | ||
| website: z.url().optional(), |
| bio: z.string().optional(), | ||
| website: z.url().optional(), | ||
| }) | ||
| .loose() |
| query: z.string(), | ||
| type: z.enum(['posts', 'comments', 'agents', 'submolts']).optional(), | ||
| results: z.array(z.looseObject({})).optional(), | ||
| }) |
| .max(0xffffff) | ||
| .optional() | ||
| .describe('Embed accent color as a 24-bit integer.'), | ||
| timestamp: z |
| }) | ||
|
|
||
| const data = response.ok | ||
| ? ((await response.json()) as DiscordWebhookMessage) |
| } | ||
|
|
||
| return { | ||
| name: sourceKind, |
| observationalMemory: { | ||
| enabled: true, | ||
| scope: 'thread', // 'resource' | 'thread' | ||
| model: 'google/gemma-4-31b-it', |
|
|
||
| export const agentBrowser = new AgentBrowser({ | ||
| headless: true, | ||
| headless: false, |
There was a problem hiding this comment.
Pull request overview
This PR is a broad Mastra tools/config overhaul focused on making tool schemas stricter, improving model-facing outputs (toModelOutput), hardening lifecycle hooks/logging, and introducing new runtime/config surfaces (Convex memory, channel config, Docker/Cloudflare examples).
Changes:
- Standardize many tools to use
strict: true, add/adjust input/output hooks, and implementtoModelOutputmappings for model-facing responses. - Add new tooling/docs/testing around calendar + Moltbook/ACP, plus expand/adjust several data transformation tools (CSV/JSON/PDF).
- Rework runtime/config wiring (Convex-based memory, shared channel config, browser settings, dependency bumps).
Reviewed changes
Copilot reviewed 88 out of 89 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test-results/test-results.json | Updates stored Vitest JSON reporter output. |
| src/mastra/tools/yahoo-finance-stock.tool.ts | Adds strict mode + model output; changes hook logging payloads. |
| src/mastra/tools/write-note.ts | Adds strict mode + toModelOutput; adjusts hook logging. |
| src/mastra/tools/weather-tool.ts | Expands schemas, adds background config + toModelOutput, adds sourceUrl. |
| src/mastra/tools/url-tool.ts | Adds strict mode + safer output logging; minor typing/formatting changes. |
| src/mastra/tools/text-analysis.tool.ts | Adds strict mode, hook logging, and toModelOutput; span input tweaks. |
| src/mastra/tools/tests/calendar-tool.test.ts | Adds cross-platform calendar tool unit tests (Vitest). |
| src/mastra/tools/stooq-stock-market-data.tool.ts | Tightens input schema + adds strict mode and toModelOutput. |
| src/mastra/tools/spatial-index.tool.ts | Tightens JSON typing/schemas + adds strict mode and toModelOutput. |
| src/mastra/tools/serpapi-search.tool.ts | Schema hardening + strict mode + toModelOutput + safer onOutput logging. |
| src/mastra/tools/serpapi-local-maps.tool.ts | Adds strict mode + toModelOutput + safer hook logging. |
| src/mastra/tools/serpapi-images.tool.ts | Adds strict mode + richer toModelOutput; adds hook logging. |
| src/mastra/tools/serpapi-academic-local.tool.ts | Adds strict mode + toModelOutput; adjusts hook signatures/logging. |
| src/mastra/tools/random-generator.tool.ts | Tightens JSON typing/schemas + strict mode + toModelOutput. |
| src/mastra/tools/pdf.ts | Adds strict mode + toModelOutput; refines onOutput logging. |
| src/mastra/tools/leaflet.tool.ts | Tightens JSON schema typing + strict mode + toModelOutput. |
| src/mastra/tools/jwt-auth.tool.ts | Adds strict mode; updates hook signatures/logging. |
| src/mastra/tools/json-to-csv.tool.ts | Uses csv-stringify + strict mode + toModelOutput; improves normalization. |
| src/mastra/tools/index.ts | Exports new tool modules (incl. Moltbook + Convex RAG exports). |
| src/mastra/tools/github.ts | Adds strict mode across tools; improves JSON typing and safer field access. |
| src/mastra/tools/git-local.tool.ts | Resolves repo paths via workspace fs; adds strict mode and input hooks. |
| src/mastra/tools/fetch.tool.ts | Removes abort-signal resolver import; adjusts hook logging + safer output parsing. |
| src/mastra/tools/extractLearningsTool.ts | Adds strict mode + hook logging + more structured toModelOutput. |
| src/mastra/tools/evaluateResultTool.ts | Adds strict mode; adjusts span type + output logging and toModelOutput. |
| src/mastra/tools/editor-agent-tool.ts | Adds strict mode; switches to content-style toModelOutput; refines streaming casts. |
| src/mastra/tools/downsample.tool.ts | Adds strict mode + hook logging; safer output logging. |
| src/mastra/tools/datetime.tool.ts | Adds strict mode + typed result union; removes mastra from span metadata. |
| src/mastra/tools/data/logs/moltbook-commands.md | Adds Moltbook API command examples documentation. |
| src/mastra/tools/data/acp.md | Adds ACP protocol documentation/reference material. |
| src/mastra/tools/cytoscape.tool.ts | Tightens JSON typing + strict mode + toModelOutput; adds input hooks. |
| src/mastra/tools/csv-to-json.tool.ts | Tightens output typing + strict mode + toModelOutput; adds input hooks. |
| src/mastra/tools/confirmation.tool.ts | Adds strict mode; hook signature tweaks; minor formatting fix. |
| src/mastra/tools/color-change-tool.ts | Adds strict mode + toModelOutput; moves output logging after execute. |
| src/mastra/tools/coinbase-exchange-crypto.tool.ts | Adds strict mode + toModelOutput; adjusts hook payloads. |
| src/mastra/tools/chartjs.tool.ts | Tightens JSON typing + strict mode + toModelOutput; refactors scales/title config. |
| src/mastra/tools/calculator.tool.ts | Adds strict mode + toModelOutput across calculator/unit/matrix tools; hook logging. |
| src/mastra/tools/binance-crypto-market.tool.ts | Adds strict mode + toModelOutput; changes hook logging payloads. |
| src/mastra/tools/arxiv.tool.ts | Adds strict mode; hook signature/logging adjustments; safer output logging. |
| src/mastra/tools/alpha-vantage.tool.ts | Tightens JSON typing + strict mode + toModelOutput; hook/logging adjustments. |
| src/mastra/tools/AGENTS.md | Documents workspace filesystem policy + toModelOutput guidance and streaming rules. |
| src/mastra/lib/http-client.ts | Tightens axios typings (Method/headers/params) and adds request data support. |
| src/mastra/index.ts | Removes global temperature unit injection from request context payload. |
| src/mastra/config/libsql.ts | Updates observational memory model configuration. |
| src/mastra/config/index.ts | Exports new channels config barrel. |
| src/mastra/config/duckdb.ts | Updates observational memory model configuration. |
| src/mastra/config/docker.ts | Adds Docker workspace example configuration. |
| src/mastra/config/convex.ts | Adds Convex storage/vector + composite store + memory config. |
| src/mastra/config/cloudflare.ts | Adds Cloudflare storage/deployer example configuration. |
| src/mastra/config/channels.ts | Adds shared channel adapter gating + handler utilities for the research agent. |
| src/mastra/config/AGENTS.md | Documents new channels.ts config module. |
| src/mastra/browsers.ts | Changes agent/stagehand browsers to non-headless by default. |
| src/mastra/agents/supervisor-agent.ts | Switches supervisor agent memory to Convex memory. |
| src/mastra/agents/copywriterAgent.ts | Switches model + memory to Convex memory. |
| src/mastra/agents/browserAgent.ts | Switches memory to Convex memory; increases tool concurrency; uses non-headless browser. |
| skills-lock.json | Adds Convex-related agent skills entries. |
| package.json | Version bump; dependency updates; updates convex script and adds adapter deps. |
| memory-bank/progress.md | Updates progress tracking notes. |
| memory-bank/activeContext.md | Updates active context notes. |
| convex/_generated/ai/ai-files.state.json | Adds Convex AI files state tracking output. |
| AGENTS.md | Adds Convex guidance banner referencing generated guidelines. |
| .env.example | Replaces example secret with placeholder; adds Moltbook key and Discord app id. |
| .agents/skills/convex-setup-auth/agents/openai.yaml | Adds Convex skill metadata for agent usage. |
| .agents/skills/convex-quickstart/agents/openai.yaml | Adds Convex skill metadata for agent usage. |
| .agents/skills/convex-performance-audit/agents/openai.yaml | Adds Convex skill metadata for agent usage. |
| .agents/skills/convex-migration-helper/agents/openai.yaml | Adds Convex skill metadata for agent usage. |
| .agents/skills/convex-create-component/agents/openai.yaml | Adds Convex skill metadata for agent usage. |
| memory-bank/tool-execute-fix/tasks.md | Removes obsolete memory-bank tasks doc. |
| memory-bank/tool-execute-fix/prd.md | Removes obsolete memory-bank PRD doc. |
| memory-bank/tool-execute-fix/design.md | Removes obsolete memory-bank design doc. |
| memory-bank/tool-execute-fix/context.md | Removes obsolete memory-bank context doc. |
| onOutput: ({ output, toolCallId, toolName, abortSignal }) => { | ||
| const resolved = resolveAbortSignal(abortSignal) | ||
| const aborted = resolved.aborted ?? false | ||
| log.info('Alpha Vantage crypto completed', { | ||
| toolCallId, | ||
| toolName, | ||
| symbol: output.metadata?.symbol ?? 'unknown', | ||
| abortSignal: resolveAbortSignal(abortSignal).aborted, | ||
| hook: 'onOutput', | ||
| }) |
There was a problem hiding this comment.
resolveAbortSignal(abortSignal) and aborted are computed in onOutput but never used. With typical TS/ESLint settings (noUnusedLocals / @typescript-eslint/no-unused-vars), this can fail CI. Either remove these locals or include the derived aborted value in the log payload.
| import { ModelRouterEmbeddingModel } from '@mastra/core/llm' | ||
| import { fastembed } from '@mastra/fastembed' |
There was a problem hiding this comment.
ModelRouterEmbeddingModel is imported but not used in this module. If the repo enforces unused-import checks, this will fail lint/TS builds. Remove the unused import (and any other unused imports) or reintroduce usage if it’s required.
| import { ModelRouterEmbeddingModel } from '@mastra/core/llm' | |
| import { fastembed } from '@mastra/fastembed' |
| @@ -1 +1 @@ | |||
| {"numTotalTestSuites":2,"numPassedTestSuites":2,"numFailedTestSuites":0,"numPendingTestSuites":0,"numTotalTests":1,"numPassedTests":1,"numFailedTests":0,"numPendingTests":0,"numTodoTests":0,"snapshot":{"added":0,"failure":false,"filesAdded":0,"filesRemoved":0,"filesRemovedList":[],"filesUnmatched":0,"filesUpdated":0,"matched":0,"total":0,"unchecked":0,"uncheckedKeysByFile":[],"unmatched":0,"updated":0,"didUpdate":false},"startTime":1776262021876,"success":true,"testResults":[{"assertionResults":[{"ancestorTitles":["ForecastView"],"fullName":"ForecastView renders forecast rows","status":"passed","title":"renders forecast rows","duration":77.82680000000028,"failureMessages":[],"location":{"line":9,"column":5},"meta":{},"tags":[]}],"startTime":1776262025182,"endTime":1776262025259.827,"status":"passed","message":"","name":"C:/Users/ssdsk/AgentStack/src/components/ai-elements/tools/__tests__/weather-tool.test.tsx"}]} No newline at end of file | |||
| {"numTotalTestSuites":2,"numPassedTestSuites":2,"numFailedTestSuites":0,"numPendingTestSuites":0,"numTotalTests":5,"numPassedTests":5,"numFailedTests":0,"numPendingTests":0,"numTodoTests":0,"snapshot":{"added":0,"failure":false,"filesAdded":0,"filesRemoved":0,"filesRemovedList":[],"filesUnmatched":0,"filesUpdated":0,"matched":0,"total":0,"unchecked":0,"uncheckedKeysByFile":[],"unmatched":0,"updated":0,"didUpdate":false},"startTime":1776701747029,"success":true,"testResults":[{"assertionResults":[{"ancestorTitles":["calendar-tool"],"fullName":"calendar-tool selects the correct default source for each platform","status":"passed","title":"selects the correct default source for each platform","duration":1.6313000000000102,"failureMessages":[],"location":{"line":21,"column":5},"meta":{},"tags":[]},{"ancestorTitles":["calendar-tool"],"fullName":"calendar-tool honors explicit source overrides","status":"passed","title":"honors explicit source overrides","duration":0.32979999999997744,"failureMessages":[],"location":{"line":27,"column":5},"meta":{},"tags":[]},{"ancestorTitles":["calendar-tool"],"fullName":"calendar-tool parses events from an ICS calendar export","status":"passed","title":"parses events from an ICS calendar export","duration":1.940900000000056,"failureMessages":[],"location":{"line":37,"column":5},"meta":{},"tags":[]},{"ancestorTitles":["calendar-tool"],"fullName":"calendar-tool loads events from an ICS file on Linux","status":"passed","title":"loads events from an ICS file on Linux","duration":7.559199999999919,"failureMessages":[],"location":{"line":58,"column":5},"meta":{},"tags":[]},{"ancestorTitles":["calendar-tool"],"fullName":"calendar-tool requires an ICS file when Linux falls back to the ICS source","status":"passed","title":"requires an ICS file when Linux falls back to the ICS source","duration":0.7972000000002026,"failureMessages":[],"location":{"line":86,"column":5},"meta":{},"tags":[]}],"startTime":1776701750467,"endTime":1776701750479.797,"status":"passed","message":"","name":"C:/Users/ssdsk/AgentStack/src/mastra/tools/tests/calendar-tool.test.ts"}]} No newline at end of file | |||
There was a problem hiding this comment.
This file appears to be an auto-generated Vitest JSON reporter output (see vitest.config.ts), and committing it will create frequent noisy diffs and merge conflicts. Consider adding it to .gitignore (or generating it only in CI artifacts) unless the repo intentionally versions test outputs.
| strict: true, | ||
| onInputStart: ({ toolCallId, messages }) => { | ||
| log.info('Google Images input streaming started', { | ||
| toolCallId, | ||
| messages: messages ?? [], | ||
| hook: 'onInputStart', | ||
| }) | ||
| }, | ||
| onInputDelta: ({ inputTextDelta, toolCallId, messages }) => { | ||
| log.info('Google Images received input chunk', { | ||
| toolCallId, | ||
| inputTextDelta, | ||
| messages: messages ?? [], | ||
| hook: 'onInputDelta', | ||
| }) | ||
| }, | ||
| onInputAvailable: ({ input, toolCallId, messages }) => { | ||
| log.info('Google Images received input', { |
There was a problem hiding this comment.
strict: true is followed by mis-indented hook properties (onInputStart, onInputDelta, onInputAvailable). While it likely still parses, it looks like formatting drift that will keep failing Prettier (and makes the object harder to scan). Run the formatter / fix indentation so tool hook keys align with the rest of the tool definition.
| @@ -337,7 +337,7 @@ export const agentBrowser = new AgentBrowser({ | |||
| }) | |||
|
|
|||
| export const stagehandBrowser = new StagehandBrowser({ | |||
| headless: true, | |||
| headless: false, | |||
| model: | |||
There was a problem hiding this comment.
headless is hard-coded to false for both agentBrowser and stagehandBrowser, which ignores the earlier env-driven agentBrowserHeadless / stagehandHeadless settings. This will break CI/server deployments that require headless Chrome and makes BROWSER_HEADLESS/STAGEHAND_HEADLESS ineffective. Prefer wiring headless to the computed config values (and/or keep the default headless behavior) rather than forcing non-headless.
| onInputStart: ({ toolCallId, messages, abortSignal }) => { | ||
| log.info('Yahoo Finance stock quotes input streaming started', { | ||
| toolCallId, | ||
| messageCount: messages?.length ?? 0, | ||
| abortSignal: abortSignal?.aborted, | ||
| messages, | ||
| abortSignal, |
There was a problem hiding this comment.
The updated hooks log the full messages array and abortSignal object. This can significantly increase log volume and can leak user content/PII into logs. Consider logging only safe metadata (e.g., messages?.length, a small redacted preview, and abortSignal?.aborted) and avoid serializing the full AbortSignal object.
| "prettier:write": "dotenvx run -- prettier --write .", | ||
| "format": "npm run prettier:write", | ||
| "convex": "npx convex dev --env-file .env.local", | ||
| "convex": "dotenvx run npx convex dev --env-file .env.local", |
There was a problem hiding this comment.
The convex npm script uses dotenvx run npx ... without the -- separator used elsewhere in this repo (e.g., dotenvx run -- eslint ...). If dotenvx expects -- before the command, this script will fail to start Convex in development. Align it with the other scripts (use the same dotenvx run -- <command> pattern).
| "convex": "dotenvx run npx convex dev --env-file .env.local", | |
| "convex": "dotenvx run -- npx convex dev --env-file .env.local", |
No description provided.