-
Notifications
You must be signed in to change notification settings - Fork 5
Add Mastra system-prompt example wrapper #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
devin-ai-integration
wants to merge
1
commit into
main
from
devin/1756320605-mastra-system-prompt-wrapper
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,133 @@ | ||
| # Logs | ||
| logs | ||
| *.log | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| lerna-debug.log* | ||
| .pnpm-debug.log* | ||
|
|
||
| # Diagnostic reports (https://nodejs.org/api/report.html) | ||
| report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
|
||
| # Runtime data | ||
| pids | ||
| *.pid | ||
| *.seed | ||
| *.pid.lock | ||
|
|
||
| # Directory for instrumented libs generated by jscoverage/JSCover | ||
| lib-cov | ||
|
|
||
| # Coverage directory used by tools like istanbul | ||
| coverage | ||
| *.lcov | ||
|
|
||
| # nyc test coverage | ||
| .nyc_output | ||
|
|
||
| # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
| .grunt | ||
|
|
||
| # Bower dependency directory (https://bower.io/) | ||
| bower_components | ||
|
|
||
| # node-waf configuration | ||
| .lock-wscript | ||
|
|
||
| # Compiled binary addons (https://nodejs.org/api/addons.html) | ||
| build/Release | ||
|
|
||
| # Dependency directories | ||
| node_modules/ | ||
| jspm_packages/ | ||
|
|
||
| # Snowpack dependency directory (https://snowpack.dev/) | ||
| web_modules/ | ||
|
|
||
| # TypeScript cache | ||
| *.tsbuildinfo | ||
|
|
||
| # Optional npm cache directory | ||
| .npm | ||
|
|
||
| # Optional eslint cache | ||
| .eslintcache | ||
|
|
||
| # Optional stylelint cache | ||
| .stylelintcache | ||
|
|
||
| # Microbundle cache | ||
| .rpt2_cache/ | ||
| .rts2_cache_cjs/ | ||
| .rts2_cache_es/ | ||
| .rts2_cache_umd/ | ||
|
|
||
| # Optional REPL history | ||
| .node_repl_history | ||
|
|
||
| # Output of 'npm pack' | ||
| *.tgz | ||
|
|
||
| # Yarn Integrity file | ||
| .yarn-integrity | ||
|
|
||
| # dotenv environment variable files | ||
| .env | ||
| .env.development.local | ||
| .env.test.local | ||
| .env.production.local | ||
| .env.local | ||
|
|
||
| # parcel-bundler cache (https://parceljs.org/) | ||
| .cache | ||
| .parcel-cache | ||
|
|
||
| # Next.js build output | ||
| .next | ||
| out | ||
|
|
||
| # Nuxt.js build / generate output | ||
| .nuxt | ||
| dist | ||
|
|
||
| # Gatsby files | ||
| .cache/ | ||
| # Comment in the public line in if your project uses Gatsby and not Next.js | ||
| # https://nextjs.org/blog/next-9-1#public-directory-support | ||
| # public | ||
|
|
||
| # vuepress build output | ||
| .vuepress/dist | ||
|
|
||
| # vuepress v2.x temp and cache directory | ||
| .temp | ||
| .cache | ||
|
|
||
| # Docusaurus cache and generated files | ||
| .docusaurus | ||
|
|
||
| # Serverless directories | ||
| .serverless/ | ||
|
|
||
| # FuseBox cache | ||
| .fusebox/ | ||
|
|
||
| # DynamoDB Local files | ||
| .dynamodb/ | ||
|
|
||
| # TernJS port file | ||
| .tern-port | ||
|
|
||
| # Stores VSCode versions used for testing VSCode extensions | ||
| .vscode-test | ||
|
|
||
| # yarn v2 | ||
| .yarn/cache | ||
| .yarn/unplugged | ||
| .yarn/build-state.yml | ||
| .yarn/install-state.gz | ||
| .pnp.* | ||
|
|
||
| # Agentuity | ||
| .agentuity/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # Mastra System Prompt Example - Agentuity Wrapper | ||
|
|
||
| This example demonstrates how to wrap a Mastra agent that uses system prompts within Agentuity's structure. The agent implements a Harry Potter character agent that can respond as different characters from the wizarding world. | ||
|
|
||
| ## Overview | ||
|
|
||
| This is a direct conversion of the [Mastra system-prompt example](https://mastra.ai/en/examples/agents/system-prompt) into an Agentuity agent wrapper. The implementation preserves ALL original Mastra framework code while adding Agentuity's wrapper structure. | ||
|
|
||
| ## Features | ||
|
|
||
| - **Character-based responses**: The agent can respond as Harry Potter, Hermione Granger, or Ron Weasley | ||
| - **System prompt demonstration**: Shows how Mastra's system prompts can change agent behavior | ||
| - **Preserved framework code**: All original Mastra Agent creation and configuration is maintained | ||
| - **Agentuity integration**: Proper error handling, logging, and response formatting | ||
|
|
||
| ## How it Works | ||
|
|
||
| The agent uses Mastra's `Agent` class with system prompts to define character personalities and response styles. When a user makes a request, the agent: | ||
|
|
||
| 1. Receives input through Agentuity's `AgentRequest` | ||
| 2. Creates a Mastra `Agent` with character-specific instructions | ||
| 3. Generates a response using the original Mastra framework | ||
| 4. Returns the result through Agentuity's `AgentResponse` | ||
|
|
||
| ## Usage Examples | ||
|
|
||
| - "Speak as Harry Potter and tell me about your first day at Hogwarts" | ||
| - "Respond as Hermione and explain the importance of studying" | ||
| - "Answer as Ron and describe your favorite Quidditch match" | ||
|
|
||
| ## Framework Preservation | ||
|
|
||
| This wrapper maintains the original Mastra framework patterns: | ||
|
|
||
| - Uses `@mastra/core/agent` for agent creation | ||
| - Preserves the original `Agent` constructor with `name`, `model`, and `instructions` | ||
| - Keeps the original `agent.generate()` method call | ||
| - Maintains all Mastra-specific configuration and behavior | ||
|
|
||
| ## Development | ||
|
|
||
| ```bash | ||
| # Install dependencies | ||
| bun install | ||
|
|
||
| # Run locally | ||
| agentuity dev | ||
|
|
||
| # Build | ||
| agentuity build | ||
|
|
||
| # Lint | ||
| bun run lint | ||
|
|
||
| # Format | ||
| bun run format | ||
| ``` | ||
|
|
||
| ## Dependencies | ||
|
|
||
| - `@mastra/core`: Core Mastra framework | ||
| - `@ai-sdk/anthropic`: Anthropic AI SDK for Claude models | ||
| - `@agentuity/sdk`: Agentuity SDK for wrapper functionality | ||
|
|
||
| This example demonstrates the proper way to wrap existing framework agents in Agentuity structure without modifying the original framework code. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| # yaml-language-server: $schema=https://raw.githubusercontent.com/agentuity/cli/refs/heads/main/agentuity.schema.json | ||
|
|
||
| # ------------------------------------------------ | ||
| # This file is generated by Agentuity | ||
| # You should check this file into version control | ||
| # ------------------------------------------------ | ||
|
|
||
| # The version semver range required to run this project | ||
| version: '>=0.0.130' | ||
| # The ID of the project which is automatically generated | ||
| project_id: proj_mastra_system_prompt_example | ||
| # The name of the project which is editable | ||
| name: mastra-system-prompt | ||
| # The description of the project which is editable | ||
| description: "A Harry Potter character agent demonstrating Mastra's system prompt capabilities wrapped in Agentuity structure." | ||
| # The development configuration for the project | ||
| development: | ||
| # The port to run the development server on which can be overridden by setting the PORT environment variable | ||
| port: 3501 | ||
| watch: | ||
| # Whether to watch for changes and automatically restart the server | ||
| enabled: true | ||
| # Rules for files to watch for changes | ||
| files: | ||
| - src/** | ||
| # The command to run the development server | ||
| command: bun | ||
| # The arguments to pass to the development server | ||
| args: | ||
| - run | ||
| - --silent | ||
| - .agentuity/index.js | ||
| deployment: | ||
| command: bun | ||
| args: | ||
| - run | ||
| - --no-install | ||
| - --prefer-offline | ||
| - --silent | ||
| - --no-macros | ||
| - --no-global-search-paths | ||
| - --report-uncaught-exception | ||
| - --disable-sigusr1 | ||
| - --disallow-code-generation-from-strings | ||
| - --no-addons | ||
| - --no-deprecation | ||
| - .agentuity/index.js | ||
| # You should tune the resources for the deployment | ||
| resources: | ||
| # The memory requirements | ||
| memory: 250Mi | ||
| # The CPU requirements | ||
| cpu: 500M | ||
| # The disk size requirements | ||
| disk: 100Mi | ||
| # You should not need to change these value | ||
| bundler: | ||
| enabled: true | ||
| identifier: bunjs | ||
| language: javascript | ||
| runtime: bunjs | ||
| agents: | ||
| dir: src/agents | ||
| ignore: | ||
| - node_modules/** | ||
| - dist/** | ||
| - src/** | ||
| # The agents that are part of this project | ||
| agents: | ||
| - # The ID of the Agent which is automatically generated | ||
| id: agent_harry_potter_system_prompt | ||
| # The name of the Agent which is editable | ||
| name: HarryPotterAgent |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| { | ||
| "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json", | ||
| "vcs": { | ||
| "enabled": false, | ||
| "clientKind": "git", | ||
| "useIgnoreFile": false | ||
| }, | ||
| "files": { | ||
| "ignoreUnknown": false, | ||
| "ignore": [] | ||
| }, | ||
| "formatter": { | ||
| "enabled": true, | ||
| "indentStyle": "space" | ||
| }, | ||
| "organizeImports": { | ||
| "enabled": true | ||
| }, | ||
| "linter": { | ||
| "enabled": true, | ||
| "rules": { | ||
| "recommended": false, | ||
| "correctness": { | ||
| "noUnusedVariables": "error" | ||
| }, | ||
| "style": { | ||
| "useImportType": "error" | ||
| }, | ||
| "suspicious": { | ||
| "noExplicitAny": "error" | ||
| } | ||
| } | ||
| }, | ||
| "javascript": { | ||
| "formatter": { | ||
| "quoteStyle": "single" | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Biome isn’t honoring .gitignore; add VCS ignores or explicit ignores to avoid linting .agentuity output.
With
vcs.enabled: falseanduseIgnoreFile: false, Biome will not respect.gitignore. Onceagentuity bundlecreates.agentuity/,biome lint .may scan it and produce noise. Recommend enabling VCS ignores or explicitly ignoring build artifacts (at least.agentuity,dist,coverage).Apply:
"vcs": { - "enabled": false, + "enabled": true, "clientKind": "git", - "useIgnoreFile": false + "useIgnoreFile": true }, "files": { "ignoreUnknown": false, - "ignore": [] + "ignore": [".agentuity", "dist", "coverage"] },📝 Committable suggestion
🤖 Prompt for AI Agents