All of us do it naturally and repeatedly. In my private life, I usually create to-do lists to arrange holidays, errands, and many others.
At work, we depend on process trackers and venture plans to maintain our groups aligned. Retirement can also be frequent for builders TODO Feedback within the code can be utilized as reminders for future modifications.
Naturally, LLM brokers additionally profit from a transparent to-do record to information their planning.
To-do lists assist brokers plan and monitor advanced duties extra successfully, and are particularly helpful when coordinating a number of instruments or working over lengthy durations of time when it is advisable to visually see progress.
like a coding agent OpenAI Codex, Kleinand claude code (which I exploit repeatedly) is a major instance of this idea.
Break down advanced requests right into a collection of preliminary steps, arrange them as to-do lists with dependencies, and replace the plan in real-time as duties are accomplished or new info arises.
This readability permits brokers to deal with lengthy sequences of actions, coordinate throughout totally different instruments, and monitor progress in an easy-to-understand means.
This text particulars how brokers make the most of the to-do record performance, analyzes the underlying parts of the planning course of, and demonstrates its implementation utilizing LangChain.
content material
(1) Planning agent scenario example
(2) Key components of the Tasks feature
(3) Organize into middleware
The accompanying code is on the market at: This GitHub repository.
(1) Planning agent state of affairs instance
Let’s check out an instance state of affairs that may type the idea of the tutorial.
Arrange. single agent Plan your journey itinerary and carry out reserving duties. Brokers can entry:
On this instance, these instruments are simulated and no precise reservations are carried out. They’re included to elucidate the agent’s planning logic and methods to use to-do lists.
Right here is the code to implement this planning agent Within the rung chain:
Enter consumer queries and examine to-do lists from agent plans.

Structured note-taking with to-do lists permits brokers to keep up persistent reminiscence exterior of the context window. This technique improves the agent’s skill to handle and retain related context over time.
Organising the code is simple. create_agent Create an LLM agent occasion. Go to the system immediate and choose the mannequin (GPT-5.1), hyperlink instruments.
It ought to be famous that TodoListMiddleware() object handed to middleware Parameter.
First, what’s LangChain? middleware?
Because the title suggests, it is a center layer that lets you run customized code earlier than and after the LLM name.
Consider middleware as a programmable layer that lets you insert code to watch, alter, and prolong its conduct.
This lets you management and visualize agent conduct with out altering the agent’s core logic. You should utilize it to rework prompts and output, handle retries or early termination, and apply safeguards (guardrails, PII checks, and many others.).
TodoListMiddleware is a built-in middleware that particularly supplies to-do record administration performance for brokers. Then how TodoListMiddleware Works below the hood.
(2) Foremost parts of the To-Do perform
The planning agent’s to-do record administration options may be summarized as follows: 4 foremost parts:
- To-do process merchandise
- record of issues to do
- Instruments to create and replace to-do lists
- Up to date to-do system prompts
of TodoListMiddleware Combine these parts to allow agent to-do record performance.
Let’s take a better take a look at every element and the way it’s carried out. ToDo middleware code.
(2.1) ToDo process merchandise
A to-do merchandise is the smallest unit on a to-do record and represents a single process. That is represented by two fields: process description and present standing.
In LangChain, that is modeled as follows. Todo sort, outlined utilizing TypedDict:
of content material The sphere represents an outline of the duty that the agent should carry out subsequent. standing Observe whether or not a process has not been began (pending), we’re engaged on (in_progress), or finish (accomplished).
Right here is an instance of a to-do merchandise:
{
"content material": "Examine flight choices from Singapore to Tokyo",
"standing": "accomplished"
},
(2.2) ToDo record
Since now we have outlined the construction of Todo Gadgets explores how a set of to-do objects is saved and tracked as a part of an general plan.
Outline. State Object (PlanningState) plan record Listing of to-do objects up to date as duties are carried out:
of todos The sphere is non-compulsory (NotRequired), which implies that it could not exist when it’s first initialized (i.e., the agent’s plan might not but comprise the duty).
OmitFromInput Which means todos is managed internally by the middleware and shouldn’t be offered instantly as consumer enter.
State is an agent’s short-term reminiscence that captures latest conversations and essential info and permits it to behave appropriately primarily based on earlier context and knowledge.
On this case, the to-do record stays accessible for brokers to view and replace duties constantly all through the session.
Right here is an instance of a to-do record:
todos: record[Todo] = [
{
"content": "Research visa requirements for Singapore passport holders visiting Japan",
"status": "completed"
},
{
"content": "Compare flight options from Singapore to Tokyo",
"status": "in_progress"
},
{
"content": "Book flights and hotels once itinerary is finalized",
"status": "pending"
}
]
(2.3) Instruments to create and replace To-Dos
Now that the essential construction of the to-do record is established, the LLM agent wants a instrument to handle and replace it as duties are carried out.
The usual strategy to outline a instrument is as follows (write_todos):
of write_todos The instrument is Command This instructs the agent to replace the to-do record and add a message to document the change.
alternatively, write_todos The construction is easy, however the magic is within the clarification (WRITE_TODOS_TOOL_DESCRIPTION) of instruments.
When an agent invokes a instrument, the instrument description serves as an essential further immediate. We are going to information you on the right utilization and inputs to offer.
Beneath is a (fairly lengthy) rendition of the instrument description by LangChain.
You’ll find that the directions are extremely structured and exact, defining how and when to make use of the instrument, process states, and administration guidelines.
It additionally supplies clear pointers for monitoring advanced duties, breaking them down into clear steps, and updating them systematically.
Remember to take a look at Deepagents’ extra concise interpretation of the ToDo instrument description. here
(2.4) System immediate replace
The ultimate ingredient of configuring To Do performance is updating the agent’s system prompts.
It’s performed by injecting WRITE_TODOS_SYSTEM_PROMPT On the foremost immediate, explicitly inform the agent that: write_todos Instruments exist.
information the agent When and why to make use of instrumentssupplies context for advanced multi-step duties and descriptions finest practices for sustaining and updating to-do lists.
(3) Arrange into middleware
Lastly, all 4 main parts are mixed into one class. TodoListMiddlewareThis packages to-do performance right into a constant circulation for brokers.
- outline
PlanningStateObserve duties as a part of your to-do record - Create dynamically
write_todosInstruments to replace the record and make it accessible from LLM - inject
WRITE_TODOS_SYSTEM_PROMPTTo information agent planning and reasoning
of WRITE_TODOS_SYSTEM_PROMPT injected by way of middleware wrap_model_call (and awrap_model_call) methodology might be added to the agent’s system messages on every mannequin name, as proven under.
put it collectively
Identical to people, brokers use to-do lists to interrupt down advanced issues, keep organized, and adapt in actual time to resolve issues extra successfully and precisely.
Via LangChain’s middleware implementation, we additionally achieve deeper perception into how deliberate duties are constructed, tracked, and executed by brokers.
take a look at This GitHub repository For code implementation.

