Skip to content

feat: add Mastra memory integration example#548

Open
m1lestones wants to merge 2 commits intoplastic-labs:mainfrom
m1lestones:feat/mastra-memory-integration
Open

feat: add Mastra memory integration example#548
m1lestones wants to merge 2 commits intoplastic-labs:mainfrom
m1lestones:feat/mastra-memory-integration

Conversation

@m1lestones
Copy link
Copy Markdown

Summary

  • Adds examples/mastra/typescript/ — a full Honcho memory integration for Mastra agents
  • Uses new Agent({ instructions, tools }) with dynamic instructions built from Honcho context, and createTool() for memory recall
  • Follows the same pattern as the existing examples/openai-agents/ example

What's included

examples/mastra/
├── README.md
└── typescript/
    ├── main.ts
    ├── package.json
    ├── tsconfig.json
    └── tools/
        ├── client.ts
        ├── saveMemory.ts
        ├── getContext.ts
        └── queryMemory.ts   # makeQueryMemoryTool(ctx) → createTool()

How it works

  1. Dynamic instructionsbuildInstructions(ctx) fetches Honcho session history and passes it as the instructions string to new Agent() before every generate() call.
  2. Tool factorymakeQueryMemoryTool(ctx) returns a Mastra createTool() with a Zod schema, closing over the user context. execute calls Honcho's Dialectic API.
  3. Auto-savechat() persists the user message before agent.generate() and the assistant response after.

Test plan

  • Set HONCHO_API_KEY and OPENAI_API_KEY in typescript/.env
  • cd typescript && bun install && bun run main.ts
  • Tell the agent something about yourself, start a new session, then ask "What do you remember about me?"

🤖 Generated with Claude Code

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 10, 2026

Warning

Rate limit exceeded

@m1lestones has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 9 minutes and 16 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 9 minutes and 16 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: CHILL

Plan: Pro

Run ID: 5cfc1053-2a05-4c44-80f8-e19e1d484da8

📥 Commits

Reviewing files that changed from the base of the PR and between 5b6bd59 and a68654d.

📒 Files selected for processing (8)
  • examples/mastra/README.md
  • examples/mastra/typescript/main.ts
  • examples/mastra/typescript/package.json
  • examples/mastra/typescript/tools/client.ts
  • examples/mastra/typescript/tools/getContext.ts
  • examples/mastra/typescript/tools/queryMemory.ts
  • examples/mastra/typescript/tools/saveMemory.ts
  • examples/mastra/typescript/tsconfig.json
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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.

1 participant