HomeVideos

Graph Engineering explained in 8min..

Now Playing

Graph Engineering explained in 8min..

Transcript

236 segments

0:00

When we ask Claudecode to do a deep

0:01

research about a specific topic, behind

0:03

the scenes, it's not just one agent that

0:06

handles the entire research, but many

0:08

agents are spawned to handle our

0:10

research needs. Claudecode actually

0:12

generates a dynamic workflow that looks

0:14

something like this, where you have over

0:16

100 agents broken into various phases.

0:19

And this entire workflow is generated on

0:22

the fly by Claudecode in JavaScript

0:24

code, like you can see here. That's 427

0:27

lines of code, and this very code acts

0:30

as a runtime environment that will spawn

0:32

over 100 agents. And every new request

0:34

that I send, Claudecode will generate a

0:37

fresh new workflow, and each workflow

0:39

will spawn different numbers of agents.

0:41

So, given our example here of JavaScript

0:44

file, where Claudecode essentially

0:46

converted my research plan into a

0:48

workflow as a runtime, Claudecode will

0:50

then start launching many agents in five

0:52

different phases. And each phase of the

0:54

workflow will more or less work in

0:56

parallel, and each agent has its own

0:59

context window and its own system

1:00

prompt. Pretty neat, right? Now,

1:02

building on this workflow that you can

1:04

see here, the concept for graphs has

1:07

been resurfacing lately, as if it's a

1:09

next natural progression in our agentic

1:12

engineering. So, we asked the natural

1:13

question, what exactly is graph

1:16

engineering? The idea of graphs dates

1:18

all the way back to 1736, when a Swiss

1:20

polymath, Leonhard Euler, was

1:22

considering solving the strange question

1:25

in a city called Königsberg. They have

1:26

two mainlands and two islands and seven

1:29

bridges connecting them. And the

1:30

question was simple, is there a route

1:32

through the city that crosses every

1:35

single bridge, but only exactly once?

1:37

Now, you might try and hypothesize a way

1:39

by process of elimination. Maybe you can

1:41

start here and try to cross the bridge

1:44

this way, or maybe you just start on the

1:46

island instead and start out and see if

1:48

there's another way possible, and you'll

1:50

soon realize that this is not possible.

1:53

Euler agreed, but it's not just that

1:55

this wasn't possible, but how Euler

1:58

simplified the problem into a simple

2:00

concept shown in this diagram. Circles

2:03

are nodes, which in this case were land,

2:05

and the black lines are edges, which are

2:07

bridges in this case, and these two

2:09

constitute a graph. So, this middle

2:11

island here has five edges, or bridges

2:14

in this case, connecting to other areas,

2:16

and so on. And given this

2:18

representation, Euler concluded with a

2:20

proof that this kind of route in

2:22

Königsberg is impossible. Now, the exact

2:25

proof that Euler proposed is sort of

2:27

irrelevant to this video, but Euler's

2:29

graph theory is now applied to agents

2:31

and graph engineering today. Here's

2:33

another way to visualize the workflow

2:35

that Claude code generated for my deep

2:37

research from earlier. This consists of

2:39

five phases. One agent for scoping the

2:42

requirement, five agents to gather

2:44

credible websites to research for each

2:46

subtopics, 25 agents to then actually

2:49

fetch the information and pass it to the

2:51

next, and 75 agents to verify the facts

2:55

and vote on the credibility, and

2:57

finally, one agent that generates the

2:59

full report in the end. And this

3:01

workflow you're seeing here is a form of

3:03

a graph. In this case, because execution

3:06

only flows from left to right, with no

3:08

node going backwards, which would form a

3:10

loop, this is called DAG, or directed

3:13

acyclic graph. Now, we could technically

3:15

do this with a single agent instead of

3:17

hundreds of agents in a graph like we

3:19

just saw earlier. But this would be a

3:21

bit silly because using a dynamic

3:23

workflow for this kind of work is better

3:25

for many reasons. The most obvious one

3:27

being time. By parallelizing task into

3:30

sub-agents that have their own small

3:32

objective, this helps save a large

3:34

amount of time by the simple fact that

3:36

multiple agents are working at the same

3:38

time. Another benefit is separation of

3:41

concerns. The fact that each agent has

3:43

its own context window helps focus its

3:45

own context window towards its goal.

3:47

Whereas a single agent might need to

3:49

keep reusing its own context to store

3:52

some of it for the goal, some of it for

3:54

the current task and keep summarizing

3:56

back and forth. But graphs aren't

3:57

without its drawbacks either. Anthropic

3:59

made a post that talked about their

4:01

multi-agent research system that said a

4:03

single agent tends to use four times

4:05

more tokens than a regular chat and a

4:07

multi-agent system tends to use 15 times

4:10

more tokens in comparison. So going back

4:12

to our example, each agent ran on Opus 5

4:16

with their own system prompt and each

4:17

agent used about 20,000 tokens by

4:20

default to start. So by the time you

4:21

extrapolate this to 108 agents that it

4:24

eventually used, the input cost alone

4:27

would be closer to $10 given Opus 5's

4:30

pricing. But since we have prompt

4:32

caching, realistically, this number will

4:34

look closer to a dollar which helps

4:36

scale our agent from a single agent to a

4:38

parallel agents like you can see here.

4:40

So given the benefits and the drawbacks

4:42

when it comes to graphs, why are

4:43

everyone talking about graph and graph

4:45

engineering as if it's the next

4:47

evolution when it comes to agentic

4:48

engineering? But first, a quick word

4:50

from Zoe sponsoring this video. It's

4:52

pretty obvious that more and more parts

4:53

of our lives are being integrated with

4:55

AI and often our interactions are

4:57

scattered across Claude, ChatGPT, Codex

5:00

and Menace. So how can we have more

5:02

ownership while having a 24/7 agent? Zoe

5:05

gives you a dedicated computer on the

5:07

cloud that's yours, meaning your agent

5:09

is on standby for anything that you

5:11

give. And part of being 24/7 is the

5:13

ability to message your agent through

5:15

text. You can directly message Zoe to

5:17

have normal conversations through

5:19

iMessage or ask about files that you

5:21

have stored on your computer in the

5:22

cloud and better yet, build an

5:24

e-commerce website for vintage watches

5:27

and host directly on Zoe using their AI

5:29

agent natively through text. What's cool

5:32

about Zoe is that you can write code and

5:33

launch sites that are actually useful

5:35

because you can integrate all your

5:37

contacts into Zoe and run automations.

5:39

Custom domains are also included at paid

5:41

plan and all your sites are hosted on

5:43

your Zoe's cloud computer. Plus they got

5:45

some neat tricks like the selector tool

5:47

to edit exact areas to improve things or

5:50

even add automations that plug into your

5:52

website, like a text anytime someone

5:54

fills out a form. Try Zo today. I'll

5:56

have the link in the description below.

5:57

The concept behind agent communicating

6:00

with another agent is not anything new.

6:02

We can look back to open-source ideas

6:03

like AutoGen in 2023 from Microsoft

6:06

talking about agents communicating with

6:08

another agent. Companies like LangChain

6:10

also started messing with cyclic graph

6:12

in 2023, which led to LangGraph, which

6:15

became a framework for orchestrating

6:17

agents. Anthropic also released various

6:19

ways that agents can work together

6:21

around the same time, like prompt

6:23

chaining where LLMs are chained

6:25

sequentially one after another, routing,

6:27

which is similar to sub-agents, but from

6:29

the perspective of the main agent,

6:31

parallelization, which is similar to our

6:33

deep research workflow, orchestrator,

6:35

also similar to what we saw earlier, and

6:37

evaluator optimizer, where two LLMs

6:40

adversarially go at each other until a

6:42

condition is met. But, none of these

6:44

were materially useful back then because

6:47

the problem wasn't so much in the graph

6:49

itself, but what the node inside of the

6:52

graph can actually do. In LangChain's

6:54

blog post talking about graph

6:55

engineering, they said that what changed

6:58

wasn't the graph, but more in what the

7:00

node can do. Back then, it was just an

7:02

LLM call, nothing close to a full agent

7:05

that we interact with every day like

7:07

Claude Code or CodeX CLI. These agents

7:09

are immensely better given their myriads

7:12

of tools and harness environment. So,

7:14

with the emergence of coding like

7:16

Cursor, Kline, Rue, and Winster, which

7:19

were one of the few early players back

7:21

then when it comes to agents, they focus

7:23

more on single agents in improving that

7:26

very agent instead of extending them to

7:29

various edges that form a graph of

7:31

agents actually working together. And

7:33

over time, these agents individually

7:35

started to incorporate better

7:37

methodologies, going from prompt

7:39

engineering to context engineering,

7:41

better harnessing, and now the

7:42

bottleneck started to shift away from

7:45

what the node can do, but into a graph

7:48

and the edges that connect the nodes

7:49

together. And now, no pun intended,

7:51

we're coming full circle back to graphs.

7:54

Because the nodes are reliable and more

7:56

capable, we can now scale our agents

7:59

from a single agent to a workflow or a

8:01

graph to target a much wider set of

8:04

problems like we saw in deep research,

8:06

which would have been really difficult

8:08

for a single agent to solve. So, going

8:10

back to Euler's case, his challenge was

8:12

to determine the feasibility of crossing

8:14

all seven bridges exactly once, which

8:17

led to the birth of graph theory. In our

8:19

case, our adaptation of graph theory

8:21

into agents is determining how a task

8:24

can be divided in a way that a highly

8:27

capable node now should structurally be

8:29

configured to solve a much more

8:31

complicated task that we give our agents

8:33

to solve.

Interactive Summary

This video explores the evolution and mechanics of agentic engineering, specifically focusing on the shift from single-agent systems to complex, multi-agent 'graph' architectures. By using Claudecode's deep research capabilities as an example, it illustrates how dynamic workflows—represented as Directed Acyclic Graphs (DAGs)—can parallelize tasks and improve efficiency through the separation of concerns. The video also traces the historical roots of graph theory back to Leonhard Euler, explains the trade-offs regarding token usage and cost, and highlights that the recent surge in graph engineering is primarily enabled by the increased capability and reliability of individual agent nodes.

Suggested questions

4 ready-made prompts