from Hacker News

Show HN: Mastra – Open-source JS agent framework, by the developers of Gatsby

by calcsam on 2/19/25, 3:25 PM with 154 comments

Hi HN, we’re Sam, Shane, and Abhi, and we’re building Mastra (https://mastra.ai), an open-source JavaScript SDK for building agents on top of Vercel’s AI SDK.

You can start a Mastra project with `npm create mastra` and create workflow graphs that can suspend/resume, build a RAG pipeline and write evals, give agents memory, create multi-agent workflows, and view it all in a local playground.

Previously, we built Gatsby, the open-source React web framework. Later, we worked on an AI-powered CRM but it felt like we were having to roll all the AI bits (agentic workflows, evals, RAG) ourselves. We also noticed our friends building AI applications suffering from long iteration cycles: they were getting stuck debugging prompts, figuring out why their agents called (or didn’t call) tools, and writing lots of custom memory retrieval logic.

At some point we just looked at each other and were like, why aren't we trying to make this part easier, and decided to work on Mastra.

Demo video: https://www.youtube.com/watch?v=8o_Ejbcw5s8

One thing we heard from folks is that seeing input/output of every step, of every run of every workflow, is very useful. So we took XState and built a workflow graph primitive on top with OTel tracing. We wrote the APIs to make control flow explicit: `.step()` for branching, `.then()` for chaining, and `.after()` for merging. We also added .`.suspend()/.resume()` for human-in-the-loop.

We abstracted the main RAG verbs like `.chunk()`, `embed()`, `.upsert(),’ `.query()`, and `rerank()` across document types and vector DBs. We shipped an eval runner with evals like completeness and relevance, plus the ability to write your own.

Then we read the MemGPT paper and implemented agent memory on top of AI SDK with a `lastMessages` key, `topK` retrieval, and a `messageRange` for surrounding context (think `grep -C`).

But we still weren’t sure whether our agents were behaving as expected, so we built a local dev playground that lets you curl agents/workflows, chat with agents, view evals and traces across runs, and iterate on prompts with an assistant. The playground uses a local storage layer powered by libsql (thanks Turso team!) and runs on localhost with `npm run dev` (no Docker).

Mastra agents originally ran inside a Next.js app. But we noticed that AI teams’ development was increasingly decoupled from the rest of their organization, so we built Mastra so that you can also run it as a standalone endpoint or service.

Some things people have been building so far: one user automates support for an iOS app he owns with tens of thousands of paying users. Another bundled Mastra inside an Electron app that ingests aerospace PDFs and outputs CAD diagrams. Another is building WhatsApp bots that let you chat with objects like your house.

We did (for now) adopt an Elastic v2 license. The agent space is pretty new, and we wanted to let users do whatever they want with Mastra but prevent, eg, AWS from grabbing it.

If you want to get started: - On npm: npm create mastra@latest - Github repo: https://github.com/mastra-ai/mastra - Demo video: https://www.youtube.com/watch?v=8o_Ejbcw5s8 - Our website homepage: https://mastra.ai (includes some nice diagrams and code samples on agents, RAG, and links to examples) - And our docs: https://mastra.ai/docs

Excited to share Mastra with everyone here – let us know what you think!

  • by Palmik on 2/20/25, 5:47 AM

    The example from the landing page does not exactly spark joy:

        testWorkflow
         .step(llm)
           .then(decider)
           .then(agentOne)
           .then(workflow)
         .after(decider)
           .then(agentTwo)
           .then(workflow)
          .commit();
    
    
    On a first glance, this looks like a very awkward way to represent the graph from the picture. And this is just a simple "workflow" (the structure of the graph does not depend on the results of the execution), not an agent.
  • by kylemathews on 2/19/25, 6:46 PM

    Very excited about Mastra! We have a number of Agent-ic things we'll be building at ElectricSQL and Mastra looks like a breath of fresh air.

    Also the team is top-notch — Sam was my co-founder at Gatsby and I worked closely with Shane and Abhi and I have a ton of confidence in their product & engineering abilities.

  • by joshstrange on 2/19/25, 6:55 PM

    This looks awesome! Quick question, are there plans to support SSE MCP servers? I see Stdio [0] are supported and I can always run a proxy but SSE would be awesome.

    [0] https://mastra.ai/docs/reference/tools/client

  • by alanwells on 2/19/25, 8:32 PM

    Happy Mastra user here! Strikes the right balance between letting me build with higher level abstractions but providing lower level controls when needed. I looked at a handful of other frameworks before getting started and the clarity & easy of use of Mastra stood out. Nice work.
  • by brap on 2/19/25, 7:19 PM

    I don’t really understand agents. I just don’t get why we need to pretend we have multiple personalities, especially when they’re all using the same model.

    Can anyone please give me a usecase, that couldn’t be solved with a single API call to a modern LLM (capable of multi-step planning/reasoning) and a proper prompt?

    Or is this really just about building the prompt, and giving the LLM closer guidance by splitting into multiple calls?

    I’m specifically not asking about function calling.

  • by Gakho on 2/19/25, 5:56 PM

    Congrats on launching. I've noticed that switching prompts without edits between different LLM providers has degradation on performance. I'm wondering if you guys have noticed how developers do these "translations", I'm wondering since maybe your eval framework might have data for best practices.
  • by epolanski on 2/19/25, 6:59 PM

    By the developers of Gatsby is a minus, not a plus makes me think this is going to be the next abandonware.
  • by _pdp_ on 2/19/25, 10:13 PM

    I don't want to be that person but there are hundreds of other similar frameworks doing more or less the same thing. Do you know why? Because writing a framework that orchestrates a number of tools with a model is the easy part. In fact, most of the time you don't even need a framework. All of these framework focus on the trivial and you can tell that simply by browsing the examples section.

    This is like 5% of the work. The developer needs to fill the other 95% which involves a lot more things that are strictly outside of scope of the framework.

  • by harliem on 2/19/25, 6:01 PM

    Impressive. Have you seen any success with Mastra being used to build voice agents? Our company has been experimenting with VAPI, which just launched a workflow builder into open beta (https://docs.vapi.ai/workflows), but it has a lot of rough edges.
  • by eliotthehacker on 2/19/25, 8:49 PM

    I basically learned everything about how agents work by using Mastra's framework and going through their documentation. The founders are also super hands-on and love to help!
  • by aranibatta on 2/19/25, 3:58 PM

    Congrats on launching! Curious how early the Mastra team thinks people should be thinking about evals and setting up a pipeline for them.
  • by netcraft on 2/19/25, 8:03 PM

    This looks really great! How do you make money? Do you charge for deploying these to your platform? I couldnt find anything on pricing
  • by monideas on 2/19/25, 7:30 PM

    Are there any plans to add automatic retries for individual steps (with configurable max attempts and backoff strategy)?
  • by davedx on 2/19/25, 7:39 PM

    Why is it on top of Vercel’s platform?
  • by PetrBrzyBrzek on 2/20/25, 7:29 AM

    I created a similar library for orchestrations, but it’s more explicit and lightweight. https://github.com/langtail/ai-orchestra
  • by lmrl on 2/20/25, 7:09 AM

    Congrats, looks promising! 1. Is it possible to create custom endpoints? I see that several endpoints are created when running “mastra dev”.

    2. Related to previous question, since this is node based, is it possible to support websockets?

  • by orliesaurus on 2/20/25, 5:02 AM

    Does Mastra support libraries of tools for agents like toolhouse.ai or https://github.com/transitive-bullshit/agentic
  • by dstroot on 2/20/25, 7:39 PM

    Congrats! Side question - is the website OS as well? I'd like to "borrow" the Nav Bar code. I looked on GitHub and couldn't find it in the repos and 300+ branches. Cheers!
  • by dhorthy on 2/19/25, 8:57 PM

    i am very long on TS as the future of agent applications. nice work team
  • by _1 on 2/19/25, 6:35 PM

    This looks really nice. We've been considering developing something very similar in-house. Are you guys looking at supporting MLC Web LLM, or someother local models?
  • by realmikebernico on 2/19/25, 5:57 PM

    Congrats! This is exactly what the AI world needs. I'm thinking about using Mastra for a class I'm working on with AI Agents.
  • by 5Qn8mNbc2FNCiVV on 2/19/25, 5:58 PM

    I thought Kyle Matthews was the creator of Gatsby
  • by fnikacevic on 2/19/25, 10:20 PM

    Do the workflows support voice-to-voice models like openai's realtime? Or if something like that exists I'd be curios.
  • by cshimmin on 2/20/25, 7:45 AM

    Interested to learn more about the PDF -> CAD project built on mastra, can you share a link?
  • by tobyhinloopen on 2/20/25, 7:51 AM

    Neat, I’m going to use this
  • by dikaio on 2/20/25, 5:42 PM

    Got excited, was hoping to see a repository of Go Agents.
  • by levensti on 2/19/25, 6:22 PM

    Super excited to try out the new agent memory features
  • by asati on 2/20/25, 12:19 AM

    Congrats guys! really excited to try this out!
  • by albertmz on 2/22/25, 1:05 AM

    Kudos on using XState!
  • by gregpr07 on 2/19/25, 7:03 PM

    Any timeline for python?
  • by fuddle on 2/19/25, 7:20 PM

    "You may not provide the software to third parties as a hosted or managed service" - The Elastic v2 license isn't actually open source like your title mentions: "Open-source JS agent framework"

    https://github.com/mastra-ai/mastra/blob/main/LICENSE

  • by delduca on 2/19/25, 11:14 PM

    > Mastra uses the Vercel AI SDK

    It started off wrong.

  • by jobryan on 2/19/25, 5:49 PM

    Bamfs
  • by pablodecm on 2/19/25, 8:08 PM

    Very interesting set of abstractions that address lots of the pain points when building agents, also the team is super eager to help out!
  • by yovboy on 2/19/25, 5:47 PM

    You’re awesome guys! I had so many problems with lanchain and am very happy since switching to Mastra
  • by bobremeika on 2/19/25, 5:40 PM

    A TypeScript first AI framework is something that has been missing. How do you work with AI SDK?