Workflows

Workflows are systems that execute tool calls in a sequence

Workflows execute predefined sequences of tool calls with LLM-driven decision making. Use the workflow_agent agent type for structured, sequential processes where you need deterministic execution paths.

Workflows are stateless by default but can branch and make decisions based on tool outputs and LLM reasoning.

Agents vs Workflows

Agents are autonomous systems that decide what tools to call and when, based on goals and context.

Workflows are predefined sequences where the LLM follows structured paths (for example, start with tool A, then call either tool B or tool C), making decisions within defined branching points.

The definition between an agent and a workflow is not always clear and each can have various overlapping levels of autonomy: workflows can be made more autonomous by structuring the decision points to be highly general, and agents can be made more deterministic by adding tool rules to constrain their behavior.

Workflows vs Tool Rules

An alternative to workflows is using autonomous agents (MemGPT, ReAct, Sleep-time) with tool rules to constrain behavior.

Use the workflow architecture when:

  • You have an existing workflow to implement in Letta (e.g., moving from n8n, LangGraph, or another workflow builder)
  • You need strict sequential execution with minimal autonomy

Use tool rules (on top of other agent architectures) when:

  • You want more autonomous behavior, but with certain guardrails
  • Your task requires adaptive decision making (tool sequences are hard to predict)
  • You want to have the flexibility (as a developer) to adapt the level of autonomy (for example, reducing constraints as the underlying LLMs improve)

Creating Workflows

Workflows are created using the workflow_agent agent type. By default, there are no constraints on the sequence of tool calls that can be made: to add constraints and build a “graph”, you can use the tool_rules parameter to add tool rules to the agent.

For example, in the following code snippet, we are creating a workflow agent that can call the web_search tool, and then call either the send_email or create_report tool, based on the LLM’s reasoning.

1from letta_client import Letta
2
3client = Letta(token="LETTA_API_KEY")
4
5# create the workflow agent with tool rules
6agent = client.agents.create(
7 agent_type="workflow_agent",
8 model="openai/gpt-4.1",
9 embedding="openai/text-embedding-3-small",
10 tools=["web_search", "send_email", "create_report"],
11 tool_rules=[
12 {
13 "tool_name": "web_search",
14 "type": "run_first"
15 },
16 {
17 "tool_name": "web_search",
18 "type": "constrain_child_tools",
19 "children": ["send_email", "create_report"]
20 },
21 {
22 "tool_name": "send_email",
23 "type": "exit_loop"
24 },
25 {
26 "tool_name": "create_report",
27 "type": "exit_loop"
28 }
29 ]
30)