Loading video...

Video Failed to Load

Go Home

don't use loops, design state machines

221,789 views • 3 months ago •via X (Twitter)

60 Comments

David's profile picture
David3 months ago

do this today at

David K 🎹's profile picture
David K 🎹3 months ago

What does the state machine for this example look like?

David's profile picture
David3 months ago

My version actually don't use a full deterministic state machine, I want to keep the flexibility of AI with minimal guardrails:

Ilko Kacharov's profile picture
Ilko Kacharov3 months ago

Hot take: it's not loops vs state machines, it's both. The state machine defines what "done" looks like; the loop is the engine that grinds until it gets there. No loop = agent stalls mid-task. No state machine = it loops forever toward nothing. Winners design both.

David's profile picture
David3 months ago

Agreed, but that's not catchy and doesn't go viral 😂

Brian Via's profile picture
Brian Via3 months ago

We’re inventing computer science from first principles

David's profile picture
David3 months ago

😂 just slowly moving up the ladder of abstraction

David's profile picture
David3 months ago

A loop is just a state machine with 2 states 😅

David's profile picture
David3 months ago

😂

patark's profile picture
patark3 months ago

sir this is a kanban board /s

duet's profile picture
duet3 months ago

🪩🪩🪩

Daniel's profile picture
Daniel3 months ago

🤯🤯🤯this looks insanely powerful! 2026 -- what a year 🚀🚀 reworking stack for 3rd time in 10 days 😵‍💫

David's profile picture
David3 months ago

Give it a try at and tell me how it goes! Happy to give you some free credits :)

Jason Szesze's profile picture
Jason Szesze3 months ago

Sweet @duetchat

David's profile picture
David3 months ago

@duetchat Niceeeee

Mustafa Kirac's profile picture
Mustafa Kirac3 months ago

It's n8n all over again 🤔

David's profile picture
David3 months ago

Na, it's not a workflow engine actually, it's just the bare minimum guardrails. All workflow logic is done by agent / codegen

Sense Noped Out's profile picture
Sense Noped Out3 months ago

this is what he meant. same same

David's profile picture
David3 months ago

yup agreed. just adding a tangible example

Rob Schaper's profile picture
Rob Schaper3 months ago

State machines can be designed to run in a loop, they can also act like a DAG with an outcome certain. For example, you can have four state machines in a loop, made of four DAGs, each run updates an S3 bucket, which has a trigger to run the next state machine, etc... Cheers.

Relex Legal's profile picture
Relex Legal3 months ago

Each state should be a loop until successfully state changed

David's profile picture
David3 months ago

@relexyou Yup, our custom harness has this guarantee

Rick Wong's profile picture
Rick Wong3 months ago

State machines and workflows are amazing, but do you think humans should spend time focusing on those, or do you see a trajectory where the models are advance enough to manage both of those internally? Older solutions like zapier/make.com/n8n were heavy on workflows/states, but many realized how adept the models are becoming at managing those things internally. If you look at the design of claude's /workflow, you'll see it is actually far from what most people consider "workflow" -- they leap frogged quite a few steps ahead.

Mek's profile picture
Mek3 months ago

Claude Fable 5? Please add it to the platform as soon as possible.

David's profile picture
David3 months ago

On it 🫡

David's profile picture
David3 months ago

FYI: you may need to wait a bit for everyone's sandbox to get upgraded. If you're impatient, feel free to go into the files tab and click on "Reboot gateway". Just note that it'll terminate all currently running sessions if you do that.

Kenn's profile picture
Kenn3 months ago

Would love to give it a try

David's profile picture
David3 months ago

Nice, sign up at and shoot me a DM if you want more free credits

Shaun Sheikh's profile picture
Shaun Sheikh3 months ago

Very cool

David's profile picture
David3 months ago

Thanks! Give it a try at :)

Enterprise Software Architecture's profile picture
Enterprise Software Architecture3 months ago

👀 I’ve already ascended to recursive state-loop machines by design.

Will's profile picture
Will3 months ago

Don't design state machines, build hyper structures

Farshad Taheri's profile picture
Farshad Taheri3 months ago

Yea, this been there for sometimes and not working plus too slow

David's profile picture
David3 months ago

What do you mean?

Farshad Taheri's profile picture
Farshad Taheri3 months ago

Have you used it for any actual/real complex workflow?

D's profile picture
D3 months ago

how's duet make money? bulk token arb?

David's profile picture
David3 months ago

we run our own inference stack for certain models

D's profile picture
D3 months ago

Ah yes, got it. Thx!

Manas's profile picture
Manas3 months ago

Aight we are back to langgraph great 😭

David's profile picture
David3 months ago

Very different, it's not a workflow engine

Felipe's profile picture
Felipe3 months ago

We have the same but we used coder and n8n to integrate with linear is Duet a platform by itself? Like, could linear, clickup or others platforms have the same features as u guys?

David's profile picture
David3 months ago

Yup @duetchat is its own platform And it's fundamentally different than linear/clickup. In duet the kanban view is just treated as a way to visualize all your agents, as a user you don't actually interact with the cards, and that's by design The problem we are solving isn't better project management, but how can we deploy 00s of agents and actually track & steer them. Right now it's kanban, in 6 months maybe something else

Felipe's profile picture
Felipe3 months ago

@duetchat I see that, I mean we have the same, but "in-house implementation", linear is just because it's what we used before You can see we have the plan, plan approval, review approval etc... that u also have related states, on your kanban on the video Here it's using n8n for the flow

Felipe's profile picture
Felipe3 months ago

@duetchat U guys don't see your product "benefiting" from being something that can integrate with a existing linear/clickup/jira etc...? Like, stack can integrate with your codebase, but also be seen from clickup if you do something with n8n as well; Like "integrate Duet" on your workflow

Aleksandr Fulha's profile picture
Aleksandr Fulha3 months ago

state machines ARE loops with transition contracts. paperclip handoff: each agent's exit state is typed, next agent's entry matched. break-on-mismatch instead of run-on-pattern. the loop still runs — the contract just keeps it honest about what it's passing forward.

Scott Evernden's profile picture
Scott Evernden3 months ago

tomorrow .. "we learn about arrays"

David's profile picture
David3 months ago

😂😂

Duncan's profile picture
Duncan3 months ago

Excellent callout :)

SurfboardRSS's profile picture
SurfboardRSS3 months ago

This is the way

kreo's profile picture
kreo3 months ago

i like your thinking young man

David's profile picture
David3 months ago

🫡

0xA's profile picture
0xA3 months ago

Don’t use state machines. Design coinductive coalgebras over Cartesian closed categories.

SAWC || CS STUDENT's profile picture
SAWC || CS STUDENT3 months ago

What does this entail?

David's profile picture
David3 months ago

just sign up for @duetchat -

Michael Gustin's profile picture
Michael Gustin3 months ago

What the fuck does that mean Kobe Bryant

David's profile picture
David3 months ago

are you the same animal but a different beast?

Walter Monecke's profile picture
Walter Monecke3 months ago

this looks amazing!

Divya Soni's profile picture
Divya Soni3 months ago

Making probabilistic machines deterministic. We've come a full circle here

David's profile picture
David3 months ago

Deterministic orchestration probabilistic execution Also - my state machine implementation isn't fully deterministic. Guardrail only enforces correct states, orchestrator agent can transition to any state it wants

Eray's profile picture
Eray3 months ago

don’t use loops. design a fault-tolerant replicated giant atomic state machine. @toly

Related Videos