Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Sep 3, 2025

Add Mastra Dynamic Agents Example

Summary

Converts the Mastra Dynamic Agents example into an Agentuity agent following the established patterns in the frameworks directory. This example demonstrates how to create agents that adapt their behavior at runtime based on contextual input (user tier and language preferences).

Key changes:

  • Created new example directory frameworks/mastra/dynamic-agents/
  • Implemented agent that detects context from user input and modifies behavior accordingly
  • Added proper Agentuity wrapper with error handling and logging
  • Follows established patterns from other Mastra examples in the repo
  • Includes comprehensive README with setup and usage instructions

Review & Testing Checklist for Human

  • End-to-end functionality: Test the agent locally with agentuity dev and verify it actually responds with different behavior for different user tiers (free/pro/enterprise) and language preferences
  • Framework preservation: Verify this implementation actually preserves the original Mastra framework functionality - the original example uses RuntimeContext API which this implementation simplifies to prompt modification
  • Dynamic behavior verification: Test with the provided example prompts to ensure the agent adapts responses based on detected context (user tier and language)

Notes

  • The implementation uses contextual prompt modification rather than Mastra's RuntimeContext API from the original example
  • Dependencies may need version updates to access latest Mastra features
  • Local testing was attempted but server startup failed - manual verification needed

Link to Devin run: https://app.devin.ai/sessions/4c57aab5afae4650ac30fed21ca33d86
Requested by: Dhilan Fye (dfye@agentuity.com)

Summary by CodeRabbit

  • New Features

    • Introduces a Mastra Dynamic Agent example with sample prompts and a consumable entry point for running locally or in deployment.
  • Documentation

    • Adds a README with setup, local development, deployment steps, examples, and runtime notes.
  • Chores

    • Adds package manifest, runtime/bootstrap, TypeScript and tooling configs, environment example, Agentuity config, and comprehensive .gitignore rules.

- Convert Mastra dynamic agents example to Agentuity agent
- Preserve original Mastra framework functionality with dynamic context
- Add welcome function with example prompts
- Implement proper error handling and logging
- Follow established patterns from other Mastra examples
- Support dynamic behavior based on user tier and language context

Co-Authored-By: Dhilan Fye <dfye@agentuity.com>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 3, 2025

Walkthrough

Adds a new Mastra Dynamic Agents example under frameworks/mastra/dynamic-agents, including an Agentuity config, TypeScript setup, package manifest, .gitignore, README, a runtime bootstrap, and a Mastra dynamic agent that adapts prompts by inferring user tier and language.

Changes

Cohort / File(s) Summary
Agent implementation
frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts
Adds welcome() and a default async DynamicAgent(req, resp, ctx) handler that infers user tier/language, builds a Mastra Agent (gpt-4o-mini), constructs a contextual prompt, calls agent.generate(...), logs, and returns or falls back on error.
Runtime bootstrap / entry
frameworks/mastra/dynamic-agents/index.ts
Adds runtime bootstrap that validates AGENTUITY_API_KEY/AGENTUITY_SDK_KEY, warns on missing AGENTUITY_URL, invokes runner(true, import.meta.dirname), and handles startup errors.
Project manifest & scripts
frameworks/mastra/dynamic-agents/package.json
New package.json with scripts (build/dev/prestart/start), dependencies, devDeps, peerDeps, and package metadata for mastra-dynamic-agents.
Tooling / config
frameworks/mastra/dynamic-agents/tsconfig.json, frameworks/mastra/dynamic-agents/biome.json
Adds TypeScript compiler config and Biome formatter/linter settings (formatting, lint rules, vcs/file ignore settings).
Agentuity deployment config
frameworks/mastra/dynamic-agents/agentuity.yaml
Adds Agentuity project config (version, project_id, dev/deploy commands, bundler, resources, agents metadata).
Repository hygiene
frameworks/mastra/dynamic-agents/.gitignore
Adds comprehensive .gitignore covering node/bundler caches, env files, build/dist, coverage, editor metadata, and .agentuity/.
Docs & env
frameworks/mastra/dynamic-agents/README.md, frameworks/mastra/dynamic-agents/.env.development
Adds README describing behavior, setup, usage, and a placeholder .env.development file.

Sequence Diagram(s)

%%{init: {"securityLevel":"loose"}}%%
sequenceDiagram
  autonumber
  participant User as User
  participant Runtime as Agentuity Runtime
  participant Handler as DynamicAgent Handler
  participant Agent as Mastra Agent
  participant OpenAI as OpenAI Model

  User->>Runtime: HTTP request (text)
  Runtime->>Handler: invoke handler(req, resp, ctx)
  Handler->>Handler: detect tier (Free/Pro/Enterprise) & language (EN/JA)
  Handler->>Agent: construct agent + contextualPrompt
  Handler->>Agent: generate(contextualPrompt, {maxSteps:5})
  Agent->>OpenAI: model completion request
  OpenAI-->>Agent: completion result
  Agent-->>Handler: result.text
  Handler-->>Runtime: resp.text(result)
  Runtime-->>User: response

  alt Error path
    Handler->>Handler: log error
    Handler-->>Runtime: resp.text(fallback message)
    Runtime-->>User: fallback response
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • jhaynie
  • rblalock

Pre-merge checks (2 passed, 1 warning)

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
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 (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Add Mastra Dynamic Agents Example" succinctly and accurately summarizes the primary change — the addition of a Mastra dynamic agents example under frameworks/mastra/dynamic-agents, including code, configuration, and docs. It is concise, specific, and aligned with the PR objectives and file changes, so a reviewer scanning history will understand the main intent at a glance.

Poem

A rabbit hops through runtime lanes,
I sniff the tier and learn your aims.
I tweak my prompts, reply in kind,
こんにちは if you’re inclined.
Soft paws on code, I spring—then send. 🐇✨

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch devin/1756860827-mastra-dynamic-agents

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

@coderabbitai coderabbitai bot requested review from jhaynie and rblalock September 3, 2025 01:01
Copy link
Contributor

@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: 7

🧹 Nitpick comments (12)
frameworks/mastra/dynamic-agents/tsconfig.json (2)

12-12: Drop JSX setting (no React here).

Removes noise and avoids accidental TSX assumptions.

-    "jsx": "react-jsx",

If you don’t plan TSX files, also tighten includes:

-  "include": ["**/*.ts", "**/*.tsx"],
+  "include": ["**/*.ts"],

8-11: Consider enabling verbatimModuleSyntax for cleaner ESM.

Helps the bundler tree-shake and avoids implicit type-only elision quirks.

     "isolatedModules": true,
     "noEmit": true,
+    "verbatimModuleSyntax": true,
frameworks/mastra/dynamic-agents/biome.json (2)

23-26: Remove React-specific hook rule to reduce false positives.

useExhaustiveDependencies is React Hooks–focused and irrelevant here.

       "correctness": {
-        "noUnusedVariables": "error",
-        "useExhaustiveDependencies": "warn"
+        "noUnusedVariables": "error"
       },

12-15: Align indentation with repo standard (if spaces).

If the repo standard is spaces, switch to spaces to avoid churn; otherwise ignore.

   "formatter": {
     "enabled": true,
-    "indentStyle": "tab"
+    "indentStyle": "space"
   },
frameworks/mastra/dynamic-agents/.gitignore (1)

7-8: Deduplicate entries to keep the ignore list lean.

Multiple repeats of coverage/, node_modules/, dist, and .env are unnecessary.

Example cleanup:

-coverage/
-# Coverage directory used by tools like istanbul
-coverage/
-*.lcov
+coverage/
+*.lcov

-# Dependency directories
-node_modules/
-jspm_packages/
+node_modules/
+jspm_packages/

-# dotenv environment variables file
-.env
-.env.test
+.env
+.env.test

-# Nuxt.js build / generate output
-.nuxt
-dist
+.nuxt
+dist/

Also applies to: 32-35, 39-42, 64-67, 76-78

frameworks/mastra/dynamic-agents/README.md (2)

61-65: Polish example phrasing.

Minor tone/grammar tweaks.

-- **Pro User**: "I'm a pro user, provide detailed technical support"
+- **Pro User**: "I'm a pro user; please provide detailed technical support."
-- **Enterprise**: "I'm an enterprise customer, I need priority assistance"
+- **Enterprise**: "I'm an enterprise customer; I need priority assistance."
-- **Language**: "Can you help me in Japanese? (ja)"
+- **Language**: "Can you help me in Japanese (ja)?"

21-25: Clarify model/provider requirement.

Specify an example model (e.g., gpt-4o-mini) to match code and reduce confusion.

-This example uses the `openai` model. Make sure to add `OPENAI_API_KEY` to your `.env` file.
+This example uses OpenAI (e.g., `gpt-4o-mini`). Add `OPENAI_API_KEY` to your `.env` file.
frameworks/mastra/dynamic-agents/package.json (1)

23-29: Trim dependencies to the minimum set.

Having both mastra and @mastra/core may be redundant; keep only what’s used.

-    "@mastra/core": "^0.9.4",
-    "ai": "^4.3.16",
-    "mastra": "^0.6.3"
+    "@mastra/core": "^0.9.4",
+    "ai": "^4.3.16"

Please confirm actual imports before removing.

frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts (4)

18-22: Type the handler to Agentuity’s AgentHandler for compile-time safety.

Annotate the default export to match the SDK’s handler type and catch signature drift early.

Example:

-import type { AgentRequest, AgentResponse, AgentContext } from "@agentuity/sdk";
+import type { AgentRequest, AgentResponse, AgentContext, AgentHandler } from "@agentuity/sdk";-export default async function DynamicAgent(
+const DynamicAgent: AgentHandler = async function DynamicAgent(
   req: AgentRequest,
   resp: AgentResponse,
   ctx: AgentContext
 ) {
   …
-}
+}
+export default DynamicAgent;

56-61: Propagate cancellation and consider token/latency limits.

If Agent.generate supports AbortSignal/options, pass ctx.abortSignal and set sensible caps (temperature/tokens) for demos.

Example (adjust to API):

const result = await agent.generate(contextualPrompt, {
  maxSteps: 5,
  // signal: ctx.abortSignal,
  // maxOutputTokens: 512,
  // temperature: 0.3,
});

58-59: Log structured context for observability.

Capture inferred tier/lang to aid debugging without logging PII.

-    ctx.logger.info("Dynamic agent processed request with contextual prompt");
+    ctx.logger.info({ contextualPromptLength: contextualPrompt.length }, "processed dynamic-agent request");

61-64: Preserve error details in logs; keep user message generic.

Good pattern. Consider tagging with an error code for easier support triage.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 61337c0 and a5774cd.

📒 Files selected for processing (8)
  • frameworks/mastra/dynamic-agents/.gitignore (1 hunks)
  • frameworks/mastra/dynamic-agents/README.md (1 hunks)
  • frameworks/mastra/dynamic-agents/agentuity.yaml (1 hunks)
  • frameworks/mastra/dynamic-agents/biome.json (1 hunks)
  • frameworks/mastra/dynamic-agents/index.ts (1 hunks)
  • frameworks/mastra/dynamic-agents/package.json (1 hunks)
  • frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts (1 hunks)
  • frameworks/mastra/dynamic-agents/tsconfig.json (1 hunks)
🧰 Additional context used
🧠 Learnings (45)
📓 Common learnings
Learnt from: CR
PR: agentuity/examples#0
File: agents/agent-riza/.cursor/rules/sdk.mdc:0-0
Timestamp: 2025-07-17T13:39:31.143Z
Learning: Applies to agents/agent-riza/src/agents/**/*.ts : Consider agent communication (e.g., `response.handoff`, `context.getAgent`) for complex workflows
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/mastra/basic/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-06-23T17:15:12.561Z
Learning: In Agentuity AI Agent files (`**/src/agents/**/index.ts`), import types such as `AgentRequest`, `AgentResponse`, and `AgentContext` from the `agentuity/sdk` package to ensure type safety and consistency.
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/langgraph/basic/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-06-23T17:14:39.393Z
Learning: In Agentuity AI Agent files (`**/src/agents/**/index.ts`), import types such as `AgentRequest`, `AgentResponse`, and `AgentContext` from the `agentuity/sdk` package to ensure type safety and consistency.
Learnt from: CR
PR: agentuity/examples#0
File: agents/composio/.cursor/rules/sdk.mdc:0-0
Timestamp: 2025-07-17T13:39:44.988Z
Learning: Applies to agents/composio/src/agents/**/*.ts : Use TypeScript for better type safety and IDE support
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/langgraph/basic/.cursor/rules/sdk.mdc:0-0
Timestamp: 2025-06-23T17:14:46.802Z
Learning: The Agentuity JavaScript SDK provides core interfaces such as AgentHandler, AgentRequest, AgentResponse, and AgentContext for building AI agents in TypeScript or JavaScript.
📚 Learning: 2025-07-17T13:39:44.988Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/composio/.cursor/rules/sdk.mdc:0-0
Timestamp: 2025-07-17T13:39:44.988Z
Learning: Applies to agents/composio/src/agents/**/*.ts : Use TypeScript for better type safety and IDE support

Applied to files:

  • frameworks/mastra/dynamic-agents/tsconfig.json
📚 Learning: 2025-07-17T13:39:37.133Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/composio/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:39:37.133Z
Learning: Applies to agents/composio/**/src/agents/**/index.ts : All code should be in Typescript format

Applied to files:

  • frameworks/mastra/dynamic-agents/tsconfig.json
📚 Learning: 2025-07-17T13:39:31.143Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/agent-riza/.cursor/rules/sdk.mdc:0-0
Timestamp: 2025-07-17T13:39:31.143Z
Learning: Applies to agents/agent-riza/src/agents/**/*.ts : Use TypeScript for better type safety and IDE support

Applied to files:

  • frameworks/mastra/dynamic-agents/tsconfig.json
📚 Learning: 2025-07-17T13:40:05.817Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/deep-research-js/.cursor/rules/sdk.mdc:0-0
Timestamp: 2025-07-17T13:40:05.817Z
Learning: Applies to agents/deep-research-js/src/agents/**/*.ts : Use TypeScript for better type safety and IDE support

Applied to files:

  • frameworks/mastra/dynamic-agents/tsconfig.json
📚 Learning: 2025-07-17T13:40:50.861Z
Learnt from: CR
PR: agentuity/examples#0
File: agentuity/sdk-js/streaming/.cursor/rules/sdk.mdc:0-0
Timestamp: 2025-07-17T13:40:50.861Z
Learning: Applies to agentuity/sdk-js/streaming/src/agents/**/*.ts : Use TypeScript for better type safety and IDE support

Applied to files:

  • frameworks/mastra/dynamic-agents/tsconfig.json
📚 Learning: 2025-07-17T13:39:18.709Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/agent-riza/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:39:18.709Z
Learning: Applies to agents/agent-riza/**/src/agents/**/index.ts : All code should be in Typescript format

Applied to files:

  • frameworks/mastra/dynamic-agents/tsconfig.json
📚 Learning: 2025-07-17T13:39:55.775Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/deep-research-js/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:39:55.775Z
Learning: Applies to agents/deep-research-js/**/src/agents/**/index.ts : All code should be in Typescript format

Applied to files:

  • frameworks/mastra/dynamic-agents/tsconfig.json
📚 Learning: 2025-07-17T13:40:37.445Z
Learnt from: CR
PR: agentuity/examples#0
File: agentuity/sdk-js/streaming/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:40:37.445Z
Learning: Applies to agentuity/sdk-js/streaming/**/src/agents/**/index.ts : All code should be in Typescript format

Applied to files:

  • frameworks/mastra/dynamic-agents/tsconfig.json
📚 Learning: 2025-06-23T17:17:19.027Z
Learnt from: CR
PR: agentuity/examples#0
File: patterns/llmAsJury/.cursor/rules/sdk.mdc:0-0
Timestamp: 2025-06-23T17:17:19.027Z
Learning: Use TypeScript for better type safety and IDE support when developing with the Agentuity SDK.

Applied to files:

  • frameworks/mastra/dynamic-agents/tsconfig.json
📚 Learning: 2025-06-23T17:14:39.393Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/langgraph/basic/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-06-23T17:14:39.393Z
Learning: In Agentuity AI Agent files (`**/src/agents/**/index.ts`), import types such as `AgentRequest`, `AgentResponse`, and `AgentContext` from the `agentuity/sdk` package to ensure type safety and consistency.

Applied to files:

  • frameworks/mastra/dynamic-agents/package.json
  • frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts
📚 Learning: 2025-07-17T13:39:37.133Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/composio/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:39:37.133Z
Learning: Applies to agents/composio/**/src/agents/**/index.ts : Prefer loading types from the node modules package `agentuity/sdk` in the node_modules folder

Applied to files:

  • frameworks/mastra/dynamic-agents/package.json
📚 Learning: 2025-07-17T13:39:18.709Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/agent-riza/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:39:18.709Z
Learning: Applies to agents/agent-riza/**/src/agents/**/index.ts : Prefer loading types from the node modules package `agentuity/sdk` in the node_modules folder

Applied to files:

  • frameworks/mastra/dynamic-agents/package.json
📚 Learning: 2025-07-17T13:39:55.775Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/deep-research-js/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:39:55.775Z
Learning: Applies to agents/deep-research-js/**/src/agents/**/index.ts : Prefer loading types from the node modules package `agentuity/sdk` in the node_modules folder

Applied to files:

  • frameworks/mastra/dynamic-agents/package.json
📚 Learning: 2025-07-17T13:38:58.657Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/Startup_News_Scraper/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:38:58.657Z
Learning: Applies to agents/Startup_News_Scraper/**/src/agents/**/index.ts : Prefer loading types from the node modules package `agentuity/sdk` in the node_modules folder

Applied to files:

  • frameworks/mastra/dynamic-agents/package.json
📚 Learning: 2025-07-17T13:40:37.445Z
Learnt from: CR
PR: agentuity/examples#0
File: agentuity/sdk-js/streaming/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:40:37.445Z
Learning: Applies to agentuity/sdk-js/streaming/**/src/agents/**/index.ts : Prefer loading types from the node modules package `agentuity/sdk` in the node_modules folder

Applied to files:

  • frameworks/mastra/dynamic-agents/package.json
📚 Learning: 2025-07-17T13:39:44.988Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/composio/.cursor/rules/sdk.mdc:0-0
Timestamp: 2025-07-17T13:39:44.988Z
Learning: Applies to agents/composio/src/agents/**/*.ts : Import types from `agentuity/sdk`

Applied to files:

  • frameworks/mastra/dynamic-agents/package.json
📚 Learning: 2025-07-17T13:40:05.817Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/deep-research-js/.cursor/rules/sdk.mdc:0-0
Timestamp: 2025-07-17T13:40:05.817Z
Learning: Applies to agents/deep-research-js/src/agents/**/*.ts : Import types from `agentuity/sdk`

Applied to files:

  • frameworks/mastra/dynamic-agents/package.json
📚 Learning: 2025-07-17T13:39:31.143Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/agent-riza/.cursor/rules/sdk.mdc:0-0
Timestamp: 2025-07-17T13:39:31.143Z
Learning: Applies to agents/agent-riza/src/agents/**/*.ts : Import types from `agentuity/sdk`

Applied to files:

  • frameworks/mastra/dynamic-agents/package.json
📚 Learning: 2025-07-17T13:39:55.775Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/deep-research-js/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:39:55.775Z
Learning: Applies to agents/deep-research-js/**/src/agents/**/index.ts : The file should export a default function

Applied to files:

  • frameworks/mastra/dynamic-agents/index.ts
  • frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts
📚 Learning: 2025-07-17T13:39:37.133Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/composio/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:39:37.133Z
Learning: Applies to agents/composio/**/src/agents/**/index.ts : The file should export a default function

Applied to files:

  • frameworks/mastra/dynamic-agents/index.ts
  • frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts
📚 Learning: 2025-07-17T13:39:18.709Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/agent-riza/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:39:18.709Z
Learning: Applies to agents/agent-riza/**/src/agents/**/index.ts : The file should export a default function

Applied to files:

  • frameworks/mastra/dynamic-agents/index.ts
  • frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts
📚 Learning: 2025-07-17T13:40:37.445Z
Learnt from: CR
PR: agentuity/examples#0
File: agentuity/sdk-js/streaming/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:40:37.445Z
Learning: Applies to agentuity/sdk-js/streaming/**/src/agents/**/index.ts : The file should export a default function

Applied to files:

  • frameworks/mastra/dynamic-agents/index.ts
📚 Learning: 2025-07-17T13:39:55.775Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/deep-research-js/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:39:55.775Z
Learning: Applies to agents/deep-research-js/**/src/agents/**/index.ts : Prefer naming the default function Agent or the name of the Agent based on the context of the Agent description

Applied to files:

  • frameworks/mastra/dynamic-agents/index.ts
  • frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts
📚 Learning: 2025-07-17T13:39:37.133Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/composio/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:39:37.133Z
Learning: Applies to agents/composio/**/src/agents/**/index.ts : Prefer naming the default function Agent or the name of the Agent based on the context of the Agent description

Applied to files:

  • frameworks/mastra/dynamic-agents/index.ts
  • frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts
📚 Learning: 2025-07-17T13:39:18.709Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/agent-riza/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:39:18.709Z
Learning: Applies to agents/agent-riza/**/src/agents/**/index.ts : Prefer naming the default function Agent or the name of the Agent based on the context of the Agent description

Applied to files:

  • frameworks/mastra/dynamic-agents/index.ts
  • frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts
📚 Learning: 2025-07-17T13:38:58.657Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/Startup_News_Scraper/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:38:58.657Z
Learning: Applies to agents/Startup_News_Scraper/**/src/agents/**/index.ts : The file should export a default function

Applied to files:

  • frameworks/mastra/dynamic-agents/index.ts
📚 Learning: 2025-07-17T13:40:37.445Z
Learnt from: CR
PR: agentuity/examples#0
File: agentuity/sdk-js/streaming/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:40:37.445Z
Learning: Applies to agentuity/sdk-js/streaming/**/src/agents/**/index.ts : Prefer naming the default function Agent or the name of the Agent based on the context of the Agent description

Applied to files:

  • frameworks/mastra/dynamic-agents/index.ts
  • frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts
📚 Learning: 2025-06-23T17:14:39.393Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/langgraph/basic/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-06-23T17:14:39.393Z
Learning: In Agentuity AI Agent files (`**/src/agents/**/index.ts`), the default export should be an async function that handles the agent logic, typically accepting parameters `(req: AgentRequest, resp: AgentResponse, ctx: AgentContext)`.

Applied to files:

  • frameworks/mastra/dynamic-agents/index.ts
  • frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts
📚 Learning: 2025-06-23T17:16:33.550Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/pydantic/basic/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-06-23T17:16:33.550Z
Learning: The agentuity.yaml file is a configuration file used by Agentuity to configure the AI Agent project and should not be edited or suggested for edits during code review.

Applied to files:

  • frameworks/mastra/dynamic-agents/agentuity.yaml
📚 Learning: 2025-06-23T17:16:16.519Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/openai/from-oai/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-06-23T17:16:16.519Z
Learning: The Agentuity configuration file (agentuity.yaml) is reserved for configuring the AI Agent project and should not be edited or suggested for edits during code review.

Applied to files:

  • frameworks/mastra/dynamic-agents/agentuity.yaml
📚 Learning: 2025-06-23T17:13:52.368Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/crewai/socialagent/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-06-23T17:13:52.368Z
Learning: The 'agentuity.yaml' file is a configuration file used by Agentuity to configure the AI Agent project and should not be edited or suggested for edits.

Applied to files:

  • frameworks/mastra/dynamic-agents/agentuity.yaml
📚 Learning: 2025-06-23T17:14:18.092Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/langchain/basic/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-06-23T17:14:18.092Z
Learning: The file 'agentuity.yaml' is used to configure the Agentuity AI Agent project and should not be edited or suggested for edits.

Applied to files:

  • frameworks/mastra/dynamic-agents/agentuity.yaml
📚 Learning: 2025-06-23T17:15:46.735Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/miscellaneous/mem0/mem0demo/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-06-23T17:15:46.735Z
Learning: The Agentuity configuration file (agentuity.yaml) is used to configure the AI Agent project and should not be edited or suggested for edits.

Applied to files:

  • frameworks/mastra/dynamic-agents/agentuity.yaml
📚 Learning: 2025-06-23T17:15:30.804Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/miscellaneous/grokLiveSearch/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-06-23T17:15:30.804Z
Learning: In the context of Agentuity AI projects, the 'agentuity.yaml' file is a configuration file that should not be edited or suggested for edits during code review.

Applied to files:

  • frameworks/mastra/dynamic-agents/agentuity.yaml
📚 Learning: 2025-06-23T17:17:12.992Z
Learnt from: CR
PR: agentuity/examples#0
File: patterns/llmAsJury/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-06-23T17:17:12.992Z
Learning: In the context of Agentuity AI projects, the agentuity.yaml file is a configuration file that should not be edited or suggested for edits during code review.

Applied to files:

  • frameworks/mastra/dynamic-agents/agentuity.yaml
📚 Learning: 2025-06-23T17:16:02.063Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/openai/from-oai-typescript/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-06-23T17:16:02.063Z
Learning: The Agentuity AI Configuration file (agentuity.yaml) is used to configure the AI Agent project and should not be edited or suggested for edits.

Applied to files:

  • frameworks/mastra/dynamic-agents/agentuity.yaml
📚 Learning: 2025-07-17T13:39:39.665Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/composio/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-07-17T13:39:39.665Z
Learning: Applies to agents/composio/**/agentuity.yaml : Do NOT suggest edits to the Agentuity AI Configuration file (agentuity.yaml)

Applied to files:

  • frameworks/mastra/dynamic-agents/agentuity.yaml
📚 Learning: 2025-07-17T13:41:01.314Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/agno/from_agno/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-07-17T13:41:01.314Z
Learning: Applies to frameworks/agno/from_agno/**/agentuity.yaml : Do not suggest edits to the Agentuity AI Configuration file (agentuity.yaml)

Applied to files:

  • frameworks/mastra/dynamic-agents/agentuity.yaml
📚 Learning: 2025-07-17T13:39:58.483Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/deep-research-js/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-07-17T13:39:58.483Z
Learning: Applies to agents/deep-research-js/**/agentuity.yaml : Do not suggest edits to the agentuity.yaml configuration file

Applied to files:

  • frameworks/mastra/dynamic-agents/agentuity.yaml
📚 Learning: 2025-07-17T13:38:58.657Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/Startup_News_Scraper/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:38:58.657Z
Learning: Applies to agents/Startup_News_Scraper/**/src/agents/**/index.ts : Prefer naming the default function Agent or the name of the Agent based on the context of the Agent description

Applied to files:

  • frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts
📚 Learning: 2025-06-23T17:16:49.315Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/vercel/basic/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-06-23T17:16:49.315Z
Learning: When writing an Agent in TypeScript for Agentuity, always use the types provided by the `agentuity/sdk` package for AgentRequest, AgentResponse, and AgentContext to ensure type safety and compatibility.

Applied to files:

  • frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts
📚 Learning: 2025-06-23T17:14:46.802Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/langgraph/basic/.cursor/rules/sdk.mdc:0-0
Timestamp: 2025-06-23T17:14:46.802Z
Learning: The Agentuity JavaScript SDK provides core interfaces such as AgentHandler, AgentRequest, AgentResponse, and AgentContext for building AI agents in TypeScript or JavaScript.

Applied to files:

  • frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts
📚 Learning: 2025-06-23T17:15:21.314Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/mastra/basic/.cursor/rules/sdk.mdc:0-0
Timestamp: 2025-06-23T17:15:21.314Z
Learning: In the Agentuity JavaScript SDK, the main handler for an agent should implement the AgentHandler type: a function that takes (request: AgentRequest, response: AgentResponse, context: AgentContext) and returns a Promise of AgentResponseType.

Applied to files:

  • frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts
📚 Learning: 2025-06-23T17:16:58.079Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/vercel/basic/.cursor/rules/sdk.mdc:0-0
Timestamp: 2025-06-23T17:16:58.079Z
Learning: In the Agentuity JavaScript SDK, the main handler for an agent should implement the AgentHandler type: (request: AgentRequest, response: AgentResponse, context: AgentContext) => Promise<AgentResponseType>.

Applied to files:

  • frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts
🪛 LanguageTool
frameworks/mastra/dynamic-agents/README.md

[grammar] ~6-~6: There might be a mistake here.
Context: ...e responses. This example shows how to: - Create agents with dynamic instructions ...

(QB_NEW_EN)


[grammar] ~54-~54: There might be a mistake here.
Context: ... determine context (user tier, language) 2. Dynamic Instructions: Agent instructio...

(QB_NEW_EN)


[grammar] ~55-~55: There might be a mistake here.
Context: ...ons change based on the detected context 3. Contextual Response: Provides appropri...

(QB_NEW_EN)


[grammar] ~56-~56: There might be a mistake here.
Context: ...iate level of support based on user tier 4. Language Adaptation: Responds in the u...

(QB_NEW_EN)


[style] ~61-~61: If you’re making a request, consider inserting ‘please’ to sound more courteous and respectful.
Context: ...ree Tier User**: "I'm a free tier user, can you help me with basic documentation?" - **...

(CAN_YOU)


[grammar] ~61-~61: There might be a mistake here.
Context: ...n you help me with basic documentation?" - Pro User: "I'm a pro user, provide det...

(QB_NEW_EN)


[grammar] ~68-~68: There might be a mistake here.
Context: ...chnical Details The agent demonstrates: - Dynamic context detection from user inpu...

(QB_NEW_EN)


[grammar] ~69-~69: There might be a mistake here.
Context: ...ynamic context detection from user input - Contextual prompt modification based on ...

(QB_NEW_EN)


[grammar] ~70-~70: There might be a mistake here.
Context: ...ed on user tier and language preferences - Adaptive agent instructions that change ...

(QB_NEW_EN)


[grammar] ~71-~71: There might be a mistake here.
Context: ...hange behavior based on detected context - Integration with Agentuity's platform fo...

(QB_NEW_EN)

🔇 Additional comments (3)
frameworks/mastra/dynamic-agents/package.json (1)

4-5: Align package.json entrypoints with build output. The main (index.js) and module (index.ts) fields reference files that don’t exist after running the build. Either configure the build to emit a JS entry (e.g. .agentuity/index.js) or update main/module to point at the actual entry sources (and add a types field for your TypeScript declarations).

⛔ Skipped due to learnings
Learnt from: CR
PR: agentuity/examples#0
File: agents/composio/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:39:37.133Z
Learning: Applies to agents/composio/**/src/agents/**/index.ts : All code should be in Typescript format
Learnt from: CR
PR: agentuity/examples#0
File: agents/composio/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:39:37.133Z
Learning: Applies to agents/composio/**/src/agents/**/index.ts : Prefer loading types from the node modules package `agentuity/sdk` in the node_modules folder
Learnt from: CR
PR: agentuity/examples#0
File: agentuity/sdk-js/streaming/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:40:37.445Z
Learning: Applies to agentuity/sdk-js/streaming/**/src/agents/**/index.ts : Prefer loading types from the node modules package `agentuity/sdk` in the node_modules folder
Learnt from: CR
PR: agentuity/examples#0
File: agents/agent-riza/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:39:18.709Z
Learning: Applies to agents/agent-riza/**/src/agents/**/index.ts : Prefer loading types from the node modules package `agentuity/sdk` in the node_modules folder
Learnt from: CR
PR: agentuity/examples#0
File: agents/deep-research-js/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:39:55.775Z
Learning: Applies to agents/deep-research-js/**/src/agents/**/index.ts : All code should be in Typescript format
Learnt from: CR
PR: agentuity/examples#0
File: agents/agent-riza/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:39:18.709Z
Learning: Applies to agents/agent-riza/**/src/agents/**/index.ts : All code should be in Typescript format
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/langgraph/basic/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-06-23T17:14:39.393Z
Learning: In Agentuity AI Agent files (`**/src/agents/**/index.ts`), import types such as `AgentRequest`, `AgentResponse`, and `AgentContext` from the `agentuity/sdk` package to ensure type safety and consistency.
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/mastra/basic/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-06-23T17:15:12.561Z
Learning: In Agentuity AI Agent files (`**/src/agents/**/index.ts`), import types such as `AgentRequest`, `AgentResponse`, and `AgentContext` from the `agentuity/sdk` package to ensure type safety and consistency.
Learnt from: CR
PR: agentuity/examples#0
File: agentuity/sdk-js/streaming/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:40:37.445Z
Learning: Applies to agentuity/sdk-js/streaming/**/src/agents/**/index.ts : All code should be in Typescript format
Learnt from: CR
PR: agentuity/examples#0
File: agents/deep-research-js/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:39:55.775Z
Learning: Applies to agents/deep-research-js/**/src/agents/**/index.ts : Prefer loading types from the node modules package `agentuity/sdk` in the node_modules folder
frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts (1)

26-41: Verify Agent model integration
Ensure that openai("gpt-4o-mini") returns the exact type expected by the model field in the Agent constructor. If Agent requires a plain model ID string (or a different adapter), adjust the call accordingly.

frameworks/mastra/dynamic-agents/agentuity.yaml (1)

1-74: Config acknowledged.

No suggestions; we don’t review or propose changes to agentuity.yaml per project guidelines. Mapping to src/agents looks consistent.

@@ -0,0 +1 @@
export { default } from "./src/agents/mastra-dynamic-agent/index.js";
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Broken re-export to a non-existent .js file (likely causes dev startup failure).

This TS entry points at a .js file that doesn’t exist in the source tree during dev. Prefer an extensionless path so TS/Bun/NodeNext resolve the TS source or built JS uniformly.

Apply:

-export { default } from "./src/agents/mastra-dynamic-agent/index.js";
+export { default } from "./src/agents/mastra-dynamic-agent";

Run to confirm the .js target is missing:


🏁 Script executed:

#!/bin/bash
test -f frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.js || echo "index.js not found (expected during TS dev)"

Length of output: 180


Fix broken re-export to extensionless path

Replace the re-export to point at the module without “.js”, so Node/TS resolve the TS source or built JS correctly:

--- frameworks/mastra/dynamic-agents/index.ts
-export { default } from "./src/agents/mastra-dynamic-agent/index.js";
+export { default } from "./src/agents/mastra-dynamic-agent";
📝 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
export { default } from "./src/agents/mastra-dynamic-agent/index.js";
export { default } from "./src/agents/mastra-dynamic-agent";
🤖 Prompt for AI Agents
frameworks/mastra/dynamic-agents/index.ts (lines 1-1): The current re-export
references a file with a “.js” extension which breaks Node/TS resolution; change
the export to point to the module path without the “.js” extension (export {
default } from "./src/agents/mastra-dynamic-agent";) so TypeScript and Node can
resolve to the TS source or built JS depending on environment.

Comment on lines +6 to +13
"scripts": {
"build": "agentuity build",
"dev": "agentuity dev",
"format": "biome format --write .",
"lint": "biome lint .",
"prestart": "agentuity bundle",
"start": "bun run .agentuity/index.js"
},
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Make scripts self-contained (no global CLI required).

Use npx to ensure the Agentuity CLI resolves without a global install.

-    "build": "agentuity build",
-    "dev": "agentuity dev",
+    "build": "npx -y agentuity@latest build",
+    "dev": "npx -y agentuity@latest dev",
     "format": "biome format --write .",
     "lint": "biome lint .",
-    "prestart": "agentuity bundle",
-    "start": "bun run .agentuity/index.js"
+    "prestart": "npx -y agentuity@latest bundle",
+    "start": "bun run .agentuity/index.js"

Alternatively, add the CLI as a devDependency.

📝 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
"scripts": {
"build": "agentuity build",
"dev": "agentuity dev",
"format": "biome format --write .",
"lint": "biome lint .",
"prestart": "agentuity bundle",
"start": "bun run .agentuity/index.js"
},
// frameworks/mastra/dynamic-agents/package.json
{
"scripts": {
"build": "npx -y agentuity@latest build",
"dev": "npx -y agentuity@latest dev",
"format":"biome format --write .",
"lint": "biome lint .",
"prestart":"npx -y agentuity@latest bundle",
"start": "bun run .agentuity/index.js"
}
}
🤖 Prompt for AI Agents
In frameworks/mastra/dynamic-agents/package.json around lines 6 to 13, the npm
scripts invoke the Agentuity CLI expecting a global install; update the scripts
to be self-contained by either (A) prefixing CLI invocations with npx (e.g.,
"build": "npx agentuity build", etc.) so the local or remote binary is resolved
at runtime, or (B) add "agentuity" as a devDependency in package.json and then
use the package bin via npm scripts (or still use npx) to ensure CI/local runs
do not require a global install; pick one approach and make the scripts
consistent.

Comment on lines +16 to +19
"devDependencies": {
"@biomejs/biome": "^1.9.4",
"@types/bun": "^1.2.13"
},
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Align TS types config with tsconfig change.

If switching to "types": ["bun"], keep @types/bun; otherwise install bun-types and update tsconfig accordingly.


🏁 Script executed:

#!/bin/bash
# Check that Bun types resolve
jq -r '.devDependencies' frameworks/mastra/dynamic-agents/package.json
rg -n 'types": \\["bun' frameworks/mastra/dynamic-agents/tsconfig.json || true

Length of output: 297


🏁 Script executed:

#!/bin/bash
# Check for bun in tsconfig types array
rg -nP '"types"\s*:\s*\[\s*"bun"' frameworks/mastra/dynamic-agents/tsconfig.json || echo 'no types: ["bun"] found'

Length of output: 139


🏁 Script executed:

#!/bin/bash
sed -n '1,200p' frameworks/mastra/dynamic-agents/tsconfig.json

Length of output: 585


Replace @types/bun with bun-types in devDependencies
tsconfig.json’s "types": ["bun-types"] requires the bun-types package—remove @types/bun and add "bun-types": "latest" (or pinned version) under devDependencies.

🤖 Prompt for AI Agents
In frameworks/mastra/dynamic-agents/package.json around lines 16 to 19, replace
the incorrect devDependency "@types/bun" with "bun-types": "latest" (or a pinned
version). Remove the "@types/bun" entry and add "bun-types" under
devDependencies so it matches tsconfig.json's "types": ["bun-types"]; update
package.json accordingly and run install to ensure types resolve.


```bash
# Navigate to the agent directory
cd mastra-dynamic-agents
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix path to the package directory.

Commands should cd into the framework subfolder; current path will fail.

-cd mastra-dynamic-agents
+cd frameworks/mastra/dynamic-agents

Apply in both Local Development and Deployment sections.

Also applies to: 44-44

🤖 Prompt for AI Agents
In frameworks/mastra/dynamic-agents/README.md around lines 31 and 44, the cd
command points to the repo root (cd mastra-dynamic-agents) instead of the
framework subfolder; update both occurrences to cd into the correct package
directory (the framework subfolder) so the commands run from the package path
used by Local Development and Deployment sections, e.g., replace the existing cd
instruction with the framework subfolder path for both line 31 and line 44.

Comment on lines +24 to +25
const input = await req.data.text() ?? "Can Mastra Cloud handle long-running tasks?";

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fallback doesn’t trigger for empty/whitespace inputs.

Nullish coalescing won’t catch "", leading to an empty prompt. Trim and default.

-    const input = await req.data.text() ?? "Can Mastra Cloud handle long-running tasks?";
+    const raw = (await req.data.text()) ?? "";
+    const input = raw.trim() || "Can Mastra Cloud handle long-running tasks?";
📝 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 input = await req.data.text() ?? "Can Mastra Cloud handle long-running tasks?";
const raw = (await req.data.text()) ?? "";
const input = raw.trim() || "Can Mastra Cloud handle long-running tasks?";
🤖 Prompt for AI Agents
In frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts
around lines 24 to 25, the current nullish-coalescing fallback doesn't handle
empty or whitespace-only strings; change the logic to read the text, trim it,
and if the result is empty use the default prompt (e.g., const raw = await
req.data.text(); const input = (raw && raw.trim()) ? raw.trim() : "Can Mastra
Cloud handle long-running tasks?"). Ensure you trim before checking emptiness so
whitespace-only inputs fall back to the default.

Comment on lines +42 to +54
let contextualPrompt = input;

if (input.includes("free") || input.includes("basic")) {
contextualPrompt = `[User Tier: Free] ${input}. Please provide basic help and documentation links.`;
} else if (input.includes("pro") || input.includes("detailed")) {
contextualPrompt = `[User Tier: Pro] ${input}. Please provide detailed technical support and best practices.`;
} else if (input.includes("enterprise") || input.includes("priority")) {
contextualPrompt = `[User Tier: Enterprise] ${input}. Please provide priority assistance with tailored solutions.`;
}

if (input.includes("ja") || input.includes("japanese")) {
contextualPrompt += " Please respond in Japanese.";
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Make context detection case-insensitive and avoid “ja” false positives.

Current includes() is case-sensitive and “ja” can match “Java”. Normalize and use word boundaries.

-    let contextualPrompt = input;
-    
-    if (input.includes("free") || input.includes("basic")) {
+    let contextualPrompt = input;
+    const lc = input.toLowerCase();
+
+    if (/\b(free|basic)\b/i.test(input)) {
       contextualPrompt = `[User Tier: Free] ${input}. Please provide basic help and documentation links.`;
-    } else if (input.includes("pro") || input.includes("detailed")) {
+    } else if (/\b(pro|detailed)\b/i.test(input)) {
       contextualPrompt = `[User Tier: Pro] ${input}. Please provide detailed technical support and best practices.`;
-    } else if (input.includes("enterprise") || input.includes("priority")) {
+    } else if (/\b(enterprise|priority)\b/i.test(input)) {
       contextualPrompt = `[User Tier: Enterprise] ${input}. Please provide priority assistance with tailored solutions.`;
     }
 
-    if (input.includes("ja") || input.includes("japanese")) {
+    if (/\bjapanese\b/i.test(input) || /\bja\b/i.test(input) || /日本語/.test(input)) {
       contextualPrompt += " Please respond in Japanese.";
     }
📝 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
let contextualPrompt = input;
if (input.includes("free") || input.includes("basic")) {
contextualPrompt = `[User Tier: Free] ${input}. Please provide basic help and documentation links.`;
} else if (input.includes("pro") || input.includes("detailed")) {
contextualPrompt = `[User Tier: Pro] ${input}. Please provide detailed technical support and best practices.`;
} else if (input.includes("enterprise") || input.includes("priority")) {
contextualPrompt = `[User Tier: Enterprise] ${input}. Please provide priority assistance with tailored solutions.`;
}
if (input.includes("ja") || input.includes("japanese")) {
contextualPrompt += " Please respond in Japanese.";
}
let contextualPrompt = input;
const lc = input.toLowerCase();
if (/\b(free|basic)\b/i.test(input)) {
contextualPrompt = `[User Tier: Free] ${input}. Please provide basic help and documentation links.`;
} else if (/\b(pro|detailed)\b/i.test(input)) {
contextualPrompt = `[User Tier: Pro] ${input}. Please provide detailed technical support and best practices.`;
} else if (/\b(enterprise|priority)\b/i.test(input)) {
contextualPrompt = `[User Tier: Enterprise] ${input}. Please provide priority assistance with tailored solutions.`;
}
if (/\bjapanese\b/i.test(input) || /\bja\b/i.test(input) || //.test(input)) {
contextualPrompt += " Please respond in Japanese.";
}
🤖 Prompt for AI Agents
In frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts
around lines 42 to 54, the current context detection is case-sensitive and the
"ja" check can falsely match substrings like "Java"; convert the input to a
normalized lowercase string and perform checks against that (e.g., const
normalized = input.toLowerCase()), replace the existing includes(...) checks
with checks against normalized, and for language detection use word-boundary
matching for "ja" (e.g., regex /\bja\b/ or explicitly check for "japanese") so
only whole-word "ja" matches and not substrings.

"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"types": ["bun-types"]
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix Bun types mismatch to avoid missing globals.

tsconfig references "bun-types" but package.json installs "@types/bun". Use "bun" here.

Apply:

-    "types": ["bun-types"]
+    "types": ["bun"]
📝 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
"types": ["bun-types"]
"types": ["bun"]
🤖 Prompt for AI Agents
frameworks/mastra/dynamic-agents/tsconfig.json around line 17: the "types" entry
currently references "bun-types" which doesn't match the installed package
"@types/bun"; update the entry to "bun" so TypeScript picks up the correct
globals (i.e., replace "bun-types" with "bun"), and if needed ensure
package.json has "@types/bun" installed or remove any incorrect "bun-types"
package.

Copy link
Contributor

@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: 3

♻️ Duplicate comments (2)
frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts (2)

25-26: Trim and fallback for empty/whitespace inputs.

Nullish coalescing won’t catch "" and " ". Trim then default.

-    const input = await req.data.text() ?? "Can Mastra Cloud handle long-running tasks?";
+    const raw = (await req.data.text()) ?? "";
+    const input = raw.trim() || "Can Mastra Cloud handle long-running tasks?";

43-55: Make tier/language detection case-insensitive and avoid “ja” in “Java”.

Use word-boundary regex and include 日本語.

-    let contextualPrompt = input;
-    
-    if (input.includes("free") || input.includes("basic")) {
+    let contextualPrompt = input;
+    const lc = input.toLowerCase();
+
+    if (/\b(free|basic)\b/i.test(input)) {
       contextualPrompt = `[User Tier: Free] ${input}. Please provide basic help and documentation links.`;
-    } else if (input.includes("pro") || input.includes("detailed")) {
+    } else if (/\b(pro|detailed)\b/i.test(input)) {
       contextualPrompt = `[User Tier: Pro] ${input}. Please provide detailed technical support and best practices.`;
-    } else if (input.includes("enterprise") || input.includes("priority")) {
+    } else if (/\b(enterprise|priority)\b/i.test(input)) {
       contextualPrompt = `[User Tier: Enterprise] ${input}. Please provide priority assistance with tailored solutions.`;
     }
 
-    if (input.includes("ja") || input.includes("japanese")) {
+    if (/\bjapanese\b/i.test(input) || /\bja\b/i.test(input) || /日本語/.test(input)) {
       contextualPrompt += " Please respond in Japanese.";
     }
🧹 Nitpick comments (2)
frameworks/mastra/dynamic-agents/index.ts (1)

17-27: Use yellow for warnings, not red (readability).

-  console.warn(
-    '\x1b[31m[WARN] You are running this agent outside of the Agentuity environment. Any automatic Agentuity features will be disabled.\x1b[0m'
-  );
+  console.warn(
+    '\x1b[33m[WARN] You are running this agent outside of the Agentuity environment. Any automatic Agentuity features will be disabled.\x1b[0m'
+  );
frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts (1)

59-64: Optional: log detected context for debugging.

Helps verify dynamic behavior during manual tests.

-    ctx.logger.info("Dynamic agent processed request with contextual prompt");
+    ctx.logger.info("Dynamic agent processed request with contextual prompt");
+    ctx.logger.debug("context_prompt=%s", contextualPrompt);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a5774cd and 758398a.

⛔ Files ignored due to path filters (1)
  • frameworks/mastra/dynamic-agents/bun.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • frameworks/mastra/dynamic-agents/.env.development (1 hunks)
  • frameworks/mastra/dynamic-agents/agentuity.yaml (1 hunks)
  • frameworks/mastra/dynamic-agents/index.ts (1 hunks)
  • frameworks/mastra/dynamic-agents/package.json (1 hunks)
  • frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • frameworks/mastra/dynamic-agents/.env.development
🚧 Files skipped from review as they are similar to previous changes (1)
  • frameworks/mastra/dynamic-agents/package.json
🧰 Additional context used
🧠 Learnings (32)
📚 Learning: 2025-07-17T13:38:58.657Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/Startup_News_Scraper/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:38:58.657Z
Learning: Applies to agents/Startup_News_Scraper/**/src/agents/**/index.ts : Prefer loading types from the node modules package `agentuity/sdk` in the node_modules folder

Applied to files:

  • frameworks/mastra/dynamic-agents/index.ts
📚 Learning: 2025-07-17T13:39:55.775Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/deep-research-js/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:39:55.775Z
Learning: Applies to agents/deep-research-js/**/src/agents/**/index.ts : The file should export a default function

Applied to files:

  • frameworks/mastra/dynamic-agents/index.ts
  • frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts
📚 Learning: 2025-07-17T13:39:37.133Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/composio/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:39:37.133Z
Learning: Applies to agents/composio/**/src/agents/**/index.ts : The file should export a default function

Applied to files:

  • frameworks/mastra/dynamic-agents/index.ts
  • frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts
📚 Learning: 2025-07-17T13:39:55.775Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/deep-research-js/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:39:55.775Z
Learning: Applies to agents/deep-research-js/**/src/agents/**/index.ts : All code should be in Typescript format

Applied to files:

  • frameworks/mastra/dynamic-agents/index.ts
📚 Learning: 2025-07-17T13:39:18.709Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/agent-riza/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:39:18.709Z
Learning: Applies to agents/agent-riza/**/src/agents/**/index.ts : The file should export a default function

Applied to files:

  • frameworks/mastra/dynamic-agents/index.ts
  • frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts
📚 Learning: 2025-07-17T13:40:05.817Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/deep-research-js/.cursor/rules/sdk.mdc:0-0
Timestamp: 2025-07-17T13:40:05.817Z
Learning: Applies to agents/deep-research-js/src/agents/**/*.ts : Use TypeScript for better type safety and IDE support

Applied to files:

  • frameworks/mastra/dynamic-agents/index.ts
📚 Learning: 2025-07-17T13:40:05.817Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/deep-research-js/.cursor/rules/sdk.mdc:0-0
Timestamp: 2025-07-17T13:40:05.817Z
Learning: Applies to agents/deep-research-js/src/agents/**/*.ts : Consider agent communication for complex workflows

Applied to files:

  • frameworks/mastra/dynamic-agents/index.ts
📚 Learning: 2025-07-17T13:40:37.445Z
Learnt from: CR
PR: agentuity/examples#0
File: agentuity/sdk-js/streaming/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:40:37.445Z
Learning: Applies to agentuity/sdk-js/streaming/**/src/agents/**/index.ts : The file should export a default function

Applied to files:

  • frameworks/mastra/dynamic-agents/index.ts
  • frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts
📚 Learning: 2025-07-17T13:40:05.817Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/deep-research-js/.cursor/rules/sdk.mdc:0-0
Timestamp: 2025-07-17T13:40:05.817Z
Learning: Applies to agents/deep-research-js/src/agents/**/*.ts : Import types from `agentuity/sdk`

Applied to files:

  • frameworks/mastra/dynamic-agents/index.ts
📚 Learning: 2025-07-17T13:39:55.775Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/deep-research-js/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:39:55.775Z
Learning: Applies to agents/deep-research-js/**/src/agents/**/index.ts : Prefer naming the default function Agent or the name of the Agent based on the context of the Agent description

Applied to files:

  • frameworks/mastra/dynamic-agents/index.ts
  • frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts
📚 Learning: 2025-07-17T13:39:44.988Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/composio/.cursor/rules/sdk.mdc:0-0
Timestamp: 2025-07-17T13:39:44.988Z
Learning: Applies to agents/composio/src/agents/**/*.ts : Use TypeScript for better type safety and IDE support

Applied to files:

  • frameworks/mastra/dynamic-agents/index.ts
📚 Learning: 2025-06-23T17:15:21.314Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/mastra/basic/.cursor/rules/sdk.mdc:0-0
Timestamp: 2025-06-23T17:15:21.314Z
Learning: For best practices in Agentuity SDK projects, use TypeScript for type safety, import types from agentuity/sdk, use structured error handling with try/catch, leverage the provided logger, use storage APIs for data persistence, and consider agent communication for complex workflows.

Applied to files:

  • frameworks/mastra/dynamic-agents/index.ts
📚 Learning: 2025-06-23T17:16:33.550Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/pydantic/basic/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-06-23T17:16:33.550Z
Learning: The agentuity.yaml file is a configuration file used by Agentuity to configure the AI Agent project and should not be edited or suggested for edits during code review.

Applied to files:

  • frameworks/mastra/dynamic-agents/agentuity.yaml
📚 Learning: 2025-06-23T17:16:16.519Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/openai/from-oai/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-06-23T17:16:16.519Z
Learning: The Agentuity configuration file (agentuity.yaml) is reserved for configuring the AI Agent project and should not be edited or suggested for edits during code review.

Applied to files:

  • frameworks/mastra/dynamic-agents/agentuity.yaml
📚 Learning: 2025-06-23T17:13:52.368Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/crewai/socialagent/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-06-23T17:13:52.368Z
Learning: The 'agentuity.yaml' file is a configuration file used by Agentuity to configure the AI Agent project and should not be edited or suggested for edits.

Applied to files:

  • frameworks/mastra/dynamic-agents/agentuity.yaml
📚 Learning: 2025-06-23T17:14:18.092Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/langchain/basic/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-06-23T17:14:18.092Z
Learning: The file 'agentuity.yaml' is used to configure the Agentuity AI Agent project and should not be edited or suggested for edits.

Applied to files:

  • frameworks/mastra/dynamic-agents/agentuity.yaml
📚 Learning: 2025-06-23T17:15:30.804Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/miscellaneous/grokLiveSearch/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-06-23T17:15:30.804Z
Learning: In the context of Agentuity AI projects, the 'agentuity.yaml' file is a configuration file that should not be edited or suggested for edits during code review.

Applied to files:

  • frameworks/mastra/dynamic-agents/agentuity.yaml
📚 Learning: 2025-06-23T17:15:46.735Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/miscellaneous/mem0/mem0demo/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-06-23T17:15:46.735Z
Learning: The Agentuity configuration file (agentuity.yaml) is used to configure the AI Agent project and should not be edited or suggested for edits.

Applied to files:

  • frameworks/mastra/dynamic-agents/agentuity.yaml
📚 Learning: 2025-06-23T17:17:12.992Z
Learnt from: CR
PR: agentuity/examples#0
File: patterns/llmAsJury/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-06-23T17:17:12.992Z
Learning: In the context of Agentuity AI projects, the agentuity.yaml file is a configuration file that should not be edited or suggested for edits during code review.

Applied to files:

  • frameworks/mastra/dynamic-agents/agentuity.yaml
📚 Learning: 2025-07-17T13:39:39.665Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/composio/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-07-17T13:39:39.665Z
Learning: Applies to agents/composio/**/agentuity.yaml : Do NOT suggest edits to the Agentuity AI Configuration file (agentuity.yaml)

Applied to files:

  • frameworks/mastra/dynamic-agents/agentuity.yaml
📚 Learning: 2025-06-23T17:16:02.063Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/openai/from-oai-typescript/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-06-23T17:16:02.063Z
Learning: The Agentuity AI Configuration file (agentuity.yaml) is used to configure the AI Agent project and should not be edited or suggested for edits.

Applied to files:

  • frameworks/mastra/dynamic-agents/agentuity.yaml
📚 Learning: 2025-07-17T13:41:01.314Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/agno/from_agno/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-07-17T13:41:01.314Z
Learning: Applies to frameworks/agno/from_agno/**/agentuity.yaml : Do not suggest edits to the Agentuity AI Configuration file (agentuity.yaml)

Applied to files:

  • frameworks/mastra/dynamic-agents/agentuity.yaml
📚 Learning: 2025-07-17T13:39:58.483Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/deep-research-js/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-07-17T13:39:58.483Z
Learning: Applies to agents/deep-research-js/**/agentuity.yaml : Do not suggest edits to the agentuity.yaml configuration file

Applied to files:

  • frameworks/mastra/dynamic-agents/agentuity.yaml
📚 Learning: 2025-06-23T17:14:39.393Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/langgraph/basic/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-06-23T17:14:39.393Z
Learning: In Agentuity AI Agent files (`**/src/agents/**/index.ts`), the default export should be an async function that handles the agent logic, typically accepting parameters `(req: AgentRequest, resp: AgentResponse, ctx: AgentContext)`.

Applied to files:

  • frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts
📚 Learning: 2025-07-17T13:40:37.445Z
Learnt from: CR
PR: agentuity/examples#0
File: agentuity/sdk-js/streaming/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:40:37.445Z
Learning: Applies to agentuity/sdk-js/streaming/**/src/agents/**/index.ts : Prefer naming the default function Agent or the name of the Agent based on the context of the Agent description

Applied to files:

  • frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts
📚 Learning: 2025-07-17T13:39:18.709Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/agent-riza/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:39:18.709Z
Learning: Applies to agents/agent-riza/**/src/agents/**/index.ts : Prefer naming the default function Agent or the name of the Agent based on the context of the Agent description

Applied to files:

  • frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts
📚 Learning: 2025-07-17T13:39:37.133Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/composio/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:39:37.133Z
Learning: Applies to agents/composio/**/src/agents/**/index.ts : Prefer naming the default function Agent or the name of the Agent based on the context of the Agent description

Applied to files:

  • frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts
📚 Learning: 2025-06-23T17:16:49.315Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/vercel/basic/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-06-23T17:16:49.315Z
Learning: When writing an Agent in TypeScript for Agentuity, always use the types provided by the `agentuity/sdk` package for AgentRequest, AgentResponse, and AgentContext to ensure type safety and compatibility.

Applied to files:

  • frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts
📚 Learning: 2025-06-23T17:14:46.802Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/langgraph/basic/.cursor/rules/sdk.mdc:0-0
Timestamp: 2025-06-23T17:14:46.802Z
Learning: The Agentuity JavaScript SDK provides core interfaces such as AgentHandler, AgentRequest, AgentResponse, and AgentContext for building AI agents in TypeScript or JavaScript.

Applied to files:

  • frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts
📚 Learning: 2025-06-23T17:17:19.027Z
Learnt from: CR
PR: agentuity/examples#0
File: patterns/llmAsJury/.cursor/rules/sdk.mdc:0-0
Timestamp: 2025-06-23T17:17:19.027Z
Learning: In the Agentuity JavaScript SDK, the main handler for an agent should implement the AgentHandler type: (request: AgentRequest, response: AgentResponse, context: AgentContext) => Promise<AgentResponseType>.

Applied to files:

  • frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts
📚 Learning: 2025-06-23T17:15:21.314Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/mastra/basic/.cursor/rules/sdk.mdc:0-0
Timestamp: 2025-06-23T17:15:21.314Z
Learning: In the Agentuity JavaScript SDK, the main handler for an agent should implement the AgentHandler type: a function that takes (request: AgentRequest, response: AgentResponse, context: AgentContext) and returns a Promise of AgentResponseType.

Applied to files:

  • frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts
📚 Learning: 2025-06-23T17:15:12.561Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/mastra/basic/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-06-23T17:15:12.561Z
Learning: In Agentuity AI Agent files (`**/src/agents/**/index.ts`), import types such as `AgentRequest`, `AgentResponse`, and `AgentContext` from the `agentuity/sdk` package to ensure type safety and consistency.

Applied to files:

  • frameworks/mastra/dynamic-agents/src/agents/mastra-dynamic-agent/index.ts
🔇 Additional comments (1)
frameworks/mastra/dynamic-agents/agentuity.yaml (1)

1-74: Config file looks good.

Acknowledging generated Agentuity config; no edit suggestions per repo guidelines.

Comment on lines +7 to +13
const cmd = process.env._ || '';
if (cmd.endsWith('node')) {
console.error(
'\x1b[31m[ERROR] Re-run the command with `node --env-file .env index.ts`\x1b[0m'
);
}
process.exit(1);
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

CLI hint suggests an invalid Node command for TypeScript.

node index.ts won’t run TS; advising this will mislead users. Point to agentuity dev or Bun entrypoint.

-  const cmd = process.env._ || '';
-  if (cmd.endsWith('node')) {
-    console.error(
-      '\x1b[31m[ERROR] Re-run the command with `node --env-file .env index.ts`\x1b[0m'
-    );
-  }
+  console.error(
+    '\x1b[31m[ERROR] Re-run with `agentuity dev` (recommended) or `bun run .agentuity/index.js`.\x1b[0m'
+  );
📝 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 cmd = process.env._ || '';
if (cmd.endsWith('node')) {
console.error(
'\x1b[31m[ERROR] Re-run the command with `node --env-file .env index.ts`\x1b[0m'
);
}
process.exit(1);
console.error(
'\x1b[31m[ERROR] Re-run with `agentuity dev` (recommended) or `bun run .agentuity/index.js`.\x1b[0m'
);
process.exit(1);
🤖 Prompt for AI Agents
In frameworks/mastra/dynamic-agents/index.ts lines 7 to 13, the CLI hint tells
users to re-run with "node index.ts" which is invalid for TypeScript; replace
that message to point users to the correct runtime entry (e.g., the agentuity
dev command or the Bun entrypoint) and update the error text to clearly instruct
them how to run the project in development (for example: use the agentuity dev
command or run the compiled JS/bun entrypoint), ensuring the message does not
reference running .ts files directly with node and keeping the existing exit
behavior.

Comment on lines +20 to +28
if (process.isBun) {
console.warn(
'\x1b[31m[WARN] Recommend running `agentuity dev` to run your project locally instead of bun run start.\x1b[0m'
);
} else {
console.warn(
'\x1b[31m[WARN] Recommend running `agentuity dev` to run your project locally instead of npm start.\x1b[0m'
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Avoid process.isBun (not typed in Node); detect Bun safely.

process.isBun isn’t a standard/typed Node property. Detect via globalThis.Bun.

-  if (process.isBun) {
+  const isBun = typeof (globalThis as any).Bun !== 'undefined';
+  if (isBun) {
     console.warn(
-      '\x1b[31m[WARN] Recommend running `agentuity dev` to run your project locally instead of bun run start.\x1b[0m'
+      '\x1b[33m[WARN] Recommend running `agentuity dev` to run your project locally instead of bun run start.\x1b[0m'
     );
   } else {
     console.warn(
-      '\x1b[31m[WARN] Recommend running `agentuity dev` to run your project locally instead of npm start.\x1b[0m'
+      '\x1b[33m[WARN] Recommend running `agentuity dev` to run your project locally instead of npm start.\x1b[0m'
     );
   }
📝 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 (process.isBun) {
console.warn(
'\x1b[31m[WARN] Recommend running `agentuity dev` to run your project locally instead of bun run start.\x1b[0m'
);
} else {
console.warn(
'\x1b[31m[WARN] Recommend running `agentuity dev` to run your project locally instead of npm start.\x1b[0m'
);
}
const isBun = typeof (globalThis as any).Bun !== 'undefined';
if (isBun) {
console.warn(
'\x1b[33m[WARN] Recommend running `agentuity dev` to run your project locally instead of bun run start.\x1b[0m'
);
} else {
console.warn(
'\x1b[33m[WARN] Recommend running `agentuity dev` to run your project locally instead of npm start.\x1b[0m'
);
}
🤖 Prompt for AI Agents
In frameworks/mastra/dynamic-agents/index.ts around lines 20–28, replace the
unsafe process.isBun check with a safe Bun detection using globalThis (e.g.
check typeof globalThis.Bun !== 'undefined' or 'Bun' in globalThis) so the code
works in Node without referencing an untyped process property; keep the existing
warning messages and branches identical, and if TypeScript complains, narrow the
check with a typeof guard or an any-cast around globalThis.Bun.

}
}

runner(true, import.meta.dirname).catch((err) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Make runner path resolution cross-runtime (Bun+Node) instead of Bun-only import.meta.dirname.

Node doesn’t support import.meta.dirname; this will crash outside Bun. Use fileURLToPath/dirname fallback.

-import { runner } from '@agentuity/sdk';
+import { runner } from '@agentuity/sdk';
+import { fileURLToPath } from 'node:url';
+import { dirname } from 'node:path';
@@
-runner(true, import.meta.dirname).catch((err) => {
+const __dir = (import.meta as any).dirname ?? dirname(fileURLToPath(import.meta.url));
+runner(true, __dir).catch((err) => {

Also applies to: 1-1

🤖 Prompt for AI Agents
In frameworks/mastra/dynamic-agents/index.ts around line 31, the code uses
Bun-only import.meta.dirname which will crash in Node; replace it with a
cross-runtime resolution by deriving the directory from import.meta.url using
URL/fileURLToPath and path.dirname as a fallback for environments without
import.meta.dirname (i.e., const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename)); then pass that __dirname value to runner
so both Bun and Node work.

@dhilanfye34 dhilanfye34 closed this Oct 7, 2025
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