In short
Podcast Episode Notes: Building AI Agents on the Frontend with Sam Bhagwat and Abhi Aiyer
Overview Podcast: Software Engineering Daily Episode: Building AI Agents on the Frontend Guests: Sam Bhagwat and Abhi Aiyer, co-founders of Mastra Host: Nick Nisi
Episode Description The episode discusses challenges faced by frontend developers in integrating AI agents, predominantly built on backend frameworks, which are primarily written in Python. The episode introduces Mastra, an open-source TypeScript framework designed to streamline the process of building AI agents directly within JavaScript/TypeScript environments.
---
Key Concepts Discussed
Current State of AI Agent Frameworks
- Backend-focused Frameworks: Most existing AI frameworks are backend-centric and primarily utilize Python, complicating the development process for JavaScript/TypeScript frontend applications.
- Need for Frontend Solutions: This gap poses challenges for frontend developers in prototyping, integrating, and iterating AI features.
Introduction to Mastra
- TypeScript Framework: Mastra is an open-source framework that provides necessary primitives such as agents, tools, workflows, and retrieval-augmented generation (RAG).
- Focus on Accessibility: Aimed at making AI agent development more approachable for developers familiar with TypeScript.
---
Key Participants
- Sam Bhagwat: Co-founder and CEO of Mastra, known for previous work at Gatsby.
- Abhi Aiyer: CTO and co-founder of Mastra, also with a background at Gatsby and Netlify.
- Nick Nisi: Host and developer experience engineer at WorkOS.
---
Discussion Highlights
Founders' Journey
- Origins of Mastra: The creation stemmed from frustrations while building a CRM, where existing AI libraries did not meet their needs.
- Timing: They pivoted from their CRM project to Mastra in October 2024 after realizing the lack of adequate TypeScript libraries for AI development.
Primitives of Mastra
- Agents: Defined as a box of compute and intelligence that can execute workflows, manage memory, and call tools.
- Workflows and Tools: Framework design allows for composing different primitives (agents, tools, workflows) to create complex AI functionalities.
- Learning Mechanisms: Users can learn about AI engineering through Mastra's primitives, which serve both as a development tool and an educational resource.
Development and Community Engagement
- Documentation: Emphasis on high-quality documentation, with efforts to integrate educational tools directly into the development environment.
- Community Workshops: Regular workshops and live streams are held to engage the community and provide educational resources.
---
Technical Insights
Differences Between Agents and Traditional LLMs
- Understanding Agents: Agents are more than just prompt-based interactions; they embody a loop of feedback and can execute workflows autonomously.
- Agentic Spectrum: The concept of agency varies, ranging from simple LLM calls to complex interactions involving multiple tools and workflows.
Use Cases and Applications
- Examples include generating CAD diagrams in aerospace and automating task management for veterinarians.
- The potential to build diverse applications (e.g., personal email managers, educational tools) using Mastra's framework.
Future Directions and Roadmap
- Iterative Development: The team is focused on refining core primitives and exploring new features like agent memory, event-based execution, and support for multimodal inputs (text, images, voice).
- Community-Driven Growth: The evolution of Mastra is heavily influenced by community feedback and contributions.
---
Final Takeaways
- Encouragement for New Developers: The founders encourage immersion in the technology, advocating for building small projects to grasp the underlying concepts.
- Continuous Learning: Emphasizing the importance of staying humble and continually learning in the rapidly evolving landscape of AI technology.
---
Resources
- Mastra Documentation: [Mastra Documentation](https://mastra.ai/docs)
- Principles of Building AI Agents Book: Available through [Mastra's website](https://mastra.ai/book).
- Community Engagement: Join the [Mastra Discord](https://mastra.ai/community) and participate in workshops.
---
This episode of Software Engineering Daily provides valuable insights into the development of AI agents on frontend technologies, emphasizing the innovative approach taken by Mastra to address existing gaps in the ecosystem.
Written by AI. May contain mistakes. Listen to the episode to check what was said.
Transcript
Automatic transcript. May contain errors.0:00Most AI agent frameworks are back-end focused and written in Python, which introduces complexity when building full-stack AI applications with JavaScript or TypeScript frontends. This gap makes it harder for frontend developers to prototype, integrate, and iterate on AI-powered features. Mostra is an open-source TypeScript framework focused on building AI agents and has primitives such as agents, tools, workflows, and RAG. Sam Bhagwat and Abhi Ayer are co-founders at Mostra. They join the podcast with Nick Nisi to talk about this state of front-end tooling for AI agents, AI agent primitives, MCP integration, and more.
0:43Nick Nisi is a conference organizer, speaker, and developer focused on tools across the web ecosystem. He has organized and emceed several conferences and has led Nebraska JS for more than a decade. Nick currently works as a developer experience engineer at WorkOS.
1:13Welcome to Software Engineering Daily. Today's episode features the founders of Mastra, and I'd like to welcome to the show Sam Bagwat and Abhi Ayer. How's it going, guys? Hey, great to be here. Great to have you. Sam, why don't you go first and introduce yourself? So probably I'm best known for being the co-founder of Gatsby. And I worked at a few startups around the Valley before that as an engineer. But I'm also the author of a book called Principles of Building AI Agents. And now the co-founder and CEO of Mastra. Nice. Well, welcome to the show. Happy to have you. And I've definitely heard of Gatsby.
1:52Abbie, why don't you introduce yourself? Oh, yeah. I'm Avi Iyer. I'm the CTO and co-founder of Mastra. We also have a third co-founder. He's not here. His name's Shane. Just wanted to pour one out for him. Yeah, and I used to work at Gatsby as well very early on. And that's how Sam and I met. And then I also worked at Netlify because we got acquired by them. I'm sure we'll get into that. But that's how I got here. Nice. So, yeah, just digging right in. How did you come together on Mastra? Was it something that was born out of something that you worked on Gatsby? or yeah, I'm just curious how it got started.
2:26Probably the best way of saying it is that it was born out of frustration. So after Gatsby and sort of like we left Netlify at various points, but we were working in building a CRM and we kind of thought that like, we thought we did a lot of fun building dev tools and we're going to build something new. But it actually turned out that as we were building the AI parts of that CRM, which we called Kepler, and we were building this CRM for three of us together for about like nine months or so. We started using, building the AI parts of Kepler and using the kind of TypeScript AI libraries that were available at the time.
3:02And it just didn't feel like any of them were up to snuff. Yeah. Yeah. We were pretty exhausted from doing dev tools for so long. So we thought like a CRM game would be a great place for us, which we slowly realized that it probably wasn't. What timeframe is this? Like around what year? This was in October of last year. So October of 2024, when we kind of decided to pull the plug on the CRM and start building Master instead. Nice. Okay. So AI has been around for a while, like in its current form, chat GPT and all of that. And the rise of agents is coming. And one thing that's very notable, and we should talk about what Master actually is, but before we get to that, like it's written in TypeScript, which a lot of AI tooling right now is written in Python.
3:48So what was your drive to buck that trend and go with TypeScript? I think originally it was just super self-serving because we were trying to build AI features into our product that we were building. And we were all TypeScript engineers and very much in this industry and community for so long. And the minute that you also maybe we're dev tool snobs a little bit, but we did give things a fair shot. And the fair shot meaning like we actually tried to implement other people's libraries and there was a point where you were like, anytime you, as a DevTools person, you think like, I'm just going to go fetch from OpenAI directly and just do this stuff myself.
4:27And then the amount of people like us telling us the same thing, it was just like a natural thing. Like we had to do this and it has to be in TypeScript because that's what we, the whole point of what we were trying to do in the first place. Nice, yeah. Being in TypeScript was a major appeal to me just looking into it and getting started and playing around with it because it was one less, thing that I had to be a complete novice at, which all of the agent stuff, you know, when I was getting started was complete, don't know what I'm doing. And if I threw another language on top of that, then I really wouldn't know what I was doing, but it kind of helped to ground me a little bit and get going.
5:00So from there, let's talk about what Master actually is. How would you describe it? So Master is a TypeScript framework for building AI agents. And that means we have all of the primitives that you need, whether that's sort of an agent, like running in a loop, whether that's like a workflow graph, whether that's sort of evals and tracing, memory, tool calling, rag, a local dev playground. You can build kind of an agentic feature into your SaaS app. You could build a whole new agent from scratch that's like aimed at a specific industry or pain point. You could do sort of like internal automation of various types of workflows with LLMs and building like tooling to do that within your organization.
5:41We've seen folks build all sorts of interesting, fun use cases, whether that's like a personal email manager, like someone, our Japanese community sort of built some anime generation, like an anime sort of like writing and analysis. It's been neat to see what they were doing there. When we first started building the framework, we only had a couple of primitives. And we realized that there's just so many things that you have to understand when you're doing quote unquote AI engineering. And so we may have started Monstra with two primitives, tools and agents, and that was cool. Then we slowly realized, oh, there's this RAG thing.
6:17Oh, people need workflows. And then the number of primitives grew, but they had to be in a very sensible way. And then we learned that a lot of people were learning AI engineering through Monstra's primitives because we're essentially self-documenting and educating people what exists. Yeah, definitely. I definitely fall into that camp of learning what all of these tools are and primitives through what master provides and like why I would use that. And I will say for the longest time, like when I was getting started with it, I just couldn't for some reason wrap my head around what the heck an agent actually is.
6:54Could you give a description of like, in your words, what an agent is? I was at a panel where they asked the same question. So I want to give the same answer, which was mine was very stupid and poetic. Right. And everyone on the panel had a different answer. But I think the thing that we're trying to do at Mastra is to make like this new wave of agents, which is a loaded term, which is just like a box of compute and intelligence, right? But he put it down. So like an agent has a lot of things that defines intelligence, like an agent can speak, it can execute workflows, which are like for a human, maybe a playbook, or might be muscle memory, You have memories as humans, so do agents.
7:36So we're trying to reflect the human intelligence through our primitives. And I think that's what really an agent is, allows you to do all that stuff. But the other people in the panel, they're like, oh, it's just a loop. So it is a very loaded term. Great. So the confusion that I had was like, how is an agent different from just like chat GPT, like a prompt? Is it just like a chat tool with some fancy prompt on the beginning of it? Is that like how it gets started? And when you're talking about the loop, is it that where I ask a question or give it some text, it responds, and then we go back and forth and that's the loop?
8:13Yeah, see, this is where it gets super loaded. Because some people could define an agent as one LLM call that maybe has tools on it. And in that case, if you're using ChatGPT, ChatGPT has internal tools that it calls because you don't really expose your own tools there. So then you could say that interaction is an agentic interaction. I think it gets more agentic when there are multiple turns that are happening in one request. So for example, I ask it to do something with unstructured data, right? I'm using just a prompt. And then now there's a reasoning section that happens to happen of like, what do I need to do, execute?
8:52And then also what do I need to return? Which then may cause other type of interactions or other requests that need to happen. So yeah, I think it's very much in a spectrum. And that's kind of how we think of it here. It's like agentic is a spectrum. It could start as just like LLM calls. It could progress into structured workflows where you are the puppet master and you're calling all the LLMs, but the steps themselves are who knows what's going to happen, right? Because it's agentic. Then you get into this middle ground where you have maybe a single agent that does a bunch of things and orchestrate stuff by using its LLM and its tools.
9:32And then finally, you get like the AGI thing that they sold us a year ago, which is you can just do unstructured thing to a network of agentic components. And magically, all this stuff will just happen and the world will become a better place. So it's totally a spectrum. Yeah, I love that. And I think like, if you're doing code execution, let's say, and then you're like sending the feedback and the error states back into the agent, right? That's like higher on the agency spectrum. There are things that you can score it something higher, the more of these like advanced elements it has. And so all of those other pieces, like the workflows, the tooling and all of that, how does that play into, like does everything start with an agent and then it kind of goes into those from there in Mastra specifically?
10:16I would sort of see them sort of like put it that like you have these different primitives that you would kind of compose in interesting ways. So for example, agents by themselves have to decide which tool to choose. And so for example, agents aren't very good if you give them more than let's say eight to 10 different tools, even if you write really good tool descriptions. And so for example, maybe you could group the tools that you're giving an agent into two different categories and like wrap them into maybe two workflows. So you could have an agent that's calling workflows. You could also have like a workflow that's sort of doing an agent handoff where sort Sort of like one agent candles, perhaps asking the user for some requirements.
10:56And then like we hand it off to like another agent that's doing code generation. So it's sort of like see them both as like within Monstra, how it works is that like they are these separate primitives and then you can compose them in any way you want. And I think that's really like the power. Well, it's two things. It's the power of AI engineering in general is having these different kind of primitives you can compose in interesting ways. But it's also the power of Monstra as a framework. When you say composing them, is that what workflows are? Like composing all of these tools together? Or how does that work?
11:27Yeah, so for composing them, like all the primitives in Monstro. So we'll start with agent, for example. And agent can have tools. It could also have workflows that get executed as well. And essentially those get executed as another tool that it has in its arsenal, right? From the reverse perspective, a workflow, you can start with a workflow. and for a step of a workflow, you can pass it an agent or you could pass it a tool, right? Because now like these steps are, you're in control. So now like from that perspective, you're in control, you're doing a very deterministic thing. I mean, our workflows do have control flow and branching, et cetera, that you need, but the steps themselves are leveraging the agent primitive.
12:11And if you really want to just YOLO it, we have a primitive called agent network where you pass all the primitives in there and then you just pray. And then that's kind of what happens. So all of that is to try and bring some determinism to the task that an agent is trying to do? Yeah, so the reason why we kind of came up with workflows in the first place as an important primitive is that at the time especially, and even now, the models aren't good enough to just execute complex workflows. And a lot of the times, the engineers that we're talking to to pretty much extract all these features out from when we're talking to them, they actually know what they want to do so why do they need to prompt anything you just write some code like just because you could use a llm doesn't mean you have to then we learned like it's what they're executing at the points of the graph that they know that they're going to it's that during the execution is where they want to do like llm calls or anything like that beginning our workflow system was super trash too because we didn't really think it was that important And Sam, remember, we almost didn't want to do it at all.
13:16Yeah, we debated that. And we're like, well, maybe you should just use Injust or Temporal or another kind of workflow engine. But one of the reasons we decided to build our own was that we saw that in AI engineering, like having this kind of workflow primitive that has tracing built in, that has like a development environment where you can test it and replay it, is kind of relatively more important because you're wrapping these non-deterministic agents, these non-deterministic LLMs. And being able to just kind of observe what's going on at every step is really important because usually like in software engineering, if something is returning different output, depending on, hey, if I ran my CI at 11 PM versus 3 PM and I had some like time zone issue that only came up, if UTC is different than PST or whatever, right?
14:01Like we call it like non-deterministic and we say that's a bug. But in AI engineering, it's actually just part of the game because you're working with these LLMs that are inherently non-deterministic. And so you have to add all these like guardrails around them to get them to, they're very powerful, obviously. We all know they're very powerful, but you kind of have to add these guardrails around them to get them to behave properly. And the idea that we have in Mastra of the structured workflow graph in this primitive that we have is one way that we do that. So let's take a step back and help to paint a picture of when someone might reach for Mastra or reach for creating their own like agent workflow.
14:37Maybe start with an example of a great idea that you've seen or a great intro into this that you've seen as people adopt Mastro. Sure. Yeah. So I'll give like an example of a company that we know very well. They're building something to generate CAD diagrams for like they're working in the aerospace industry and they're ingesting these like 100 page long PDFs of part manuals and stuff. And then you need to kind of like link these things up in some sort of electrical circuit, depending on the capacity and the wattage and the voltage and all this kind of stuff. and you can kind of ingest some of the stuff from the manual.
15:10But this is obviously like, it is kind of a task that you need to extract a bunch of information, feed it into like an LLM in a creative way and feed the right amount of context. And so they're sort of using Mastra to wrap a bunch of these pieces and components in order to do that. So that's like a fun example where like, hey, it's like LLMs in sort of like a novel industry. Another one that comes to mind, there's another company that's using it, Mastra. They're sort of making software for veterinarians. So if the veterinarian is going and looking at your dog, when you bring your dog into the vet, they're sort of like talking to you and they're making notes verbally.
15:45And it kind of translates the transcript of the conversation and the things they're saying. And it sort of takes that and it kind of generates like action items in their task management system that they built into their software. and you can imagine how you sort of wrap an LLM where you can kind of take this like raw text and end up with some sort of structured data at the end of the day, like delineating like a list of tasks or representing like a particular like cat diagram. Yeah, when we first started in Y Combinator, we were in like the batch that everyone was focused on verticalized agents.
16:20And so those are our first users trying to build verticalized agents. and that's where we learned what primitives need to be created to serve them. And so a lot of our initial real world use cases came from people doing either bridging the real world to the AI through like back of house or some type of office type of thing, or they're trying to do like assistant co-pilots in other industry, aerospace and stuff. Since then, it's been all over the place, like internal tooling and things that Sam mentioned. Like it's just kind of exploded from there. Kind of glad that we did the vertical agent stuff first, because then we came to the market with a lot of primitives that people kind of learn over time.
17:04You're a professional software engineer. Vibes won't cut it. Augment Code is the only AI assistant built for real engineering teams. It ingests your entire repo, millions of lines, tens of thousands of files. So every suggestion lands in context and keeps you in flow. Where other tools stall, AugmentCode sprints. Unlike Vibe coding tools, AugmentCode is built for shipping to production. And you don't have to switch tooling. Keep using VS Code, JetBrains, Android Studio, or even Vim. Don't hire an AI for Vibe. Get the agent that knows you and your code base best. Start your free trial at AugmentCode.com.
17:44Can you define what vertical agents are? So you can think about any of these kinds of real-world industries. Maybe you're in finance, maybe you're in defense or manufacturing, and you have a lot of things that are like specific to your particular industry. And so there's a lot of SaaS that like maybe it's a SaaS for like manufacturing, or maybe it's a SaaS for aerospace, or maybe it's a SaaS for finance. There's a specific workflow in finance. And so the difference, obviously, is now we're making agents that can work on it autonomously, create complete tasks within that, or they can be co-pilots who assist humans in solving tasks rather than just being a software that can kind of record, hey, I did X thing, I did Y thing, and a human is checking off all the items in the checklist.
18:28Like maybe the agent can generate the checklist. Maybe the agent can complete some of the items in the checklist. So it's a software, but it's kind of doing work for people or helping them accelerate their work within their industry. Yeah. And they were telling us like the target salary range, there's like two levels to it. You're trying to replace like the 50K USD salary, or you're trying to replace the highly skilled labor salary, like 200K or whatever. So you got like these two groups of people working on both ends of that skilled labor section. But I think like more broadly speaking, like I was saying, some of the first folks we had using Monster were doing these kinds of things.
19:05But since then, more broadly, a lot of people are like, hey, I'm trying to help the salespeople inside my company process a lot of the information they're trying to process faster. And they'll build an assistant to help them do that. Right. And that's kind of the internal tooling stuff. or they'll have like an existing SaaS app at scale. And they say, well, I need to build in an agentic screen to help people like find information within the SaaS app. And it's not just some sort of chatbot on the side. It's really like a full screen takeover where it's like, okay, I'm going to go through and I'm going to go do some research that's like very specific to this kind of field.
19:38And then I'm going to like summarize that and like check the results of that. So anyway, so they're building kind of these screens within like their software applications that they're working on that kind of have these agentic capabilities and co-pilot capabilities, but it's sort of like an existing SaaS app that's running at scale. And then I think also like there's just a lot of people that, you know, if we like rewind back to 2016 or 2017, a lot of people were kind of using Gatsby to build personal blogs and portfolio sites, right? And then if you fast forward in that world, the JAMstack world or whatever, people started using Gatsby and they started using Next and they started building maybe an e-commerce site or they started building their company's website with Gatsby and with Next, right?
20:19And I think like there's a lot of people that are just, hey, I'm playing around with these technologies. And I created like, you know, our co-founder Shane created like a storybook app where it would like generate stories for his daughter, his three-year-old daughter, right? And it sort of like wraps the image and generation capabilities from OpenAI. And it's like, it's just such a cute thing. And like, this is totally a story you could go read, Piper. This is amazing. There's a lot of these kinds of use cases too, where people are just like playing around with it for like our own fun and benefit and games.
20:48That's awesome. I definitely need to steal that storybook idea. That would be great. So yeah, just thinking about it in terms of that, because I feel like that's like a good, you know, everyone understands stories, right? And like, there's lots of ways that you could approach that. I've of course done that with my kids, where I just, I give ChatGPT, like, you know, here's a list of things that my kids want in the story. Plus here's maybe a lesson that I want to teach them. like, oh, be nice to your little brother or things like that. And then it can generate a story from that. But like, this is going deeper where it can actually create a book with images and the images could make sense between pages.
21:22And yeah. And you have to sort of keep the characters maybe consistent, right? Through, you're not just generating five different images that are disconnected from each other. You need to have a consistent character representation across the story. You have to consistent narrative formatting. There's a lot of thought that goes into creating it in that kind of level of quality that you can kind of build into your agent. That's fascinating. Yeah. And there's a lot to that. I'm just trying to think of like how I would get started with Mastra and like you have a lot of these primitives, I guess. How do people who are getting started with it learn how to orchestrate all of them together?
21:55Is that something that the docs cover really well? Is it just kind of intuitive as you get in there? Is it kind of like trial and error? It's both and all the above. Yeah. It's definitely all the above kind of thing. So, okay. At Mastra, we think docs is our second product. It's like as important as anything we build. And in doing so that, I mean, community as well as another product, but like in doing so the docs have to be super good. So we try to make our docs amazing. We think they're decent. So we still have a long way to go, but then we started seeing a trend of people are just hanging out in their IDEs.
22:32So we should meet them where they are. So we made an MCP docs server. So you can like get the docs into your IDE and ask questions and stuff. You can also ask it to write code for you. And that was a good way to introduce people to Monstra. But then eventually, even with the docs and stuff, they don't teach you architecture. They don't teach you essentially what to do. So we created another extension of the MCP docs, which is the Monstra course called Monstra 101. So you can actually take a Monstra class from us within your IDE through the Monstra doc server. You just say, if you have it installed, you just say start course.
23:14And it'll go through a bunch of chapters that our co-founder Shane meticulously developed to kind of teach Monstra. And then that's another place that we're, once again, second product, right? We're consistently iterating on how do we educate people where they are. So actually features that like you wouldn't even think about is that that course can speak to in whatever language you speak, right? It can speak to you in French, it can speak to you in Japanese because it's the LM teaching you, right? So as far as we can tell, it's the first course released as an MCP server in the world. Maybe someone else did it, but we aren't aware of it.
23:52And no one else has been able to tell us like, hey, someone else did it first. So we think we're the first. What a brilliant idea. Yeah. I hadn't considered using MCP like that. And just, I guess to ask like a more technical question on that, like the MCP piece of that, is that like keeping track of your state through the tutorial or through the course? So it's like, I'm not going to give you step two until you've shown me that you've completed step one. And all along the way, it can help you debug that because it's just using the LLM to do that. Is that kind of what the MCP is providing to it?
24:21Yeah. And like, if you give us your email, of course, so we can show you the results and stuff. but then from there we're just tracking your course state and you can always reference it you can always say like i'm done with all the courses and stuff and go through it and stuff but yeah that's all there people can track their progress it looks really nice too nice and is that built with master it is yeah nice so that answers another question yeah when mcp started taking off we created like an mcp or mcp primitive so you can build an mcp server you can build an mcp client you can build those using master and we see a number of folks doing that we got so lucky on the mcp hype because it was like january or november actually because for master we were thinking like oh man we're gonna need to get all these tools and then we're gonna build a bunch of tool integrations and then we discovered mcp like the next day and we were like should we just do this instead and then we just took a bet and then it was good so we had like mcp support from the beginning everybody was releasing mcp registries and we were like what if we just our friends are releasing mcp registries what if we released an mcp registry registry and then that went viral on twitter i think maybe it was the meta-ness of the joke but lots of people were like well done yeah like here's the thing is that's actually like it was like a joke that became a feature in a way because tool discovery for mcp is like a real thing and links is, you know.
25:49Yeah. And Anthropic is making a registry API. So I don't know, like a lot of things we do are meta on purpose, because that's the way we think. And we're a framework, so it has to be meta. But it's also really funny. And it's also funny because you don't know if we're serious or not, because we are kind of serious, but we're also kind of not, you know. The registry was epic because people were like, wow, what a great idea. And we originally released that as kind of like a joke you know we got lots of inception memes i want to go deeper all the best tools are like that if you die in this you die in real life uh there's a couple questions that came out of this that i wanted to ask so on the mcp side mcp stands for model context protocol it's a way to give an llm or like an MCP client, cloud desktop, cloud code, cursor, any of those, the ability to act on your behalf or to get information from sources that it may not have information from, but also like actually go and execute tools.
Read the full transcript
26:52But at the end of the day, it's just like a rest endpoint that the LLM knows how to hit and get data, send data to and get data back from. My question is around that, you said that you're on there from day one. How does that relate to, I guess, the tools in Mastro. Is that the same thing? Are they different? Because I think of MCP a lot as like tooling, but should I think of Mastro tools in the same vein or are they different? One way of thinking about that is that an MCP server, like an agent is like a container for tools. But you could imagine if you have a bunch of tools, you could put them into an MCP server and you could just give it to your local windsurf agent or whatever and kind of, and sort of see like, hey, how does the Winserver agent interact with these tools when I put them in an MCP server as a container and give it to them?
27:40Great, that's what the MCP primitive is. But because it's this decentralized way of interacting with tools that you don't control, people have created these MCP servers that wrap tools to access GitHub or Notion or all these interesting third-party services. And because there are now all this, you know, we as devs, like, we have to write lots of integrations to do our job, but we hate writing integrations and nobody wants to write integrations. And so like in some ways, like these MCP registries have ended up being kind of like this decentralized integration hub that now your agents, your master agents can interact with because your agent can like take in MCP servers.
28:20And if you like feed in an MCP server as like a tool, essentially, it will be able to access any of the tools contained in that remote MCP server that someone else maybe wrote that you maybe had nothing to do with, but someone else created this functionality. And wow, now my agent is even more powerful because it can use all this third-party functionality that someone else just kind of built. Yeah, the low-key benefit of that is the MCP server doesn't have to be written in JavaScript. You could use tools from all over the communities that serve your purpose, but you're still connecting from your JavaScript written agent or application.
28:56But we do support you writing your own tools. of course. So you can write your own functions for tools and they work. We think of MCP like a better NPM now for this, but there's no governance there just yet. But yeah, you can also just use import from NPM and then make your own tools as well, but might as well just go on the MCP train. Yeah. Nice. I love that. It's like so much extension for free effectively for all of this. That's awesome. Building agentic AI apps isn't just about choosing the best LLM. Agents need short-term memory, long-term recall, and lightning-fast retrieval. Without it, you're left with clunky prototypes that never scale.
29:35You know Redis, the world's fastest caching solution? It turns out fast data is the key to good context, and good context is essential for fast, accurate memory. It's what makes AI agents actually work with your data. Redis for AI. The right infrastructure, the right tools, the only way to scale. Learn more at redis.io. slash genai.
29:57Have you tried building a text-to-SQL chatbot? If your AI agents don't understand your data, its definitions, queries, and lineage, they're forced to guess. And bad guesses mean risky assumptions. That's where SelectStar comes in. SelectStar automatically builds an always up-to-date knowledge graph of your data, capturing metadata like lineage, usage, and example queries. So whether you're training an AI model or deploying an agent, your AI can answer with facts, not assumptions. Stop the wrong SQL queries before they happen. Learn more at selectstar.com. The other question I had that came out of that, the discussion around your docs was, it was like treating docs as a second product.
30:42I have used the Mastra docs MCP immediately. Like I, it was like night and day difference adding it. And then like, it just knew everything and made it really easy to get, get up and going. And it knew what I wanted to do. And it knew what the capabilities of Mastra were like right out of the box. My question is, that's great when I know what I, that I want to use Mastra. My question is like around, you know, being a dev tools company and like having this new ish dev tool that may not be like, you know, in the memory of LLMs. like it might have come out after their training dates, right? How do you see that?
31:19How do you see marketing a dev tool in today's age as you're consistently getting more and more people that are not going to go to Google to ask, you know, what kind of tool I should use to build an agent. They're just going to ask ChatGPT or Claude. Is that something that you think about? We think about it a lot. I mean, honestly, like this is kind of our second time go-rounded. One of the great things about open source is the community and the fact that people can build things and share them with other things. Part of the community is also you can show up at AI Engineer in SF and it turns out someone else is running a workshop on Monstra and showing people how to use Monstra.
31:53And you're like, holy crap, like I'm showing up at a conference and someone else is running a workshop on this tool that we all built. This is crazy. This is amazing. We also like wrote a book. And this was just kind of like this idea that came to us one day when we were just kind of like, so the book is called Principles of Building AI Agents. it's again like it's 140 pages and kind of just walks through all the like what is rag what is prompting how you write good prompts how do you what is an agent you know what are the kind of like tool calling it walks through like all the kind of core core concepts that also just kind of came after we'd done a lot of these kinds of like whiteboarding sessions with other people that were trying to build agents and we just kind of had these interesting conversations and have these we'd kind of every time we had that we'd shared some insight to look oh wow this is really interesting.
32:37I didn't think that maybe I should be splitting up this like one LLM call into like 12 different LLM calls instead of trying to like have this one LLM call decide whether these 12 pieces of information, maybe I should just parallelize them and split. You know, so like we just had so many of these conversations and we're like, gosh, like it feels like everybody's figuring out how to do this. And maybe we should just like write a book at it. And I write pretty fast. And so we already had docs that were kind of like an outline and kind of a taxonomy, almost of those different concepts, except, you know, when you're looking at docs, it's kind of 20 % explanatory text and 80 % code.
33:12And so, you know, we just kind of took that, but then like flipped it where like we expanded the explanatory text where it was like 80 % explanatory text and kind of 20 % code and some historical background. And it was like a couple of weekends and I just kind of, we kind of like kept writing and kept writing and kept writing. Then all of a sudden it was like 90 pages and we're like, okay, like, I guess this is like publishable. So we published the book. And the reception has been really incredible. I think a lot of people have said, like, hey, I keep hearing about agents. But, you know, when I kind of read the book that you guys wrote, it kind of all made sense to me.
33:42And I actually understood how I would do this. I think the reception has just been like, we've been really kind of like humbled. And we try to pass out a lot of copies of books at like events and such now. Can confirm the book is great. I put a lot of pieces together in my mind. So yeah, plus one on that. For the LLM SEO technical bits, though. We do do LLM.txt and full text and all that stuff. And then, you know, it's pretty much kind of our game there. We're starting to get into like ChatGPT responses now, but that's probably just because we're kind of all over the internet right now. There are actually companies in our YC batch that's job is to help you get onto LLM's responses.
34:26Like that's their business. So there's probably a whole little playbook that they have to do there yeah one of the things too is just about the models basically scan the internet right when they're doing especially when you put them in deep research mode they kind of they scan the internet and they pick up what's on the internet so you know when your community members and this happens a lot right like tutorials about monster like that gets picked up we didn't have anything to do with that someone just got really excited about monster and wrote a tutorial and sometimes that tutorials in japanese or whatever because there's a huge industry community in Japan.
34:55That's been kind of also one of the biggest things that has probably helped us on that front is just like the community being excited and like writing things that gets kind of picked up. We've talked to other sort of dev tools folks, as you know, at Resend. And what basically happens is like when your tool has become the consensus choice among developers, the models can kind of figure that out just by like reading the internet and seeing how people are describing it. And so when your tool has become the consensus choice, you almost get like an amplification effect. And so I think that's great because like what that says is that you should build a great product that like people love.
35:32If you build a great developer tool that like people love using, everyone feels is like the right thing. And if you are successful in doing that, then like the models will kind of surface that to like people who are coming in asking them. That makes perfect sense. And so it seems like what we're doing to get your name out there for people to use it, like it's all amplified by these tools and they know how to surf the internet just like us. So that's good. And then getting into actually using these tools as new tools come out, you're positioned in the perfect spot with your own Docs MCP that immediately just like gives all of the knowledge to the LLM to help you.
36:06So that's great. One of the other things that's like really helped us a lot, we've kind of gotten the band back together from the sort of the core team that was at Gatsby. And I think we all working together and we all sort of like, we've done this before. And so we think we can work together pretty quickly to build great stuff. And so honestly, that's probably the biggest thing, like working in our favor is just having a lot of great folks that like working together and have like built an open source JavaScript framework before. Nice. Yeah. Yeah, for sure. One question I was ask is, Robby, you mentioned kind of like almost stumbling into MCP, like just being there right there at the right time to jump on it.
36:45I'm curious if there have been any other decisions or things that haven't panned out so well that you've had to kind of pivot from. So first thing we did, we tried building a prompt builder, like a utility function that helps you build prompts. This is when prompt engineering was all the rage and actually models at the time were okay with XML tags and stuff, but now it really doesn't necessarily matter. So we built something like that. And then that's when we really learned that we should listen to our community more because we like posted an experimental exploration. We got a bunch of feedback from our, and at that time we had nobody really in discord.
37:26I'm sure nowadays we get a lot of opinions, but like at the time we had like some early contributors that are just like, Like, this is why I would never use this. And it was like a bunch of valid reasons. And we were like, okay, let's just not, let's scrap this. We tried building like an MCP registry ourselves. And then we tried to get other registries involved early. But then with the lack of, Anthropic owns the spec and the governance, it's hard to try to like get in there and sort of shake some motion up. So we kind of just did our, you know, the registry registry thing. and then we'll maybe revisit stuff like that.
38:03The last big one that I remember is our initial version of workflows would never have worked for what we were trying to do. And so we kind of built it half-assily in the beginning and then we kept going on it because we were too far in. Much like many developer teams get into, you're too far in and you can't go back. And then you realize that you have to just go back. And then, so that was like a big time sink for us, but I'm glad we did. Cause now we have a lot of power that we can then use going forward. So there's been other times it's just taken us the time to find the right things. So like initially we knew we wanted to work with AISCK, which is the library from Vercel as a, as a model routing layer.
38:49But the first way that we did it was kind of, we were sort of republishing a bunch of their packages with sort of a little bit of a wrapper. The import structure was like too long. And then we were finally like, why don't we just expose their API? So we sort of ripped out our whole model routing layer that had been built on top of their model routing layer. Just said, like, use their model routing layer. While we were trying to figure out how to, like, with it, but it wasn't the right API. You know, that and sort of like this new workflow engine that we launched in, I guess, March. Like, those were the last two sort of, like, big re-architectures.
39:21Like, that one was in January. And then the workflows, like, we called it vNext at the time, was in March. Those are like the two big re-architectures that we've had to do over the, you know, nine months we've been working on this. Nine months. That just got me thinking about how different the world was nine months ago. Yeah. AI time is sort of like two to three or four times as fast as normal time. Yeah. I think. It's just something different is happening in this part of the region. It's like singularity, black hole, something. Time dilation. I don't know what it is. So you're focused on building these like primitives, right?
39:52And I'm sure that things have changed dramatically in the nine months that you've been doing this. Have you found that the choices that you've made have been pretty resilient amongst all of the changes in AI? And do you see that trend kind of continuing? Yeah, I would say the first generation of AI frameworks like LaneChain, what they kind of tried to do is they tried to do a lot of this prompt engineering stuff. Because at that time, the models weren't good enough. And then something flipped around June or July, about a year ago, where the models were good enough. And then the right thing to do was kind of build these like workflow based abstractions on top of that.
40:29You know, by when we started working on the problem, we landed on that the correct abstraction, which is build the agent abstraction on top of the models, the workflow abstraction on top of the models. The other big thing that has stayed the same over the last nine months or 12 months, but was kind of different than before, is that when you're building on top of APIs, you don't need to do any of this sort of matrix multiplication kind of machine learning stuff that a lot of the Python people are doing, which means that there's not a default language that you should be using. You can use any language, and why not use a language that you can build your whole app in?
41:01Why not use TypeScript? Even though things are moving quite quickly, there was a distinct inflection point. And then we started building on the right side of that. We ended up with the right architecture. Yeah, it feels like we got a little head start with then like the rest of the world by starting early. And like every week, we have like this channel in our Slack called Kindergarten, where we like share all these blogs and white papers that we should read. And I'll be named that because it was like, hey, we're all going back to kindergarten. Like we all got to learn this stuff. Like, I think one of the things that to stay up to date in the AI world, you have to stay humble.
41:37You have to like not think that you've learned at all because nobody's learned at all. And there's new stuff coming out every week. I think it's hard to not be glued to kind of Twitter X in that world because you're always just like scanning for what the new model releases. And, you know, there's just a certain set of podcasts that you like obsessively like listen to and whatever. But like you stay humble and you stay in kindergarten to know. Yeah. Yeah. And then when you look at the articles and stuff that are coming, and these are research papers and stuff, a lot of them are coming out before Sam Altman tweets about them.
42:08And that's kind of like the signal that everyone else is going to do, like come into the thing. For example, agent memory, we've been focusing on that since we started the company, essentially, because we were reading a bunch of white papers on that and it wasn't mainstream yet. And then what did OpenAI do? Chud, GPT has memory now, which now made people realize that this is a primitive that exists. So I think we were very fortunate that we had a little head start and also are in the mindset of always learning. Because we haven't been off yet on our predictions on what's going to happen or what thing is based on what we've read and stuff.
42:44Nice. Yeah, that's very fortunate. And I love the idea of just that kindergarten channel. I want to adopt that for sure. It's just like constantly take me back to school. We know nothing. That's one thing you mentioned the AI engineer world's fair, like talking to people there. It was so great because like, I realized that everybody who's like in the space right now, we're all just learning together and there's so much to glean and like so many ideas. Like I just left there brimming with, with ideas. And what an exciting time to have a great dev tool in that space. The final piece I wanted to touch on was your developer experience.
43:17I think that that's one of the major selling points of Mastra just in my playing with it day to day. And it's so easy to get going from the command line utility that like walks you through getting set up, suggests a model to get going with, and then like boom pops you into a browser based environment where you can see the agent, run the agency, what tools it's calling, see all of the workflows and all of that. How did that come about? Was that like through your experience building Gatsby and other dev tools that you just kind of knew how that was going to go or a lot of trial and error again? There's a funny story behind it.
43:53And Sam can add some color there. So the first version of Monstra, let's say Monstra negative one. And at the time, this is like October, right? So at the time, AI products were very much GUI driven. So the nature of having a playground for us, like Monstra was not code first. It was actually like JSON structure first. And you would actually create all the agents and stuff through UI and all that. And so we showed it to a bunch of people we respected. And they just said like, oh, that's cool. And if you're a DevTools builder, anyone says that's cool actually means go F yourself. Really like, you know, they're just too polite to tell you that you're doing something stupid.
44:31That's cool. Like, and I just knew I was, I remember Sam and I were together and Shane, I was literally distraught. all these people I respected just said that's cool literally means like they should tell me to jump off a bridge right so I'm just all distraught we're at the bar I'm like guys I think we have to rebuild everything and we did which was the right thing so it was good but the playground was like when we changed everything to code code first we were just thinking like hey this playground was pretty cool though so we should probably keep that in some way and then like Sam you're the one you and Shane kind of have the brilliance behind that so you guys you should take over the story.
45:05I think Shane was kind of the one that really pushed for it the most, but to get the playground to work, we had to do a bunch of like really kind of crazy bundling stuff. So what you do in the playground, right? You, you, the playground is kind of a visual chat tool. So like if, you know, monster is a backend tool, you're building the backend of the agents, but then you kind of want to see how it works and see how it responds to different commands. And so it gives you a chat. It lets you see the traces. So it kind of gives you like a tool playground where you can see inputs and outputs. It gives you a screen where workflow visualization.
45:36So if your steps have, you have branching or if you're chaining them together, it'll just show you them. And then like you can put in a sample input and it'll kind of run them. It's like that inner loop of development, right? You're like, oh, this thing is in the right direction, but I just need to tweak this bit. I need to tweak that bit. I need to add a step here. I need to tweak the prompt there. You know, I need to think about this edge case. And we just do so much of our development loop is that inner development cycle. And we just kind of were like, gosh, like, we were sort of like porting our old playground.
46:04Because initially, like, right in Monster Negative 1 that we had in, like, October, November of last year, the UI was driving it. In this case, like, it's a read-only UI. You know, you're not changing the code. You go to, you know, VS Code or Cursor or whatever to change the code. But, like, you can see how the code that you've written, what it does, and you give it this input and, like, what the output is. and then we sort of switched it over that one we're like you know gosh this feels like it's kind of cool and it like it really feels like this is something kind of unique and different but once we kind of like committed to it you know it was just like 10 000 little things is the ui details where it like highlights the step in green when the step is running and then it moves on to the next step and has the next step in green and you can see the input and output at each step and like what do you do when you have like a really big diagram and how do you represent like nested workflows and, you know, like, how do you like arrange the agent chat and like, how do you represent the tool call in the chat?
46:58So it like displays visually differently. And, you know, we just sort of went through the iteration. And then, like I said, like a lot of bundling stuff we had to do, because like you're exporting your workflows and your agents right in a way that like you could use it in other bits of the code, but like also you have this kind of dev server that's kind of using them and pulling them into like a different type of environment. So there was some like narrowly stuff there that like word from the team had to work on to get it right there. Yeah, that's a good point to touch on. Like the skills that we learned at Gatsby to pull something like this off.
47:29One, we became bundle, we call them bundle rooskies. If you think about it, there are not many few people left in the earth that can bundle JavaScript proficiently as we used to do back in the day. And so we used to do it back in the day. That was like our job. And we had to do it. How many people had to do it? So there are very few people on the planet who can bundle JavaScript. So that's us. Second is we used to create Gatsby's GraphQL server from all the BS framework code. So we're really good at making servers too. And that's kind of how the Playground comes about. We transform the framework into a Monstrous server, which becomes the REST endpoint for the Playground, which has some gnarly bundling stuff with bundling server and JavaScript.
48:10But then it allows us to do cool user experiences like that. It also allows you to run Monstra as a server, or you could just run it as like an import in your current application. So like being good at bundling allowed us to have two different modes of usage. Nice. I didn't realize that. And I agree. I've dabbled in bundling and just get frustrated every moment of it. I think that these tools are very important just from like also a learning perspective, Like being able to like put things together and then see it visually like that, like don't discount that. So I think that you're definitely on the right track of like just helping through those tools to easily like help people like myself who are new to all of this understand what we're actually building and how it all works together.
48:56Kudos on that. I wanted to ask about like roadmap or vision for the future. Things are changing constantly. And like, is it a lot of like reactive based on like what, you know, how things are changing in the world with, with AI, or do you have like plans for like new features coming to Mastra? Do you want to speak to that? It's sort of a variety of a lot of different things. So the core primitives are what our roadmap looks like right now. We know what our core primitives are. And like some proportion of our roadmap is like interoperability for our core primitives, right? We want, and like some of it is like, we're working on some new eval stuff right now where we have the concept of this score and like a score, which we think is much better than these like LLMS judge and evaluator kind of tools.
49:40But like, we've built that into the playground, right? And then we're, you know, the next day after that, we have a cloud product and we're building it into Monster Cloud as well. And so it's sort of like, hey, you have these changes in the core that kind of like, you know, ripple out across things. Like we're working, for example, right now on templates. and so like you know just walking through kind of like hey i want to build a docs chat bot here's a starter code repo the template code repo for you you know to install like a pdf upload these like really basic use cases and it's like well okay cool we built this like library now we're you know going to get the cli installed now we're going to run like a hackathon to get in the community to get the community to build some templates we're gonna like have get the templates working in playground and then the templates have to like go in you know in cloud so some of it is like that where you're like, I got to trace this feature across a number of different platforms, almost think about roadmap.
50:30Some of it is coming from sort of like externally to us. So like in the space and in general, it's kind of two of the biggest problems in like agent building are one problem we call like synthetic evals, which is how do you take this like raw traces that your agents and workflows are emitting and sort of turn that into like a set of tests, a set of statistical tests, these evals of for your agents, what's the loop that helps you do that? And then Then another one is like agent learning, which is how do you use those like, again, that like raw exhaust of kind of like traces and actually improve your agent performance.
51:03And given what it did in the past, you know, kind of learn from that data. And like those are sort of like two broad problems that we were just sort of like widely recognized in the space of problems. So we're like we're working on various, you know, approaches to there. But like that's coming from the space as a whole. We're thinking about this and there's like other folks thinking about this as well. and like somebody's going to figure it out over the next few months. And we'll either be one of the first ones to do it or like once it's accepted what the right way of doing it is, then it'll be really easy to build that into master like one of the kind of the two things.
51:35Broadly speaking, the other things that we're thinking about are sort of like agent authentication, agent sort of like security, you know, guardrails for like inputs and outputs. I was talking about our multi-agent primitive or agent network. We're working on an event-based execution system where you can custom-defined events and have them bubble up. Multimodal support, whether it's images and voice, we have some stuff there, but there's going deeper into voice, thinking about video. The frontier of what the models are doing is shifting so quickly. A lot of other bits are the integrations with other kind of, there are agentic front ends, like CopilotKit and Assistant UI, for example.
52:20And like, we have a lot of work that's like, work really well with them. And then a lot of the other sort of providers in the space that have like sandboxes for code execution and like browser use tools, web scraping tools, good integrations there. So I think like a lot of it is driven by the ecosystem. A lot of it is driven by the natural development of our own primitives. We got a lot of work to do. That's for sure. I mean, time moves fast, but I think like, yeah, there's the space is evolving so rapidly and it's like, yeah. Yeah, it's constantly changing, but you seem to have a good instinct for it now.
52:55So keep that up, keep it going. Is there anything that I didn't ask you about that you wanted to mention about Mastra? I think one of the lessons that everybody should have is that kind of something I'll be alluded to earlier. Whenever a new team member on boards, like it takes like a month or two for them to kind of learn all the agentic kind of concepts and how everything all works together. And we've now watched, you know, probably a dozen folks like go through this transition. And it's just a little bit of time and immersion. And I think like, you know, if you're new to the space, or if you don't feel like you don't know a lot, and a lot of what we said might be these like terms, you're like, what are they even talking about?
53:29Right? it don't be distracted or discouraged we just we've watched so many people go through this it's just try to immerse yourself in it however you can build something yourself and that's the best way of doing it you know hopefully you know just use monster like find some toy storybook type project where you can like build it that would be like cool and fun and interesting and like use that as a vehicle to learn the concepts you know read the book free copy at like monster.ai forward slash book just like immerse yourself in it for like a month or two months and you know you'll sort of go from like, I don't know what this stuff is.
53:59And what are these people even talking about to like, wow, this is like pretty cool. And I I'm getting the hang of this. Right. I think that's our biggest like advice or takeaway for, for folks. Yeah. We're really dedicated to the education part of this. So like every Thursday, there's a master workshop. If you want to learn something new, even things that we learn tomorrow, we're doing a lesson on background agents with cursor and codex and stuff. Sometimes it's not even about master. We just like teaching things. And on Mondays, I remember back in the day when I was learning JavaScript, JS Jabber was so cool.
54:30I used to listen to that stuff. So we also do like a live stream agents hour where we talk crap with each other about just the things. And that also gets people. We've had so many new people to the community come through there because you're now in the days where you're vibe coding and you're vibe listening to people, vibe code themselves. And it's like this whole world that's coming. And so I would recommend if anyone's trying to get into this, just come to those things and we're happy to have you. Nice. Yeah, I will try and be at the next one. That sounds great. How can folks reach out to you or learn more about Mastra?
55:06We're Mastra underscore AI on Twitter X. I'm Calc Sam, that's C-A-L-C-S-A-M on Twitter. I would say like you can also like NPM create Mastra at latest and like, you know, just kind of walk through that. And then NPM run dev and spin up the dev server and kind of just play around with it, you know, for yourself as well. Yeah, you can find me on X, Avi Iyer. And then, yeah, just come join our Discord. We interact with the community, so come say what up. Yeah, please do. It's an exciting time to be a developer. I think it's an exciting time to be a building. And there's like so many things that we can build now that we couldn't have built like even a year ago or two years ago or like two years ago.
55:46And that's one of the things that just gets me excited is like seeing all the cool things that like everybody is building. All the cool agents people are building these days and all the cool AI engineering people are doing. It's just, it feels like a world where like there's magic, you know, there's kind of like that sort of magical moment when I was learning how to program where I'm like, whoa, you know, I'm doing this right. And like, but I, I didn't have that kind of experience again until, until AI. And I think like we can all have that kind of experience again. Yeah. I'll definitely second that.
56:13That feeling came back to me learning all of this. It was very exciting and still is. So definitely I'll second your suggestion on that. Thank you for sharing all this knowledge. I love the DX of this tool. I love like all of the ideas that you have, like with, you know, the doc server. I really want to check out this teacher MCP. Sounds really awesome. But most importantly, I'm just like really excited about your excitement for teaching this and like being open about that. And so I think that everyone can learn a lot from you guys and I look forward to learning more as we go. So thank you so much for joining Software Engineering Daily.
56:45Abhi, Sam, thank you so much. Have a great day. Thank you. Thank you, Nick.
From the publisher
Most AI agent frameworks are backend-focused and written in Python, which introduces complexity when building full-stack AI applications with JavaScript or TypeScript frontends. This gap makes it harder for frontend developers to prototype, integrate, and iterate on AI-powered features. Mastra is an open-source TypeScript framework focused on building AI agents and has primitives such as
The post Building AI Agents on the Frontend with Sam Bhagwat and Abhi Aiyer appeared first on Software Engineering Daily.
