How I Ended Up Using a DAG for Z3phyr
How I Ended Up Using a DAG for Z3phyr
When I started building Z3phyr, I wasn’t thinking about DAGs.
Honestly, I didn’t even know what a DAG was.
I just wanted my agent to be able to take a task, break it down, use its tools, and get the work done.
After getting the agent to a point where I could properly test it with real task runs, I started noticing another problem.
It was taking too long.
The problem showed up during testing
I gave Z3phyr a series of tasks and let it work through them.
Some of the time was obviously affected by network issues, model response times, and other things outside the actual execution logic.
But even with those things considered, the agent was still taking a long time to finish some tasks.
One run took around three hours.
That made me look at what was actually happening during execution.
And I noticed something.
Not every task needed to wait for the previous task to finish.
Some tasks were completely independent.
But my execution flow was treating them like one long sequence.
Something like:
Task A ↓ Task B ↓ Task C ↓ Task D
Even when B and C could have been happening at the same time.
That was the part I wanted to change.
I wanted the agent to work smarter
Imagine an agent gets a task that requires it to:
- Search for information
- Inspect some files
- Analyse another source
- Then combine everything into a result
There isn’t necessarily a reason for every step to happen one after another.
It could be closer to:
text┌→ Search │
Task ─────┼→ Inspect files │ └→ Analyse source ↓ Combine
The independent work can happen separately.
Then the final step waits for the information it actually needs.
That seemed like a much better way for Z3phyr to handle complex tasks.
I started researching how other systems handle this
I knew what I wanted conceptually:
If two pieces of work don’t depend on each other, let them run independently.
I just didn’t have a name for the architecture.
So I started researching ways to structure task dependencies and parallel execution.
That’s when I came across DAGs.
DAG stands for Directed Acyclic Graph.
In simple terms, it’s a way of representing work as connected steps where some steps depend on others.
For example:
textTask / \ ↓ ↓
Task Task \ / ↓ ↓ Result
The important part for what I was building was the dependency between those steps.
If two tasks don’t depend on each other, they don’t necessarily need to wait for each other.
Then I realized something funny
While reading about DAGs, I started comparing the concept to what I had already built.
And I realized:
I was already doing something similar.
I just didn’t know it was called a DAG.
I had already been thinking about tasks as individual pieces of work and connecting them based on what needed to happen before something else could run.
I basically stumbled into the concept while trying to solve a completely different problem.
That was probably my favorite part of the whole thing.
It reminded me that sometimes you don’t need to know the name of an architecture before you can start discovering why it is useful.
What this changed in Z3phyr
The main thing I wanted was simple:
Don’t make independent work wait unnecessarily.
Instead of forcing everything into one sequence, I could represent the work more like:
text┌→ Task B ──┐
Task A ───────┤ ├→ Task D └→ Task C ──┘
Task B and Task C can work independently.
Task D waits until it has what it needs.
That’s the basic idea I’m using.
I’m not trying to build some massive workflow engine.
I’m just giving Z3phyr a better way to understand which pieces of work depend on each other.
Why this matters for an AI agent
This became especially interesting because agents naturally create multi-step work.
A user might ask:
“Research these companies, check their websites, compare their products, and give me a summary.”
That’s not necessarily one task.
It’s a collection of smaller tasks.
Some depend on previous results.
Others don’t.
If the agent treats everything as one long chain, it can waste a lot of time waiting.
If it understands the dependencies, it has more opportunities to work on independent tasks at the same time.
That doesn’t automatically make everything fast.
You still have things like network latency, model latency, rate limits, tool execution time, and failures.
But at least the architecture isn’t unnecessarily forcing independent work to happen sequentially.
I’m still keeping it simple
I don’t want to over-engineer this.
Z3phyr is still an experimental project, and I’m using it to learn what actually matters when building agents.
So for now, I’m mainly interested in the basics:
- Breaking work into tasks
- Understanding dependencies
- Running independent work separately
- Waiting when a dependency is required
- Combining the results
There’s a lot more that could eventually be built around this idea.
Retries.
Cancellation.
Better failure handling.
Persistent execution.
More advanced scheduling.
But I’m not trying to solve all of that right now.
The funny thing about learning while building
One of the reasons I like building Z3phyr this way is that I keep running into concepts naturally.
I didn’t start this project thinking:
“Today I’m going to implement a DAG.”
I started with:
“Why is my agent taking so long to finish this task?”
That led to:
“Some of these tasks can run independently.”
Which led to:
“There has to be a better way to represent these dependencies.”
Which eventually led me to:
“Oh… this is basically a DAG.”
That progression is probably more valuable to me than simply learning the definition first.
I got to the concept because I had a problem that needed it.
And that’s one of the main reasons I’m building Z3phyr in the first place.
I’m learning AI engineering by actually running into the problems that AI applications create.