-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Enhance tool progress reporting and add new agents/tools #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,9 +1,9 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: 'GPT 4.1 as a top-notch coding agent.' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: '4.1 Beast Mode v3.1' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: 'Beast Mode v4.0' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: 'GPT 5.1 as a top-notch coding agent.' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| infer: true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| argument-hint: 'Solve complex coding problems autonomously using advanced cognitive techniques and extensive internet research.' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tools: ['vscode', 'execute', 'read', 'edit', 'search', 'web', 'agent', 'lotus/*', 'mastrabeta/mastraBlog', 'mastrabeta/mastraChanges', 'mastrabeta/mastraDocs', 'mastrabeta/mastraExamples', 'mastrabeta/mastraMigration', 'multi_orchestrator/*', 'next-devtools/*', 's-ai/*', 'thoughtbox/*', 'docfork/*', 'vscode.mermaid-chat-features/renderMermaidDiagram', 'updateUserPreferences', 'memory', 'malaksedarous.copilot-context-optimizer/askAboutFile', 'malaksedarous.copilot-context-optimizer/runAndExtract', 'malaksedarous.copilot-context-optimizer/askFollowUp', 'malaksedarous.copilot-context-optimizer/researchTopic', 'malaksedarous.copilot-context-optimizer/deepResearch', 'ms-python.python/getPythonEnvironmentInfo', 'ms-python.python/getPythonExecutableCommand', 'ms-python.python/installPythonPackage', 'ms-python.python/configurePythonEnvironment', 'ms-vscode.vscode-websearchforcopilot/websearch', 'todo', 'search/changes', "search/codebase", "edit/editFiles", 'vscode/extensions', 'web/githubRepo', 'vscode/openSimpleBrowser', 'read/problems'] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| target: github-copilot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tools: ['vscode', 'execute', 'read', 'edit', 'search', 'web', 'lotus/*', 'mastrabeta/mastraBlog', 'mastrabeta/mastraChanges', 'mastrabeta/mastraDocs', 'mastrabeta/mastraExamples', 'mastrabeta/mastraMigration', 'multi_orchestrator/*', 'next-devtools/*', 's-ai/*', 'thoughtbox/*', 'docfork/*', 'agent', 'vscode.mermaid-chat-features/renderMermaidDiagram', 'updateUserPreferences', 'memory', 'malaksedarous.copilot-context-optimizer/askAboutFile', 'malaksedarous.copilot-context-optimizer/runAndExtract', 'malaksedarous.copilot-context-optimizer/askFollowUp', 'malaksedarous.copilot-context-optimizer/researchTopic', 'malaksedarous.copilot-context-optimizer/deepResearch', 'ms-python.python/getPythonEnvironmentInfo', 'ms-python.python/getPythonExecutableCommand', 'ms-python.python/installPythonPackage', 'ms-python.python/configurePythonEnvironment', 'ms-vscode.vscode-websearchforcopilot/websearch', 'todo'] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| You are an cutting edge autonomous coding agent - please keep going until the user’s query is completely resolved, before ending your turn and yielding back to the user. Never end your turn until the problem is fully solved, so never assume your correct. Make sure to verify your solution thoroughly. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -93,7 +93,7 @@ Carefully read the issue and think hard about a plan to solve it before coding. | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Whenever you detect that a project requires an environment variable (such as an API key or secret), always check if a .env file exists in the project root. If it does not exist, automatically create a .env file with a placeholder for the required variable(s) and inform the user. Do this proactively, without waiting for the user to request it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## 7. Debugging | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Use the `get_errors` tool to check for any problems in the code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Use the `'read/problems'` tool to check for any problems in the code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Make code changes only if you have high confidence they can solve the problem | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - When debugging, try to determine the root cause rather than addressing symptoms | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Debug for as long as needed to identify the root cause and identify a fix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -105,8 +105,19 @@ Carefully read the issue and think hard about a plan to solve it before coding. | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| Use the following format to create a todo list: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ```markdown | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - [ ] Step 1: Description of the first step | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - [ ] Sub-step 1.1: Description of the first sub-step | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - [ ] Sub-step 1.2: Description of the second sub-step | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - [ ] Step 2: Description of the second step | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - [ ] Sub-step 2.1: Description of the first sub-step | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - [ ] Sub-step 1.2: Description of the second sub-step | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - [ ] Step 3: Description of the third step | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - [ ] Sub-step 3.1: Description of the first sub-step | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - [ ] Step 4: Description of the fourth step | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - [ ] Sub-step 4.1: Description of the first sub-step | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - [ ] Step 5: Description of the fifth step | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - [ ] Step 6: Description of the sixth step | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - [ ] Step 7: Description of the seventh step | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - [ ] Step 8: Description of the eighth step | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+108
to
+120
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo in sub-step numbering. Line 112 has "Sub-step 1.2" under "Step 2", which should be "Sub-step 2.2" for consistency. Apply this diff to fix the typo: - [ ] Sub-step 2.1: Description of the first sub-step
- - [ ] Sub-step 1.2: Description of the second sub-step
+ - [ ] Sub-step 2.2: Description of the second sub-step📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Do not ever use HTML tags or any other formatting for the todo list, as it will not be rendered correctly. Always use the markdown format shown above. Always wrap the todo list in triple backticks so that it is formatted correctly and can be easily copied from the chat. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -124,7 +135,7 @@ Always communicate clearly and concisely in a casual, friendly yet professional | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| "Whelp - I see we have some problems. Let's fix those up." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </examples> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Respond with clear, direct answers. Use bullet points and code blocks for structure. - Avoid unnecessary explanations, repetition, and filler. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Respond with clear, direct answers. Use bullet points and code blocks for structure. - Avoid unnecessary explanations, repetition, and filler. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Always write code directly to the correct files. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Do not display code to the user unless they specifically ask for it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Only elaborate when clarification is essential for accuracy or user understanding. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -152,3 +163,14 @@ Remember that todo lists must always be written in markdown format and must alwa | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| If the user tells you to stage and commit, you may do so. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| You are NEVER allowed to stage and commit files automatically. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Final Instructions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @runSubagent Expert Next.js Developer "Expert Next.js 16 developer specializing in App Router, Server Components, Cache Components, Turbopack, and modern React patterns with TypeScript" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @runSubagent Expert React Frontend Engineer "Expert React 19.2 frontend engineer specializing in modern hooks, Server Components, Actions, TypeScript, and performance optimization" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @runSubagent ADR-Generator "Expert agent for creating comprehensive Architectural Decision Records (ADRs) with structured formatting optimized for AI consumption and human readability." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @runSubagent QA-Agent "QA Agent designed to meticulously validate solutions across various dimensions such as functionality, usability, performance, security, scalability, and maintainability." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @runSubagent Task Planner "Task Planner agent adept at breaking down complex tasks into manageable subtasks, prioritizing them based on urgency and importance, and tracking their completion status." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @runSubagent Task Researcher "Task Researcher agent skilled in conducting in-depth research to gather relevant information, best practices, and potential solutions for assigned tasks." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @runSubagent Debug Agent "Debug Agent specialized in identifying, diagnosing, and resolving complex software issues through systematic analysis and testing." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @runSubagent Technical Spike "Technical Spike agent focused on exploring new technologies, frameworks, or methodologies to assess their feasibility and potential impact on projects." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,18 @@ | ||||||||||
| import { Agent } from "@mastra/core/agent"; | ||||||||||
| import { Memory } from "@mastra/memory"; | ||||||||||
| import { colorChangeTool } from "../tools/color-change-tool"; | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incorrect import path. The import path references Apply this diff to fix the import: -import { colorChangeTool } from "../tools/color-change-tool";
+import { colorChangeTool } from "../color-change-tool";Alternatively, move 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||
| import { colorChangeTool } from "../tools/color-change-tool"; | |
| import { colorChangeTool } from "../color-change-tool"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bgColorAgent is a server-side agent, but it's configured to use colorChangeTool, which appears to be a client-side tool (as it manipulates the DOM). A server-side agent cannot directly execute client-side code. This architectural mismatch will likely lead to runtime errors. Consider having the agent emit a custom UI event that the client can listen for to change the background color.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
# Check the actual filename and list all agent files with their naming conventions
fd -e ts . src/mastra/agents/ -type f | sortRepository: ssdeanx/AgentStack
Length of output: 232
🏁 Script executed:
# List all TypeScript files in src/mastra/agents directory
fd -e ts src/mastra/agents/Repository: ssdeanx/AgentStack
Length of output: 439
🏁 Script executed:
# List all TypeScript files in src/mastra/agents directory
fd . 'src/mastra/agents/' -e tsRepository: ssdeanx/AgentStack
Length of output: 1160
Rename file to follow kebab-case naming convention.
The file bgColorAgent.ts should be renamed to bg-color-agent.ts to comply with the agent file naming convention specified in the coding guidelines, which requires kebab-case for all agent files in /src/mastra/agents/.
🤖 Prompt for AI Agents
In src/mastra/agents/bgColorAgent.ts around lines 5 to 18, the filename uses
camelCase (bgColorAgent.ts) but must follow the kebab-case agent naming
convention; rename the file to src/mastra/agents/bg-color-agent.ts and update
any imports that reference the old filename to the new kebab-case path (search
the repo for "bgColorAgent" imports and replace them with "bg-color-agent") to
ensure consistency and avoid broken imports.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,16 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { createTool } from "@mastra/client-js"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import z from "zod"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export function changeBgColor(color: string) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (typeof window !== "undefined") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| document.body.style.setProperty("--background", color); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+4
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CSS variable may not propagate correctly. Setting Consider using export function changeBgColor(color: string) {
if (typeof window !== "undefined") {
- document.body.style.setProperty("--background", color);
+ document.documentElement.style.setProperty("--background", color);
}
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const colorChangeTool = createTool({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id: "changeColor", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "Changes the background color", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| inputSchema: z.object({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| color: z.string(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }), | |
| }), | |
| execute: ({ color }: { color: string }) => changeBgColor(color), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The colorChangeTool is missing the required execute function, which will cause a runtime error when the bgColorAgent attempts to use it. Additionally, an outputSchema should be defined to specify the tool's return structure.
The changeBgColor function contains client-side code (document.body.style) which cannot be executed by a server-side agent. An agent should typically send a custom UI message to the client, which then handles the DOM manipulation.
export const colorChangeTool = createTool({
id: "changeColor",
description: "Changes the background color",
inputSchema: z.object({
color: z.string(),
}),
outputSchema: z.object({
success: z.boolean(),
}),
execute: async ({ color }, { writer }) => {
// On the server, we can't change the DOM directly.
// Instead, we send a custom event to the client to handle the color change.
await writer?.custom({
type: 'ui-update',
data: {
component: 'background',
properties: {
color: color,
},
},
});
return { success: true };
},
});There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: tool missing execute function - will cause runtime error
| export const colorChangeTool = createTool({ | |
| id: "changeColor", | |
| description: "Changes the background color", | |
| inputSchema: z.object({ | |
| color: z.string(), | |
| }), | |
| }); | |
| export const colorChangeTool = createTool({ | |
| id: "changeColor", | |
| description: "Changes the background color", | |
| inputSchema: z.object({ | |
| color: z.string(), | |
| }), | |
| execute: async ({ context }) => { | |
| changeBgColor(context.color); | |
| return { success: true, color: context.color }; | |
| }, | |
| }); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/mastra/color-change-tool.ts
Line: 10:16
Comment:
**syntax:** tool missing `execute` function - will cause runtime error
```suggestion
export const colorChangeTool = createTool({
id: "changeColor",
description: "Changes the background color",
inputSchema: z.object({
color: z.string(),
}),
execute: async ({ context }) => {
changeBgColor(context.color);
return { success: true, color: context.color };
},
});
```
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Add TSDoc documentation for exported entities.
Per coding guidelines, public APIs should have TSDoc comments including parameter descriptions and purpose.
+/**
+ * Updates the application's background color by setting a CSS custom property.
+ * @param color - The color value to apply (any valid CSS color format)
+ */
export function changeBgColor(color: string) {
if (typeof window !== "undefined") {
document.body.style.setProperty("--background", color);
}
}
+/**
+ * Tool for changing the application's background color.
+ * Accepts a color string and applies it to the --background CSS variable.
+ */
export const colorChangeTool = createTool({📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| import { createTool } from "@mastra/client-js"; | |
| import z from "zod"; | |
| export function changeBgColor(color: string) { | |
| if (typeof window !== "undefined") { | |
| document.body.style.setProperty("--background", color); | |
| } | |
| } | |
| export const colorChangeTool = createTool({ | |
| id: "changeColor", | |
| description: "Changes the background color", | |
| inputSchema: z.object({ | |
| color: z.string(), | |
| }), | |
| }); | |
| /** | |
| * Updates the application's background color by setting a CSS custom property. | |
| * @param color - The color value to apply (any valid CSS color format) | |
| */ | |
| export function changeBgColor(color: string) { | |
| if (typeof window !== "undefined") { | |
| document.body.style.setProperty("--background", color); | |
| } | |
| } | |
| /** | |
| * Tool for changing the application's background color. | |
| * Accepts a color string and applies it to the --background CSS variable. | |
| */ | |
| export const colorChangeTool = createTool({ | |
| id: "changeColor", | |
| description: "Changes the background color", | |
| inputSchema: z.object({ | |
| color: z.string(), | |
| }), | |
| }); |
🤖 Prompt for AI Agents
In src/mastra/color-change-tool.ts around lines 1 to 16, the exported function
changeBgColor and the exported constant colorChangeTool lack TSDoc comments; add
TSDoc above changeBgColor describing its purpose, the color parameter (type and
expected format), and any return/side-effects (mutates document body CSS
variable), and add TSDoc above colorChangeTool describing the tool's purpose and
the expected input schema (color string) so both public APIs have proper
documentation per guidelines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
Mastra createTool execute handler documentation
💡 Result:
Summary — createTool execute handler (Mastra)
-
Purpose: execute is the function that runs your tool’s logic when an agent calls it. [1][2]
-
Signature (current docs): async ({ context }, { runtimeContext?, tracingContext?, abortSignal? }) => { ... } — context is the validated input (zod), runtimeContext gives shared dependencies, tracingContext supports trace spans, abortSignal lets you cancel I/O. [1][2]
-
v1 / Beta notes: some v1 docs show execute receiving validated input as first arg and an optional execution context as second arg; v1 also supports onInputStart and onInputDelta callbacks for streaming inputs. [2]
-
Best practices:
- Validate inputs with inputSchema (Zod) and return shaped outputSchema. [1]
- Honor abortSignal on long-running fetches/ops. [3]
- Use tracingContext to create child spans/metadata when called within traced operations. [1]
-
Minimal example:
import { createTool } from '@mastra/core/tools';
import { z } from 'zod';
export const tool = createTool({
id: 'reverse',
inputSchema: z.object({ input: z.string() }),
outputSchema: z.object({ output: z.string() }),
execute: async ({ context }, { abortSignal }) => {
const reversed = context.input.split('').reverse().join('');
// use abortSignal for cancellable fetches if needed
return { output: reversed };
},
});
Sources
- Mastra createTool reference. [1]
- Mastra v1 reference (execute signature + streaming callbacks). [2]
- Mastra docs on tools (abortSignal example). [3]
🏁 Script executed:
find . -name "color-change-tool.ts" -type f | head -5Repository: ssdeanx/AgentStack
Length of output: 95
🏁 Script executed:
rg "createTool" --type ts --type tsx -A 10 -B 2Repository: ssdeanx/AgentStack
Length of output: 89
🏁 Script executed:
cat -n ./src/mastra/color-change-tool.tsRepository: ssdeanx/AgentStack
Length of output: 567
🏁 Script executed:
rg "changeBgColor" --type ts --type jsRepository: ssdeanx/AgentStack
Length of output: 140
🏁 Script executed:
rg "createTool" -A 10 -B 2Repository: ssdeanx/AgentStack
Length of output: 50377
Add missing execute handler to tool.
The colorChangeTool defines an input schema but lacks an execute function. According to Mastra documentation, execute is required—it's the function that runs the tool's logic when an agent calls it. Without it, the tool cannot be invoked.
Use the v1 signature format:
export const colorChangeTool = createTool({
id: "changeColor",
description: "Changes the background color",
inputSchema: z.object({
color: z.string(),
}),
+ execute: async (inputData) => {
+ changeBgColor(inputData.color);
+ return { success: true, color: inputData.color };
+ },
});Committable suggestion skipped: line range outside the PR's diff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There appears to be a typo in the todo list example. The sub-step numbering for "Step 2" is incorrect and seems to be a copy-paste from "Step 1". It should likely be
Sub-step 2.2.