Diagrid

The Evolution of AI Agents · Chapter 2 of 7 · Stage 2 — The Windows message loop · 1980s–1990s

The Windows Message Loop: How Applications Became Reactive

Mark Fussell

Mark Fussell

Co-Founder & CPO, Diagrid · September 3, 2026

The Windows message loop at a glance · 1980s–1990s

What owns the control flow
The operating system
What it added
Long-lived, reactive processes driven by unpredictable external events
What it could not do
Advance anything on its own - no message meant no progress
Agent equivalent
An event-triggered agent that wakes on a webhook and goes back to sleep

Back to the 80s. Windows and the Message Loop

One of the classic examples is the Windows message loop. As a Windows 3.0 developer in the early nineties, this became embedded in my psyche. A Windows GUI application did not simply draw a window and then continue through a predefined series of instructions. It had to remain alive while the operating system delivered messages such as mouse clicks, key presses, resize events, repaint requests, timers, and shutdown notifications.

The classic code looked roughly like this:

while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}

Your application waits for a message, Windows dispatches that message into the relevant application handler, the application does some work, and then control returns to the loop. Conceptually:

The Windows message loop: the operating system message queue delivers user input to the application, the application handles it, and control returns to the loop.
The Windows message loop: the operating system message queue delivers user input to the application, the application handles it, and control returns to the loop.

What changed here was not merely the presence of a while statement. The deeper change was that the program stopped owning the entire execution lifecycle. Windows owned the outer loop, while the application supplied behavior that ran inside it. The application was now long-lived, reactive, and dependent on events it could not predict in advance. That was a very different way of thinking about execution.

Why this matters if you are building agents

This is where event-driven programming enters the mainstream, and the inversion it introduced never left. Look at any modern agent SDK and you will find the same shape: you do not write the loop; you register tools, handlers and a system prompt, and a long-lived process owned by a runtime calls them. The vocabulary changed - DispatchMessage became execute_tool - but the inversion of control did not.

The unresolved question the message loop leaves behind is the one this series is heading toward: if the runtime owns the loop, what happens to the work in flight when the runtime dies?

Frequently asked questions

About the author

Mark Fussell — Co-founder and Chief Product Officer of Diagrid and co-creator of Dapr. He was a Windows 3.0 developer in the early nineties — the message loop in Chapter 2 is his, not a history lesson — and has spent the three decades since on distributed systems, most recently making them durable for agents.

LinkedIn

Read next

Chapter 3 moves to the 1990s games industry, where the loop stopped waiting for permission to advance - and started carrying state forward.

Chapter 3: The game loop

All seven chapters are live.

Read The Evolution of AI Agents end to end, or get the next special project when it ships.