Skip to content

feat: Enhance weather tool and introduce agent builder#139

Merged
ssdeanx merged 2 commits intomainfrom
develop
Apr 16, 2026
Merged

feat: Enhance weather tool and introduce agent builder#139
ssdeanx merged 2 commits intomainfrom
develop

Conversation

@ssdeanx
Copy link
Copy Markdown
Owner

@ssdeanx ssdeanx commented Apr 16, 2026

  • Refactored weather tool to utilize linked abort controllers for improved signal handling during execution.
  • Added utility functions for creating and resolving abort signals to streamline abort handling in the weather tool.
  • Introduced a new Agent Builder page for creating stored agents with live provider, model, and tool metadata.
  • Implemented form state management for agent creation, including validation for required fields.
  • Added runtime chat catalog to manage agent configurations and features dynamically based on live metadata.
  • Created a tool status component to display the state of various tool parts with appropriate icons and labels.
  • Added market update and global conflicts markdown files to provide real-time data and insights.

- Refactored weather tool to utilize linked abort controllers for improved signal handling during execution.
- Added utility functions for creating and resolving abort signals to streamline abort handling in the weather tool.
- Introduced a new Agent Builder page for creating stored agents with live provider, model, and tool metadata.
- Implemented form state management for agent creation, including validation for required fields.
- Added runtime chat catalog to manage agent configurations and features dynamically based on live metadata.
- Created a tool status component to display the state of various tool parts with appropriate icons and labels.
- Added market update and global conflicts markdown files to provide real-time data and insights.
Copilot AI review requested due to automatic review settings April 16, 2026 07:33
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agent-stack Error Error Apr 16, 2026 7:45am

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.

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.

Sorry @ssdeanx, your pull request is larger than the review limit of 150000 diff characters

@github-actions
Copy link
Copy Markdown

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

@github-actions
Copy link
Copy Markdown

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

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 16, 2026

Warning

Rate limit exceeded

@ssdeanx has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 56 minutes and 11 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 56 minutes and 11 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: e9e9c4f7-ad47-4bfa-a30f-ad6a6932091b

📥 Commits

Reviewing files that changed from the base of the PR and between 6836d28 and 9cfd6ed.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (58)
  • .gitignore
  • app/chat/AGENTS.md
  • app/chat/builder/page.tsx
  • app/chat/components/agent-artifact.tsx
  • app/chat/components/agent-chain-of-thought.tsx
  • app/chat/components/agent-checkpoint.tsx
  • app/chat/components/agent-confirmation.tsx
  • app/chat/components/agent-launchpad.tsx
  • app/chat/components/agent-plan.tsx
  • app/chat/components/agent-queue.tsx
  • app/chat/components/agent-sources.tsx
  • app/chat/components/agent-tools.tsx
  • app/chat/components/agent-workflow.tsx
  • app/chat/components/chat-header.tsx
  • app/chat/components/chat-input.tsx
  • app/chat/components/chat-layout.tsx
  • app/chat/components/chat-messages.tsx
  • app/chat/components/chat-page-shell.tsx
  • app/chat/components/chat-settings-shell.tsx
  • app/chat/components/chat-sidebar.tsx
  • app/chat/components/code-layout.tsx
  • app/chat/components/main-sidebar.tsx
  • app/chat/lib/runtime-chat-catalog.ts
  • app/chat/providers/chat-context-types.ts
  • app/chat/providers/chat-context.tsx
  • app/chat/workflows/_components/workflow-canvas.tsx
  • app/chat/workflows/_components/workflow-header.tsx
  • app/chat/workflows/page.tsx
  • app/globals.css
  • app/layout.tsx
  • lib/hooks/use-mastra-query.ts
  • lib/mastra-client.ts
  • memory-bank/activeContext.md
  • memory-bank/progress.md
  • package.json
  • src/components/ai-elements/plan.tsx
  • src/components/ai-elements/reasoning.tsx
  • src/components/ai-elements/sandbox.tsx
  • src/components/ai-elements/sources.tsx
  • src/components/ai-elements/task.tsx
  • src/components/ai-elements/tool-status.tsx
  • src/components/ai-elements/tool.tsx
  • src/mastra/agents/researchAgent.ts
  • src/mastra/config/AGENTS.md
  • src/mastra/config/lance.ts
  • src/mastra/config/libsql.ts
  • src/mastra/config/mongodb.ts
  • src/mastra/index.ts
  • src/mastra/public/workspace/investing.md
  • src/mastra/public/workspace/war.md
  • src/mastra/tools/abort-signal.utils.ts
  • src/mastra/tools/alpha-vantage.tool.ts
  • src/mastra/tools/binance-crypto-market.tool.ts
  • src/mastra/tools/document-chunking.tool.ts
  • src/mastra/tools/fetch.tool.ts
  • src/mastra/tools/serpapi-news-trends.tool.ts
  • src/mastra/tools/url-tool.ts
  • src/mastra/tools/weather-tool.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • 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.

Comment thread app/chat/builder/page.tsx Outdated
@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented Apr 16, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 0
Other Observations (not in diff)

Issues found in unchanged code that cannot receive inline comments:

File Line Issue
app/chat/providers/chat-context.tsx 327 Runtime default agent could be empty string if Mastra backend is down
app/chat/builder/page.tsx 119 Potential infinite re-render in model selection useEffect
Files Reviewed (2 files)
  • app/chat/builder/page.tsx - 0 issues (previously flagged issue resolved)
  • app/chat/providers/chat-context.tsx - 0 issues

Fix these issues in Kilo Cloud


Reviewed by grok-code-fast-1:optimized:free · 213,821 tokens

Co-authored-by: kilo-code-bot[bot] <240665456+kilo-code-bot[bot]@users.noreply.github.com>
@ssdeanx ssdeanx merged commit b29edbb into main Apr 16, 2026
6 of 9 checks passed
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 implements a significant refactor of the chat system to use live runtime metadata for agents and models instead of static configurations, alongside a major visual overhaul of the chat UI components and theme. Key changes include the introduction of a runtime chat catalog, hardening of Mastra query hooks to align with the client SDK, and the addition of an agent builder page. Feedback includes improving validation logic in the agent builder to ensure a user ID is present before saving, fixing a syntax error in a Handlebars template within the LibSQL configuration, and correcting a logging statement in the document chunking tool to record the boolean state of the abort signal rather than the object itself.

Comment thread app/chat/builder/page.tsx
Comment on lines +87 to +92
const canSave =
name.trim().length > 0 &&
instructions.trim().length > 0 &&
selectedProviderId.length > 0 &&
selectedModelId.length > 0 &&
(selectedProvider?.connected ?? false)
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 canSave validation logic should include a check for userId to ensure that the agent creation request has a valid authorId before attempting to save. If userId is undefined (e.g., user not logged in), the mutation might fail or create an agent without an owner.

Suggested change
const canSave =
name.trim().length > 0 &&
instructions.trim().length > 0 &&
selectedProviderId.length > 0 &&
selectedModelId.length > 0 &&
(selectedProvider?.connected ?? false)
const canSave =
name.trim().length > 0 &&
instructions.trim().length > 0 &&
selectedProviderId.length > 0 &&
selectedModelId.length > 0 &&
(selectedProvider?.connected ?? false) &&
!!userId

# Additional Context
{{#each additionalContext}}
- {{this}}
- {{/each}}
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

There is a typo in the Handlebars template. The dash - before {{/each}} will result in an extra dash being rendered for every iteration of the additionalContext loop, which breaks the intended markdown list formatting.

{{/each}}

toolCallId,
messageCount: messages.length,
aborted: abortSignal?.aborted ?? false,
aborted: resolveAbortSignal(abortSignal),
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 aborted property is logging the AbortSignal object itself instead of its boolean state. It should use .aborted to be consistent with other logging statements in this file and to ensure the log output is serializable and useful.

Suggested change
aborted: resolveAbortSignal(abortSignal),
aborted: resolveAbortSignal(abortSignal).aborted,

@@ -0,0 +1,48 @@
# Market Update - 2026-05-15
@@ -0,0 +1,100 @@
# Global Wars and Conflicts Update - 2026-05-15
Copy link
Copy Markdown
Contributor

@github-advanced-security github-advanced-security AI left a comment

Choose a reason for hiding this comment

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

Csslint (reported by Codacy) found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

Copy link
Copy Markdown
Contributor

@github-advanced-security github-advanced-security AI left a comment

Choose a reason for hiding this comment

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

Stylelint (reported by Codacy) found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

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 improves cancellation handling across multiple Mastra tools, migrates the chat UI toward runtime-derived agent/model metadata (including a new agent builder page), and updates shared chat/workflow UI styling and memory/vector configuration.

Changes:

  • Standardize tool abort-signal handling via shared helpers and propagate abort state into tool execution/logging.
  • Add runtime chat catalog + /chat/builder for creating stored agents using live provider/model/tool metadata.
  • Update chat/workflow UI shells and global styling tokens; adjust LibSQL memory to use FastEmbed + warmup.

Reviewed changes

Copilot reviewed 57 out of 59 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
src/mastra/tools/weather-tool.ts Uses linked abort controller + normalized abort logging.
src/mastra/tools/url-tool.ts Uses linked abort controller + normalized abort logging; adds parent abort support in helpers.
src/mastra/tools/serpapi-news-trends.tool.ts Normalizes abort logging; adds extra hooks/logs for lite/news/trends tools.
src/mastra/tools/fetch.tool.ts Threads abort signal into downstream search/fetch helpers; adds abort helper.
src/mastra/tools/document-chunking.tool.ts Normalizes abort logging for chunking/reranking tools.
src/mastra/tools/binance-crypto-market.tool.ts Normalizes abort logging in Binance spot market tool.
src/mastra/tools/alpha-vantage.tool.ts Uses linked abort controller; forwards abort signal into httpFetch calls.
src/mastra/tools/abort-signal.utils.ts Adds shared helpers for linked AbortController + resolving signals for logging.
src/mastra/public/workspace/war.md Adds workspace markdown content for global conflicts update.
src/mastra/public/workspace/investing.md Adds workspace markdown content for market update.
src/mastra/index.ts Reorders/updates Mastra editor configuration and related comments.
src/mastra/config/mongodb.ts Expands observationalMemory configuration shape.
src/mastra/config/libsql.ts Switches LibSQL embedding to FastEmbed base + warmup; aligns index dimension/name; updates working-memory template.
src/mastra/config/lance.ts Expands observationalMemory configuration shape for Lance memory.
src/mastra/config/AGENTS.md Documents the LibSQL FastEmbed warmup + index dimension alignment change.
src/mastra/agents/researchAgent.ts Enables TokenLimiter with a larger limit in processors.
src/components/ai-elements/tool.tsx Refactors status badge logic into a shared component; updates tool UI styling.
src/components/ai-elements/tool-status.tsx New shared tool status badge component.
src/components/ai-elements/task.tsx Updates task UI styling for the chat surface.
src/components/ai-elements/sources.tsx Updates sources UI styling and link card treatment.
src/components/ai-elements/sandbox.tsx Switches status badge import to the new shared component.
src/components/ai-elements/reasoning.tsx Updates reasoning UI styling; internalizes the hook.
src/components/ai-elements/plan.tsx Updates plan UI styling (header/content/footer/trigger).
package.json Bumps/introduces dependencies (Next, AI SDK, FastEmbed, adapters, etc.).
memory-bank/progress.md Adds progress notes for FastEmbed bootstrap + chat shell redesign.
memory-bank/activeContext.md Adds active context notes for FastEmbed warmup + shell redesign.
lib/mastra-client.ts Introduces MASTRA_API_BASE_URL constant and uses it in client creation.
app/layout.tsx Removes global mesh-gradient class from <body>.
app/globals.css Updates theme tokens and adds chat-specific surface utilities/styles.
app/chat/workflows/page.tsx Wraps workflows page in shared chat shell + provider composition.
app/chat/workflows/_components/workflow-header.tsx Updates workflow header styling and navigation copy.
app/chat/workflows/_components/workflow-canvas.tsx Updates workflow canvas surface styling and panel treatments.
app/chat/providers/chat-context.tsx Moves to runtime agent ids + runtime-derived agent config; adds provider readiness metadata.
app/chat/providers/chat-context-types.ts Aligns types with runtime chat catalog model/agent config.
app/chat/lib/runtime-chat-catalog.ts New runtime-first catalog to infer agent categories/features + model display metadata.
app/chat/components/main-sidebar.tsx Updates sidebar UI and adds builder navigation entry.
app/chat/components/code-layout.tsx Adopts shared chat shell styling and SidebarProvider usage.
app/chat/components/chat-sidebar.tsx Uses runtime category labels and displays runtime capability counts.
app/chat/components/chat-settings-shell.tsx Updates settings shell styling and active-state treatments.
app/chat/components/chat-page-shell.tsx Adds fullBleed support and refines shell layout/styling.
app/chat/components/chat-messages.tsx Updates message styling; surfaces provider readiness + capability badges and warning state.
app/chat/components/chat-layout.tsx Applies chat shell background utilities and refined panel styling.
app/chat/components/chat-input.tsx Adds provider readiness UI, status badge, and refined composer styling.
app/chat/components/chat-header.tsx Switches agent/model selection to runtime-derived data and updates header styling.
app/chat/components/agent-workflow.tsx Refines workflow preview panel styling.
app/chat/components/agent-tools.tsx Refines tool panel spacing and progress message styling.
app/chat/components/agent-sources.tsx Switches favicon rendering to next/image and updates layout imports.
app/chat/components/agent-queue.tsx Refines queue header styling and badges.
app/chat/components/agent-plan.tsx Adds progress badge and refines plan styling.
app/chat/components/agent-launchpad.tsx Refines launchpad cards styling and layout spacing.
app/chat/components/agent-confirmation.tsx Refines confirmation UI styling for request/accepted/rejected states.
app/chat/components/agent-checkpoint.tsx Refines checkpoint container/button styling.
app/chat/components/agent-chain-of-thought.tsx Refines chain-of-thought header styling and badge shape.
app/chat/components/agent-artifact.tsx Refines artifact compact card and editor FAB styling.
app/chat/builder/page.tsx New agent builder page wired to live providers/tools + stored-agent creation mutation.
app/chat/AGENTS.md Updates internal docs for runtime catalog cutover and UI shell consolidation.
.gitignore Adds ignores for workspace artifacts and Playwright MCP outputs.

Comment thread app/chat/builder/page.tsx
Comment on lines +87 to +91
const canSave =
name.trim().length > 0 &&
instructions.trim().length > 0 &&
selectedProviderId.length > 0 &&
selectedModelId.length > 0 &&
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

canSave does not include authentication state, so the form can enable saving even when userId is undefined. Consider requiring a logged-in user (or otherwise handling unauthenticated creation) before allowing the save action.

Copilot uses AI. Check for mistakes.
Comment thread app/chat/builder/page.tsx
Comment on lines +159 to +163
authorId: userId,
metadata: {
createdFrom: 'chat-builder',
},
}
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

authorId is set from userId, but userId can be undefined. This can send an invalid payload to the stored-agent API. Gate saving on auth, or only include authorId when defined (depending on the backend contract).

Copilot uses AI. Check for mistakes.
Comment on lines 765 to 768
onInputStart: ({ toolCallId, messages, abortSignal }) => {


log.info('Fetch tool input streaming started', {
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

There are stray blank lines at the start of onInputStart which will typically fail lint/format rules and adds noise to diffs. Remove the empty lines so the handler starts directly with the log statement.

Copilot uses AI. Check for mistakes.
Comment on lines 123 to 127
# Additional Context
{{#each additionalContext}}
- {{this}}
- {{/each}}
`,
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

The working-memory template has an invalid Handlebars closing tag (- {{/each}}). This will either render incorrectly or fail template parsing at runtime. Replace it with a proper {{/each}} line (and keep the bullet list only for the {{this}} rows).

Copilot uses AI. Check for mistakes.
Comment thread src/mastra/index.ts
Comment on lines +338 to +340
arcade: new ArcadeToolProvider({
apiKey: process.env.ARCADE_API_KEY!,
}),
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

ArcadeToolProvider is created with process.env.ARCADE_API_KEY!, which will throw on startup when the env var is not set. Prefer gating provider creation on env var presence (or omitting the provider) so local/dev boots don't fail when unconfigured.

Copilot uses AI. Check for mistakes.
Comment on lines 706 to +710
async function checkUrlReachability(
url: string,
timeout = 5000,
userAgent?: string
userAgent?: string,
parentAbortSignal?: AbortSignal
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

checkUrlReachability / getUrlMetadata accept a parentAbortSignal, but the call sites in this file do not pass a signal, so cancellations won't propagate to these requests. Either thread the tool-level abort signal through the callers or remove the unused parameter to avoid misleading cancellation support.

Copilot uses AI. Check for mistakes.
Comment on lines 508 to 512
log.info('MDocument chunker tool input streaming started', {
toolCallId,
messageCount: messages.length,
aborted: abortSignal?.aborted ?? false,
aborted: resolveAbortSignal(abortSignal),
hook: 'onInputStart',
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

aborted: resolveAbortSignal(abortSignal) logs an AbortSignal object instead of a boolean. This will serialize inconsistently and break log queries expecting a boolean. Use resolveAbortSignal(abortSignal).aborted here.

Copilot uses AI. Check for mistakes.
Comment on lines 529 to 533
chunkingStrategy: input.chunkingStrategy,
generateEmbeddings: input.generateEmbeddings,
messageCount: messages.length,
aborted: abortSignal?.aborted ?? false,
abort: resolveAbortSignal(abortSignal).aborted,
hook: 'onInputAvailable',
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

The log field name flips from aborted to abort in onInputAvailable, which makes log queries/dashboards inconsistent. Keep the same key name (e.g., aborted) across hooks.

Copilot uses AI. Check for mistakes.
Comment on lines 496 to +500
log.info('Binance spot market-data completed', {
toolCallId,
toolName,
count,
abortSignal: abortSignal?.aborted,
aborted: resolveAbortSignal(abortSignal).aborted,
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

onInput* logs use the abortSignal key, but onOutput uses aborted. If observability tooling relies on stable attribute names, this becomes a breaking change. Keep the same key name across the tool's log payloads.

Copilot uses AI. Check for mistakes.
Comment thread src/mastra/index.ts
Comment on lines +333 to +336
toolProviders: {
composio: new ComposioToolProvider({
apiKey: process.env.COMPOSIO_API_KEY!,
}),
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

ComposioToolProvider is created with process.env.COMPOSIO_API_KEY!, which will throw on startup when the env var is not set. Prefer gating provider creation on env var presence (or omitting the provider) so local/dev boots don't fail when unconfigured.

Copilot uses AI. Check for mistakes.
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.

3 participants