Active Graph Agent Runtime (BabyAGI 4) — Yohei Nakajima, Untapped Capital
AI Engineer · 17 min · 226 sentences · from YouTube's caption track
Each timecode opens YouTube at the start of that sentence. Line anchors (#s42) are the cue ids in the WebVTT, and every line carries its start and end seconds. All transcripts has every talk, and the whole corpus as one file.
- 00:01[music]
- 00:12Hi everybody.
- 00:13Thanks for coming.
- 00:14I'm excited to be here.
- 00:16AI engineer warfare has been so fun meeting everybody.
- 00:19Um, but I'm here to talk about active graph, which is my new open-source experimental approach to building agents, which looks a little bit different than maybe you've been building agents.
- 00:29Uh, it's definitely experimental.
- 00:31The idea is more to give you inspire you with some potentially new ideas.
- 00:36Um, agents are awesome, but long-running agents break.
- 00:39And if they're so awesome, why am I still building them?
- 00:41Why they should build themselves.
- 00:44Let's build the simplest thing that can build itself has basically been kind of my research theme for the last 3 years since I did baby AGI back in March of 2023.
- 00:53So that's over 3 years ago.
- 00:55If you were there at the time, it was crazy.
- 00:57It went wild like it was covered by media.
- 01:00People thought it was going to work.
- 01:01It didn't work at all.
- 01:02Um,
- 01:03[laughter]
- 01:04Uh, over the course of 3 years I've done nine iterations of baby AGI with less fanfare, but you know, every time just experimenting on like how do we get autonomous agents to actually work?
- 01:12Usually with the theme of self-improvement.
- 01:14Uh, if you go to baby AGI wiki, you can see earlier experiments.
- 01:18Um, in the in this process I kept coming up to coming back to graphs and I've had a couple of projects.
- 01:23Earlier I did a one called Instagraph and Mindgraph.
- 01:25That was like pre-graph rag rag.
- 01:27I did some code graphs, function graphs, log graphs.
- 01:30And since then it seems like a lot of people have started using graphs to build agents.
- 01:35Um, and so and in addition to that I've actually gotten to invest in a in a good number of, you know, agentic companies, some of which you I'm sure you'll recognize through my funds Untapped Capital and I also have an agent fund.
- 01:46Uh, but yeah, that's that's me.
- 01:48Yohei, VC by day, builder by night.
- 01:51You might recognize this face more than this face.
- 01:53Um, ActiveGraph is an event-sourced graph runtime for building auditable agents.
- 02:00I have a paper that was my first archive paper called the log is the agent, but I'm here to explain it.
- 02:06So today most people build agents around the LLM.
- 02:08You start with the LLM, you add a response API, you give it tools, you add memory, and then you make sure you log everything correctly, which can give you you know all the benefits that ActiveGraph will give you, but ActiveGraph asks, what if you build around the log?
- 02:22Now what does that mean?
- 02:24Um means not everything the agent does, but more importantly, every change to the agent, right?
- 02:31Nobody here is using the same agent they were using a year ago, and the agent you're going to use a year from now is going to be different.
- 02:37And a lot of people, what the agent does and how the agent changes are tracked in two different places, but I'm saying let's flatten that down into a single immutable
- 02:45event log, and this is the ground truth of the agent.
- 02:48And this projects a sort of graph.
- 02:50This is the state of the agent.
- 02:52And what I mean by that is, for example, a prompt can be edited multiple times, but you might have, you know, a master prompt that gets used when you're, you know, when you query the graph.
- 03:00And then on top of this, you attach something that I'm calling behaviors.
- 03:04Behaviors are reacts to graph changes.
- 03:08And then they emit events, which then in turn updates the state of the agent, which might trigger new behaviors.
- 03:17Um LLMs don't talk to each other in ActiveGraph.
- 03:20They all communicate through this shared state, and that's what makes it a little bit different.
- 03:24Behaviors can be deterministic, or they can include LLMs, which is which is how you build this agent.
- 03:30And you get this beautiful typed event log, uh that's the source of truth about everything the agent did and everything every change that's happened, which means Oh, actually, well, shoot, I I jumped ahead.
- 03:41So in addition to that, there's a concept called policies, which determine how the graph can be modified.
- 03:45I'll come back to it, but for example, things like a source article that you found in research, you might be fine with adding, but if you're changing a prompt, maybe you want human in the loop.
- 03:53Or if you're changing a fact, you might want to make sure there's no contradicting facts.
- 03:57So there's these thing called policies and again, I'll show you some code you code examples.
- 04:01But yeah, in the end you get this beautiful typed event log, which gives you replays.
- 04:07It gives you rollbacks and it gives you forks.
- 04:10And this becomes natively when you start building agents with ActiveGraph.
- 04:15So this is the kind of LLM-centric versus log-centric way of building agents that I'm going to be talking about or showing you code for.
- 04:21And and again, I'll specify that this is not a harness.
- 04:24It's it's a runtime and you can actually rebuild most of the common harnesses on top of it.
- 04:29You're just forcing every single communication to communicate through the shared state.
- 04:33[snorts]
- 04:34So at the highest level, right?
- 04:36When you're building with agents, messages feels like the kind of core unit that you're seeing often, but we're going to replace that with logs.
- 04:41Logs are going to be the core unit you're going to build around.
- 04:44That's what you're going to be reading, that's what you're going to be looking at.
- 04:46[snorts]
- 04:46These are typed logs, again, immutable, clean.
- 04:50You can't edit the graph.
- 04:51These are just kind of basic rules.
- 04:53Just emit events.
- 04:54You can have the add object, which is an event emitting.
- 04:56But yes, you can query over the graph.
- 04:58And again, I'm I'm flying through some of this cuz I want to get to the fun parts and all this is in the documentation.
- 05:03Behaviors listen to graph changes and emit events.
- 05:05So this is a behavior called a planner that triggers on a goal created, right?
- 05:11And then it adds an object to adds two task objects and a relationship object, a research, write memo, two tasks.
- 05:17And then actually behaviors can actually live on edges as a something called relation behavior.
- 05:22This one has an unblock relation.
- 05:24So basically, when the research is done, you can write the memo, right?
- 05:28Um And behavior subscriptions can be pretty complex.
- 05:31They can be graph queries.
- 05:32So this one says on object created, if the if the object type is a claim, and this claim contradicts another claim, we're going to trigger the contradiction detector.
- 05:42And these can be more complex than this.
- 05:44It can have, you know, uh confidence percentages baked into it um and and then on top of that, there's another concept called views.
- 05:53Uh context management can be done programmatically as basically a graph query.
- 05:58It's a It's You basically grab a subset of the graph, which makes it available to that behavior.
- 06:02You can still do other types of context uh context management, but I felt like this kind of graph query as context management just felt really elegant.
- 06:10Candidly, I'm not the one writing the code, but AI seems to be pretty good at figuring out how to do it.
- 06:16Um and you know, I earlier I talked about policies, so some graph changes require a proposed patch before approval.
- 06:22Again, this is how you these these policies kind of give it the control on what it's allowed to change by itself, what uh what kind of changes require certain tests,
- 06:31um and I'll give a few examples in a bit, um or if you want human in the loop, right?
- 06:34And you have these kind of policies that that determine or define uh what the uh what these rules are.
- 06:42And when you bring it all together, you got these kind of object schemas, tools, deterministic LLM behaviors can be assembled into a something called a pack, right?
- 06:51With a pack policy.
- 06:53And that's how you build Harness on top of ActoGraph.
- 06:55These And all of this together is and I'll have a couple examples later um are are modular and they can be combined, uh but you're not just adding skills.
- 07:03It is much more complex about actually pretty unintuitive.
- 07:06I would never write code myself with ActoGraph, but again, AI seems really good at it.
- 07:12Um and just on like event types are fixed.
- 07:15You can add custom events, objects are user-defined.
- 07:17I only added that cuz someone asked me that question when I was showing them these slides, but think that makes sense.
- 07:22So, the old way, you got the while not done if loop.
- 07:25The new way, or at least my new way, uh you have a whole bunch of behaviors that don't talk to each other, that just monitor the state.
- 07:30So, it's it's it's inspired by uh blackboard architecture from the '70s or '80s or more recently Kafka, whole bunch of micro workers communicating through a shared state.
- 07:40One of the challenges, at least back when uh blackboard was was that it was really unintuitive to write, and the workers were very slim and deterministic.
- 07:46But now, AI writes the code, and the workers can be very powerful because they have reasoning capability.
- 07:53This is a React agent on Auto graph.
- 07:55React agent was one of the earlier agent kind of architectures.
- 07:58As you can see, it's it look it actually works the same way, but on goal created, you add a thought.
- 08:04On thought created, you trigger the reason function.
- 08:06So again, this is just to show that you can build any harness on top of Auto graph.
- 08:09It does look different um because they're not communicating with each other.
- 08:13[snorts]
- 08:13And so, to see if how well this can work, I've been running a lot of experiments.
- 08:18Um the first one I did was can I use the log itself as memory?
- 08:21So this is not pure vector rag.
- 08:22It's actually leveraging the structured log, so it knows which which message was before what, plus uh vec uh plus embedding the actual messages within the log.
- 08:31Uh I did this on long mem eval.
- 08:33I embedded the query.
- 08:35There was no semantic uh ingestion, no fact extraction, no entity extraction, but I just embedded the query, looked for relevant messages, grabbed a couple messages before and after, made sure it fit into the context,
- 08:47and it actually did pretty well on long mem eval, right?
- 08:51Like a lot of the data in your memory is actually overlaps with the memory uh the data in your log.
- 08:55Actually having them the same actually kind of makes sense and makes sure they don't separate.
- 08:59Um I did try another couple other experiments on adding kind of semantic ingestion to improve the score.
- 09:03Was able to do it, but candidly, um I could put more effort into try to increase that, but I jumped onto the next experiment.
- 09:10Actually, but in that process, one of the biggest fun surprises was, I don't know if you've run long mem eval, but you have to like 500 questions.
- 09:16And then one of the runs, uh my API key ran out like 350.
- 09:20I was like, "Oh Okay."
- 09:21So I updated the API key, said, "Okay, let's let's rerun it again."
- 09:24And it just like rolled back one and was like, "All right, we'll just start from, you know, question number 353."
- 09:30And I don't know if you have, but like I've built a lot of agents that like where the API key did broke or something, and I had to rerun the long agent from the beginning.
- 09:37and that just has not been my experience since building with ActiveGraph, uh which was a very fun surprise.
- 09:43Uh I built a couple reference agents, uh right?
- 09:45Like now I have this runtime, let's see what I can build.
- 09:47I asked Replit to build a coding agent on top of ActiveGraph and and as a result it came with, you know, a event log graph.
- 09:55And again, I'll say this, you can do this with, you know, things like LangSmith.
- 09:58Thing is, I don't know I didn't have to think about it.
- 09:59I just had to ask my coding agent to use ActiveGraph and this event log and graph came natively.
- 10:05Same thing with research agent.
- 10:07I just had just build a deep research agent on ActiveGraph and it came with this beautiful, you know, had a event event log and a graph of like where the evidence came from, what contradict to each other.
- 10:18And again, I didn't have to think about it.
- 10:20I just asked my agent to build a research agent on top of ActiveGraph and this is what it ended up looking like.
- 10:26[snorts]
- 10:26Um and then I realized, okay, how do we get this closer to like an open claw or Hermes?
- 10:30So I I played around, I have this thing called uh ActiveGraph packs, which is a core pack, a tool pack, a secret pack, a memory pack, an identity pack, a communication
- 10:40pack, a chat pack.
- 10:41So now you kind of get the idea of how I'm trying to build agents on top of ActiveGraph.
- 10:45And each of these packs have object types and behaviors.
- 10:49Again, feel probably feels very different from the way you're building agents, but I I I feel like it's actually pretty elegant.
- 10:55You can just take a memory pack and replace it with another another memory pack, right?
- 10:59Um uh uh and and it's not like skills, but like the objects and the rules and all of them are uh bundled as a pack.
- 11:05And you and you attach these packs together to create your agent.
- 11:10Um and then I jumped into the the what I really wanted to do was start playing with self-improvement loops.
- 11:15Um I did a project called Regimes.
- 11:17I did uh uh that was in paper number two.
- 11:20Um This one you was a really controlled self-modification.
- 11:23Uh Claude Code called it Regime de Scene, but basically we classified the type of failure and then based on the failure it classified it was a it was allowed to edit a specific part of the agent.
- 11:33Again, I did this on long mem eval.
- 11:35The loop was I think doing about 20 questions, looking at the answering questions, seeing where it failed, trying to self-modify, trying that on 50 different questions, see if the accuracy actually went up, and only if it went up, it would accept it.
- 11:48So, that was kind of the proposal patch that started happening, where it would do after it proposed change to itself, right?
- 11:54This is essentially the agent forking itself, proposing a change, doing a static gate check, a sandbox gate check, and then making sure it actually impacted the result, and only then accepted a change.
- 12:05And for these loops, it would loop like eight or 13 times, but only accept four or five of those patches.
- 12:10And it actually did have, you know, modest, but like statistically significant improvement on long mem eval scores.
- 12:17Uh and and not only did it know what worked, but it also knew what didn't work.
- 12:21Um at this point I was like, "Okay, can I can I get active graph to just research active graph for me?"
- 12:26So, I built lab uh active graph lab, which is reading all the blog posts.
- 12:30So, everything I've shared has a blog, a GitHub repo, and this lab is reading all of that to come up with new ideas, asking me if it can run it.
- 12:37And if I say yes, it'll run the experiment, um and then it'll write a blog post about it.
- 12:41It actually did find an error in its own code, asked me if it could it could if it could fix it.
- 12:46It wrote the PR, and then I just merged it.
- 12:48Um so, it's it's early, but it's starting to work.
- 12:51It's the lab is self-improving.
- 12:52Um it also figured out that um it looked at active graph packs, and was able to just install a pack into itself, and then wrote a blog post saying packs are modular between repos.
- 13:00I was like, "I didn't know that.
- 13:01That's great."
- 13:02Um and then I got distracted when I saw this Pokémon trading card name competition on Kaggle.
- 13:07As you can see, I'm all over the place.
- 13:09Um but uh you have to submit this deck in a deterministic agent, not with that with an LLM, and they compete in this Elo-style competition.
- 13:17So, my decks are, you know, every hour they're battling a new competitor, and their score goes up or down.
- 13:21Um and I felt like this was a pretty good uh test for seeing if active graph could help me increase my score.
- 13:27And I used no cloud code and replit and we did about 80 different passes to like try different thing and and increase our score.
- 13:35Yeah, it might not make sense if you don't play Pokémon, but these things like let's try adding a couple energy cards.
- 13:40Seems like a very casual ask.
- 13:42Um and my agent, probably because I think because I'm using Actigraph, would say, "Okay, sounds great.
- 13:46Well, let's run 200 simulated games against three reference agents and then if the win rate increases by x% and there's a, you know, whatever Wilson score above 90 something, then we'll accept that as a change."
- 13:57And I basically did this like 80 times and each time they came with this like beautiful report of like why it worked, what it did, and what the verdict was.
- 14:04So, out of those 80 passes, it probably accepted about 20 to 30 and the score did slowly improve.
- 14:10I'm still at like 27%, so I don't know if I can get higher than that, but um what was most interesting is how much how well the agent understood experiments we've tried before that didn't work.
- 14:20And that was a very different experience for me.
- 14:22Cuz I've done a lot of YOLO agents where you just like keep trying things and then it works, you're like, "Yeah."
- 14:27But then I don't know the stuff that we tried that didn't work.
- 14:30But now when I'm building with Actigraph, it tracks all the things that didn't work because it's forced because I have this policy that says, "Here are the Here Here's what we have to do before we accept a change."
- 14:41Um So, some of the pleasant surprises, most of which I mentioned, but AI does seem better at architecting these NL and base agents.
- 14:50It's just my personal experience and you know, some some people you'll have to try it yourself to see.
- 14:55But if you think about it, LLM based agents are like 3 years old.
- 15:00But if you look at, again, Kafka, blackboard, this like micro worker communicating through a shared state, there's decades of conversations about how to make that work better.
- 15:09And my hypothesis is that that's in the training data.
- 15:11And there's just much less training data around how to build LLM based agents.
- 15:16Um debugging shifted from session logs to Actigraph DB.
- 15:19Again, I didn't know it would, but when I, you know, when my coding agent was debugging, it just started querying the DB instead of the session logs because it's everything is already logged very cleanly and typed and it knows exactly how it's logged.
- 15:30Pox can be loaded easily from other repos was a surprise.
- 15:33I thought I had to do extra work to make that happen, but just worked.
- 15:36Um no more starting long runs over from the beginning and I know what didn't work, which are some of the things I shared.
- 15:42Um here's where I might lose some serious researchers, at least in the language I use.
- 15:47I don't actually know how to train models or anything.
- 15:49So I'll caveat that.
- 15:50But I'm building this, I'm starting to really think that long-running agents need not just a world world model and like a predictive world model, but what I might call an experiential world model.
- 16:00Right?
- 16:01The predictive world model feels more like the priors, right?
- 16:04And then if you think about the hippocampus, actually it also does work like an like a immutable state uh event log that projects a state.
- 16:11And then it feeds some of that state back into your priors through a replays, dreaming, and sleep.
- 16:17And so, you know, I feel like some some discussions kind of suggests that as models get better, like the harness disappears.
- 16:24But I'm starting to think that's not true.
- 16:25I think we need both um is is kind of the new hypothesis that's growing as I as I've been playing with active graph.
- 16:31And if you think about like you or me, like you or me, like we're not our reasoning capability, right?
- 16:36We are we're closer to our our our beliefs, our knowledge, and behaviors that are derived from our actual life experience.
- 16:43And if that's the case, and we're going to you know, build agents inspired by ourselves, then then maybe our agent should be treated that way, too.
- 16:48Maybe that identity of the agent is is derived from its own log.
- 16:54Um I'd love for you to try it.
- 16:57You can just go and just say look up active graph and build me something I would like to your favorite agent who knows you better than I do, uh and have it explain if it's uh if it was helpful or not.
- 17:07Um Let me know if you try it.
- 17:11Or hate it.
- 17:12Or building something relevant.
- 17:15Thanks for listening.
- 17:31[music]