Your agent doesn't know your company. Mastra Knowledge does.
Your agent knows a lot, but it doesn't know your company: your policies, your docs, how your team handles things. Knowledge is Mastra's new primitive for that gap: a shared, structured knowledge base your agents can search, read, and update. Mastra founding engineer Tyler Barnes joins Shane to explain how Knowledge differs from memory, why observational memory is lossy on purpose, and how signals keep pinned knowledge current inside a running agent without breaking the prompt cache. You'll see scopes, pinned context, and the knowledge graph viewer in Mastra Studio, plus a live demo where one agent pins the pages another agent needs before it starts work. Tyler also previews what's coming next, including an importers API, standalone Knowledge you can connect to Claude Code or Codex, and subconscious memory.
Guests in this episode

Tyler Barnes
MastraWatch on
Episode Transcript
Shane: So many people are building agents and they want those agents to operate over their company's Notion docs or Confluence or whatever. How do we get all this data into a place super accessible for the agent to use?
Tyler: We've added knowledge to fill that exact gap. You can think of it as like structured related information, which is essentially lossless, and the agent is able to look at it at any time.
Shane: Hey everyone and welcome to Agents Hour. I'm Shane. I am here with Tyler Barnes. Tyler Barnes is a founding engineer at Mastra and if you've been watching the show for a while, you've definitely seen him. Today we're going to be talking about knowledge. So if you have been paying attention, we have somewhat recently released knowledge as a primitive within Mastra. And we've been getting a lot of questions from users of when would I use it. How does this compare to memory? And we wanted to bring on the expert, the one who's been spending a lot of time working on knowledge and memory over the last 18 months, two years almost at this point. So Tyler, first of all, maybe just a quick Intro to you for those, you know, maybe handful of people who haven't seen you on the show before.
Tyler: Yeah, so I'm Tyler. I've been working at Mastra since the early days, been I think almost two years now. So founding engineer. I've been working on anything sort of related to the agent's context window this whole time that I've been here. So memory, knowledge, signals.
Shane: We've been working on context before that word even existed.
Tyler: True.
Shane: Yeah, and so you've worked on a lot of the different pieces, especially of like our first iteration of memory, obviously observational memory. And then, you know, more recently signals and now knowledge. And the funny thing is all those systems I think are related, right? And they kind of work together. But maybe you can start by just telling folks what is knowledge and what was the reason why we thought we needed to build it.
Tyler: It might be better actually to talk about what memory is. In Mastra, memory is sort of like it's the agent's understanding of everything that's happened in the context window, you know, interacting with the user or, you know, getting signals coming in and so on. You know, reading external information via tool calls or you know, getting notifications. So we obviously like you mentioned observational memory. That's like our main recommended memory system and it sort of compresses things over time. It works really well for keeping an agent on task, keeping prompt caching working and all of that. And as we saw, like we get LongMemEval results where we we scored like state of the art. It actually is very good for being able to remember things over very long periods of time. But the downside of it is that it is intentionally lossy. We on purpose lose details of what happened. But then the other thing is there's all kinds of information which does not live within you know that kind of memory. Agents will call tools to look at things externally. So until we had knowledge, that was really up to you to sort of like provide those tools to your agent. And that maybe that was like, you know, a shell tool or you know, searching the web or looking through like some markdown files that you had on disk. But knowledge, we've added that to fill that exact gap. You can think of it as like structured related information, which is essentially lossless, and the agent is able to look at it at any time. There are tools for that, can modify the knowledge and so on. Knowledge can be pinned into context as well. So memory is for keeping the agent on track, keeping it focused, prompt cacheable. Knowledge is for all this external information that it will need to intentionally look up, all the lossless, detailed stuff.
Shane: Yeah, I mean I think so many people are building agents and they want those agents to operate over their company's Notion docs or Confluence or whatever, right? They have all this data, all these documents spread out, and they want their agent to know you know, what does the organization care about? What are our policies? How do we respond to certain things? To me, it's kind of solving that problem, which is how do we get all this data into a place super accessible for the agent to use, right? Get the right data in, make sure that the agent can only access the parts it should be able to but then it can easily also maintain that or update it over time. So before we really dive into knowledge in more depth, which I want to do, let's take a second to talk about signals because I feel like that's part of this story as well. You know, I feel like signals plays a part of how we've been thinking about context at Mastra. So can you tell people what signals are and what was the missing piece that signals helped unlock?
Tyler: If you think about interacting with an agent, traditionally that's been like you send a prompt in and then it does a bunch of stuff and then it's done. You could send another prompt. But context engineering became a big thing over the past year. Right. People are talking a lot about that. I mean it's almost kind of an old thing at this point, but I guess how things changed from those early days is that agents are connected to all kinds of external information and they're being continually kept up to date with maybe GitHub or Linear or whatever, all kinds of external data sources. And then that original like, you know, prompt, and then the agent does something and send a prompt. That cycle doesn't really work so well because now you have to wait till it's done to you know remind it of something or it has to call a tool like it has to choose to do that. So signals, we designed them to solve that exact problem. So decoupling sending context into an active like running agent before it was like you'd set a prompt. You would need to own that stream as in like the code calling it, right? It would need to just essentially await the agent to be done and then you could send another prompt. With signals that's completely decoupled. You just have an agent that's always on and then signals are data being sent in and the agent immediately sees that information.
Shane: I think the coolest signals demo that really made it click for me was when we had it in Mastra Code and it was just listening to the checks on my PR. And, you know, GitHub sent the signal in or, you know, it basically like no notified while I was having it do other things that, hey, this PR review came in or this PR check. CI check failed or something and they just responded to it and just kept working. It fixed that and kept doing what I the other things I was asking it to do. How does it work? How does it actually get sent into the message or into like the running stream, right? The running agent without like interrupting it or stopping it.
Tyler: If you think about the old way, you could technically just abort the agent. Right, and then send another message. But you would continually be interrupting tool calls and all kinds of things like that, right? Maybe interrupting the agent while it's in the middle of outputting some text. So with signals what we do is we sort of have like a queue right but they're coming in and then the first moment when we can drop a signal into context, we do it. So like if the agent is outputting text, we'll wait for that to finish and then we'll immediately drop it in. The signals themselves are actually modeled as user messages. You don't want to confuse the agent and think that it said this thing. So it's dropped in as a user message and then we wrap it in XML tags. The reason we did that is agents again are trained on XML tags. So it'd be like user assistant. User assistant in the training data. So we essentially, you know, we have the user block and then we put a block inside of that. Maybe they'll say like notification is the XML tag or like GitHub or you know something like that.
Shane: Yeah I mean I've seen you know like reminder or system reminder or something also you know different types of tags that kind of get inserted into the context at different moments. Now let's talk a little bit about knowledge. How does knowledge work in Mastra? So for folks listening, whether you're using Mastra or not, I think a lot of these concepts should apply, right? You have an agent, that agent needs to remember things as people are talking to it. But you also have some kind of like storage layer, a database, or something that you need to get context into the agent and you need a reliable way to do that.
Tyler: So knowledge, so we designed it to work with any storage adapter. That was like what one of our first requirements. So it's not exactly like a you know like a knowledge graph, like with a knowledge database necessarily. We're thinking of it more as like a context graph. It is like a sort of a flat graph. You have like pages, what we're calling you know the nodes in the graph, and then you have notes that link pages together. And the agent essentially will see one level of the graph at any point, like a page A and then it can choose to call a tool, it sees, oh, there's here's all the pages that are related to that one, and it can kind of walk through the graph that way.
Shane: So it's almost like it's digging through like folders in a file system in a way.
Tyler: Exactly. Yep. The whole context graph is essentially a role and like access based. So that's done by creating scopes, is what we're calling them. So you configure the scopes that you have, and then each piece of knowledge will fit under a certain scope. So maybe like you have a role like support agent scope and then that would grant it access to some part of the context graph. You're also able to like grant access from one scope to another scope. So maybe you have one scope which has admin access on one whole section of the context graph, but then another scope just has view access on it. This actually sort of brings us back to signals here because for different scopes you can pin pieces of the knowledge graph into context. So you can say if you have this support agent scope we will pin this subsection of the graph into context so it's always available and up to date and we use signals for that. So we use another type of signal that we didn't talk about, which is state signals. And state signals are like a way to represent some external information into the context window in a prompt cacheable way where it can change over time.
Shane: How does that prompt caching mechanism work, right? If I have some data and it drops in context, the agent's doing his thing or whatever, and then that data changes. Because you can't go back and update the original context, you didn't, yeah, the cache is busted then. So how do you how does that work? Does it just drop it in? And it just drops in another like state signal update block or something?
Tyler: It's pretty much exactly that. So we scan backwards through the context window and we see has this state signal been inserted anywhere? If it hasn't, then we output what a snapshot. So a state snapshot. That's like the full state of whatever is being tracked. And then as the context window continues to progress, if the agent is doing things, if that state changes, we just show the delta. Now eventually the context window will get so large that the memory system needs to evict older parts of the context window. And when that happens, we again see, oh, the context window does not have this up-to-date snapshot, so we'll emit it again. So it's sort of like always appending either a snapshot or a delta for that state.
Shane: Give me an example of what could live in the state for an agent, maybe a support agent or something.
Tyler: Could be if a support agent is like tracking multiple different like issues of customers. Maybe that's like a hundred of them. You want to see like the status of all of those.
Shane: So let's say it's like active support issues that are being worked on, status or something. And then one of those statuses changes. So first we drop in the whole list, all the state of this thing. The agent's doing his thing, something changes upstream, the status changes. It gets dropped in the context that this one support issue or whatever changed. Then it keeps going. The memory system decides I need like observation happens. We exceed the context of the observation window. It compresses it. That state has now, you know, been basically like overwritten, right, or lost, potentially. And so then the whole state gets written again, kind of at the end.
Tyler: Exactly. And that's what makes it prompt cacheable, right? We're just only ever append appending things and just the most minimal information that we're able to.
Shane: And so then the only time the prompt cache gets broken is when you hit observation, but then your context window shrinks significantly.
Tyler: Yeah, exactly. And often that's still like a partial cache hit, depending on what your provider.
Shane: Yeah, your system prompt probably stays the same and like other things it's just the context. What's changed? Like a user since you sent the first user message might change a bit.
Tyler: Yep, exactly. The system prompt and then the observations actually would probably be stable and then some new ones get added and then we add a little bit of the conversation. So the uncached tokens is actually pretty small.
Shane: Okay. And so kind of final question. And then I know like I know you have a demo. I want to see that. You have this knowledge base. How does the agent decide it needs to get data from it? And then how does the agent decide I can update this data? I have access to it. I have the right scopes or whatever. Like how does that part of the system work?
Tyler: There's a couple ways. So one is that you could just write system instructions, you know, so under these situations, look in the knowledge base under these certain areas, but I think maybe the more interesting way and the more dynamic sort of powerful way is to pin context. One agent can pin context into another agent if you give it access to do that. Actually I'm gonna demo that. The other way is that your config, you can say for a certain scope, if an agent has this in this part of the knowledge graph into context. So pinning it can either be pinning a list of the pages that are under that section. It's almost like a site map in a way or like a folder directory listing. Or you can pin actual pages. Right. So specific pages like a refund policy or you know context on how to work within a certain repo or something like things that change over time and need to be sort of related to other things in the graphs. Right. So it might see this refund policy just pinned into context and that would also give it all the different links to other pages in the knowledge graph that it could look at. So it would know essentially from that pinned context, oh like there's this refund policy, but there's a specific case in this policy that I actually I need to look into more. You know, I could follow the link and kind of read through, you know, maybe some more in-depth complex parts of it. And then you're able to give agents read or write access on any part of the knowledge graph. So in that case that agent might only have read access but maybe there's like another sort of like manager agent that's overseeing like a hundred other ones, right? It could be kind of keeping on top of like, oh, these agents are not actually following this refund policy properly. And it can you know, go into the knowledge graph and update that page or add a link to some other relevant context. And since we were using state signals, all of those agents that have that pinned will immediately see that update. You can sort of build very like rich systems that way.
Shane: Awesome. Well you mentioned a demo. I think we all want to see it in action and see what kind of things you can build with knowledge.
Tyler: All right, so what we're looking at here is Mastra Studio. We've got the knowledge graph viewer here. For my demo, I've pulled in all the information from the Mastra site as well as some internal information that we have from our internal knowledge base. So this ranges from anything like blog posts from the Mastra blog. Got authors, like here's Shane. You can see actually Shane is a lot of different things are linking to Shane. Oh yeah, workshops. So that's why you can see up here in the top left, all those green ones are our workshops. You can see we've got tons and tons of info here. So what I'm gonna do is I'm gonna jump over to an agent. We've got two agents, so I have an explorer agent. And I'm going to tell the explorer agent that this other agent, which is a worker agent, is about to add suspend timeouts to Mastra workflows. So it's gonna know to look through all of the knowledge graph and just find any information that will be relevant for the second agent. So it's going to add it to this scope feature workflows, and then the worker agent will have the scope. So at the top you can see that the worker agent had the the listing of the knowledge graph pinned into context. So this is what we were talking about before. It just sees all of the possible pages under this section. And then it'll start diving in, like it started looking in the workflows section. And it looks like it's actually done quite a bit. And then decided to just pin four pages. It's gonna pin workflows suspend resume, snapshots, workflow steps, you know, just a bunch of information that the other agent's gonna need.
Shane: So it pins it in the knowledge graph and then the agent that's using it picks that up.
Tyler: Yeah, exactly. So you pin knowledge to a specific scope, and then any agent that has that scope assigned to it is gonna see the pinned information. So if we jump over to the worker so I'll just send it this other prompt, so add suspend timeouts to Mastra workflows. We'll see that immediately, right? Pinned knowledge. So those four areas of the graph that the first agent pinned, like this second agent, the worker agent doesn't need to look them up at all. It just already sees them immediately. If I click on that, so this is one of the pages. So workflow state reader is under our reference section. I guess it figured it needs this.
Shane: So would something like this be useful? If you had, you know, whether it's an agent that can create other dynamic agents or an agent that has subagents, this could be really powerful in more multi-agent systems.
Tyler: Absolutely. And we didn't design it only for that. But it works very well for that. So simply because of this pinning context, the manager agent being able to pin.
Shane: And so even if it's a single agent, it's still useful. But if it's a multi-agent system, it's also useful.
Tyler: Exactly. Multi-agent systems, you can even use this as like a messaging system for agents, you know, they can have like a whole task area of the knowledge base or really anything you can think of. Well, let's see, did this agent actually do anything? Okay, so looks like it finished and you can see at the end it actually cited which areas of the graph it used. It finished this work in like a local worktree and then it's, you know, just kind of explaining how it behaves, you know, the files have changed. Open the PR for this. So yeah, the agent opened this PR, adding timeouts to suspended workflow steps. Quickly scanning through it, it looks like it makes sense. It did at least kind of understand everything it needed to do and like the areas it needed to change. I think maybe one interesting thing is that it didn't have to continue looking through the knowledge graph. The information that was pinned was actually enough for it to just go ahead and just do the whole thing, which is kind of cool.
Shane: All right, so that was cool. But kind of as a follow-up question, what's coming next with knowledge? Like what are the what are the things you're excited about? What are we working on? What are you what are you excited for other people to be able to see soon-ish?
Tyler: So we actually have so many things. It's super exciting. I can't wait for everyone to see it. The things coming like soonest would be importers API. Right now with knowledge, an agent needs to call tools to insert. Or you can call like some methods directly on the knowledge instance to insert data. But our new importers API will be much better than that. So you're going to be able to, you know, on a schedule, have it import data from some external source or through a webhook, and then it will connect to Mastra Connect. So you'll be able to pull in data from all kinds of data sources. Really like anything we have in Mastra Connect, you'll be able to pull information in. We'll have to make an importer for it. So maybe not anything, but you know, technically anything. Most things. There'll be standalone knowledge. So you'd be able to use knowledge as a service on its own without Mastra. So maybe you want to connect it to, you know, Claude Code or, you know, some other agent framework even.
Shane: I think that one's the one that I'm very excited about because of course if you're already using Mastra, just add it in, all of a sudden your Mastra Mastra instance, your Mastra project has knowledge, it's great. But for those of you that maybe want to either have separate services, you have agents over here, you have a knowledge base over here, you have different tools that might interact with both those things. Having the ability to spin it up as a standalone, its own service running somewhere else, I think is gonna be really powerful. And I think the exciting thing is we're gonna have a couple different ways that I think people will be able to do that in the near future. So they can easily spin up kind of a standalone knowledge base and then interact it Yeah, connected to Mastra agents, of course, that's great, or any other agents or other system that you want to connect it to.
Tyler: And the cool thing too is you'll be able to do them at the same time. Like you could have a Mastra agent and Claude Code or, you know, Codex or whatever other kind of agent, like all of them can be pulling from the same knowledge, you know, context graph.
Shane: Awesome. Anything else? Any other thing that you're excited about that's coming soon?
Tyler: There will also be so subconscious memory will use knowledge. So if you've heard you know, terms like dreaming in the past, you know, from maybe Anthropic or other companies, we'll have something sort of in that direction. But our own, you know, sort of Mastra way, right? So we're gonna integrate it very closely with observational memory. You'll have agents that can run in the background and sort of work over your knowledge graph and kind of piece things together or you know surface information to your agent. So that yeah that one's gonna be really big.
Shane: Kind of merging the two systems together even more tightly, memory and knowledge. Tyler, thanks for coming on the show today. Thanks for coming on Agents Hour and telling us a bit about knowledge. Not only, of course, what Mastra knowledge is, but in general why knowledge and knowledge the knowledge base or knowledge graph is separate from memory systems that are already available in the agents. We'll have you back again, of course. And for all you listening, we'll see you next time.
Abhi: Like, share, and subscribe.
Shane: And follow us on X.
Abhi: And tell your friends.
Shane: And their friends.
Abhi: I mean we're not begging.
Shane: Well, maybe a little bit.
Abhi: Subscribe to Agents Hour every Monday, noon Pacific.