Entry · Ref 1AVUHADM
How state graphs, memory, and delegation shape agent workflow design
- Posted
- 2026-11-14
- Last amended
- 2026-11-14
- Account
- @theruntimejournal
When engineers build autonomous systems that carry out multi-step tasks, they quickly discover that raw language model calls are not enough. A single prompt can answer a question, but a system that browses a website, cross-references a database, and books a resource must keep track of where it is, what it has done, and what to do next. This is where agent workflow design becomes the deciding factor between a prototype that works once and a production system that reliably completes real-world jobs.
Three ideas sit at the core of modern agent workflow design: state graphs, memory, and delegation. Each solves a distinct problem, and together they let an agent maintain context, adapt to new information, and hand off sub-tasks to specialist tools or sub-agents. Understanding how they fit together helps architects avoid the brittleness that plagues naive prompt-chaining approaches.
State graphs give the agent a map of its own progress
A state graph is a directed graph whose nodes represent distinct states an agent can be in and whose edges represent transitions triggered by events or decisions. Instead of a linear script that runs from top to bottom, the agent consults the graph to decide what to do next based on its current state and the input it receives.
For example, an agent handling a customer support ticket might start in a "receive request" state. After parsing the message, it transitions to "classify issue". From there it may go to "look up account" or "escalate to human", depending on the classification. Each transition can carry preconditions and postconditions that the agent checks before moving.
This structure brings several benefits. First, it makes the agent's behaviour predictable and testable. You can enumerate all reachable states and verify that no dead ends exist. Second, it allows the agent to recover from partial failures. If a sub-task times out, the graph can define a transition back to a previous state with a retry counter. Third, it separates the control flow logic from the language model call. The model generates the content or the decision, but the graph governs the structure.
In practice, state graphs are often defined as JSON or YAML schemas that a lightweight runtime interprets. The runtime loads the graph, maintains the current state, and feeds the relevant context to the language model at each step. This keeps the agent's logic inspectable and version-controllable, unlike a monolithic chain of prompts.
Memory bridges the gap between stateless calls and persistent context
Language models are stateless by design. Each call sees only the text you send it. An agent that works across minutes or hours needs some form of memory to remember earlier steps, user preferences, or intermediate results.
Memory in agent workflow design usually takes two forms: short-term and long-term. Short-term memory holds the conversation history or the current task's context window. It is automatically managed by the agent framework and is often limited by the model's token budget. Long-term memory stores information across sessions. It might be a vector database that indexes past interactions, a key-value store for user settings, or a simple SQL table that records completed actions.
The challenge is deciding what to remember and what to discard. Storing everything bloats the context and raises costs. Forgetting too much forces the agent to re-request information from the user. Good memory design uses summarisation: after a long exchange, the agent writes a concise summary of the conversation and stores it, then loads only that summary on the next interaction. This keeps the context compact while preserving the gist of earlier work.
Another pattern is episodic memory, where the agent records a sequence of events with timestamps. When it later encounters a similar situation, it can retrieve a relevant past episode and adapt its behaviour. This is especially useful for agents that perform repetitive tasks with slight variations, such as data entry or report generation.
Delegation lets the agent compose specialised skills
No single language model or tool does everything well. Delegation is the mechanism by which an agent hands off a sub-task to a more capable system, a specialised API, or another agent. The calling agent defines the sub-task, passes the necessary context, and receives the result. It does not micromanage the sub-task's internal steps.
Delegation can happen at several levels. At the simplest level, an agent calls a tool function, such as a calculator or a web search API. The tool is deterministic and returns a structured result. At a higher level, an agent might delegate to a sub-agent that runs its own state graph. The sub-agent operates independently and reports back. This hierarchical decomposition mirrors how human teams work: a project lead assigns a piece of work to a specialist and trusts that person to deliver it.
One common pattern is the supervisor agent, which oversees several worker agents. The supervisor holds the high-level plan, breaks it into sub-goals, and delegates each sub-goal to a worker. The worker may itself be a supervisor for further delegation. This pattern scales well because each agent keeps its context focused on its own scope.
Another pattern is the marketplace model, where an agent announces a task and multiple candidate agents bid to handle it. The bidding includes their confidence, cost, or turnaround time. The delegating agent picks the best offer. This is useful in systems where agents have different capabilities and the optimal choice depends on the current load.
A well-designed delegation system includes timeouts, fallback strategies, and result validation. If a sub-agent fails to respond, the delegating agent can retry, escalate, or try a different sub-agent. Without these guards, a single hung sub-agent stalls the entire workflow.
Bringing the three together
The real power of agent workflow design emerges when state graphs, memory, and delegation work together. The state graph provides the skeleton. Memory provides the context that each state needs. Delegation provides the muscles that carry out the work.
Consider an agent that researches a topic and generates a report. The state graph defines phases: "gather sources", "extract key points", "draft sections", "review coherence", "format output". In the "gather sources" state, the agent delegates web searches to a sub-agent specialised in querying search APIs. In the "extract key points" state, it uses short-term memory to hold the source texts and long-term memory to store extracted facts in a structured table. If the "draft sections" state produces text that fails a coherence check, the graph transitions back to "gather sources" with a note to find additional supporting material.
This structure makes the agent debuggable. When something goes wrong, you can inspect the state history, see what memory was loaded, and trace which delegation returned a faulty result. You can also modify a single part without rewriting the whole system. Change the delegation target for web searches, and the rest of the agent remains unchanged.
Futurestack.online autonomous AI agents exemplify this kind of modular architecture. Their workflow design separates the control logic from the model calls, uses persistent memory to maintain context across interactions, and delegates sub-tasks to specialised components. This approach reduces the risk of cascading errors and makes the system easier to extend as new tools become available.
Practical considerations for architects
Building an agent with these patterns requires careful thought about coupling. If the state graph embeds too much domain logic, it becomes hard to reuse across tasks. If memory is too tightly coupled to a specific model's tokeniser, swapping models becomes painful. If delegation relies on a fixed set of sub-agents, adding new capabilities means rewriting the delegation logic.
A good heuristic is to treat each component as an independent service. The state graph runtime communicates with the memory service via a defined API. The delegation layer uses a registry of available tools and sub-agents. This way, you can upgrade the memory backend from a vector database to a relational store without touching the graph logic.
Another consideration is observability. Agents that run unattended need logging at every transition: what state was entered, what memory was read or written, what delegation was attempted and its outcome. This trace becomes invaluable for debugging and for auditing the agent's decisions. It also helps with compliance in regulated environments where you must explain why the agent took a particular action.
Finally, testability improves when you can simulate the state graph without calling a language model. Write unit tests that assert that given a certain state and input, the correct transition occurs. Then write integration tests that use a real model but stub the delegation targets. This layered testing catches structural bugs before they interact with unpredictable model outputs.
Futurestack.online autonomous AI agents show how these patterns work in practice. Their design treats the agent as a composed system rather than a monolithic prompt, which aligns with the principles of distributed systems engineering that the site covers. By separating concerns and making each piece testable, the architecture supports both rapid iteration and long-term maintainability.
The road ahead
Agent workflow design is still a young field. The patterns described here will evolve as models become cheaper and more capable. State graphs may give way to learned policies that adapt the graph structure itself. Memory may move toward learned retrieval that selects the most relevant facts without explicit summarisation. Delegation may become market-driven, with agents negotiating sub-task assignments in real time.
For now, the combination of state graphs, memory, and delegation offers a practical foundation. It gives engineers a clear vocabulary for talking about agent behaviour and a set of tools for building systems that are reliable enough to trust with real work. As the field matures, these ideas will likely become the standard idioms of the discipline, much as event loops and callbacks became standard in event-driven programming.
Futurestack.online on social media
Instagram