- Practice
- About 16 min
- 5 practice questions
Workflows and memory: fixed steps, open-ended agents and what they remember
Choose between a fixed workflow and an open-ended agent, lay out steps with branches and retries, and explain short-term memory (the context window) and long-term memory (stored notes found by retrieval), keeping both accurate and private.
If something looks wrong, please tell us.
By the end of this lesson you can
- Choose between a fixed workflow and an open-ended agent for a task, and say why.
- Lay out a workflow with steps, branches and retries.
- Explain short-term and long-term memory and keep both accurate and private.
Lesson 1 showed that an agent decides its own steps. Most useful systems limit that freedom, fixing the route and letting the model decide only where judgement is needed. They also need memory. Both choices decide how reliable and safe the system is.
Fixed workflows versus open-ended agents
In a fixed workflow, the developer writes the order of steps in advance. A model may do one step, such as summarising a document or sorting an email into a category, but it does not choose what happens next. In an open-ended agent, the model decides the order of steps and which tools to use. Fixed workflows are predictable, cheaper and easier to test; open-ended agents are flexible but harder to control. A common design uses a workflow for the overall path and lets the model decide only inside one bounded step.
Fixed workflow and open-ended agent
-
Fixed workflow
- The developer writes the order of steps in advance
- A model may do one step but does not choose what happens next
- Predictable, cheaper and easier to test
-
Open-ended agent
- The model decides the order of steps and which tools to use
- Flexible
- Harder to control
Steps, branches and retries
A workflow is a series of steps. A branch is a decision point that sends work one way or another: if the email is a complaint, go to step 4; otherwise go to step 5. A retry repeats a step that failed for a temporary reason, such as a busy server - a small fixed number of times with a pause between tries, after which the workflow stops and tells a person instead of looping for ever.
Worked example 1: a small office inbox
- Fetch new emails from the general inbox (read-only tool).
- The model sorts each email: complaint, information request or other.
- Branch: complaint goes to step 4; information request goes to step 5; other is moved to a folder for staff.
- Create an entry in the complaint register (write tool). If the register does not respond, retry up to three times, two minutes apart; then alert the supervisor.
- Draft a reply from the office's approved answers and save it; a staff member reviews it before it is sent.
The model makes one judgement (the category) and drafts text; every other step is fixed. A wrong category does limited, visible damage, because a person sees the drafts and the 'other' folder. Note also the arithmetic of the retry rule: one first attempt plus three retries means at most four attempts, spread over about six minutes of waiting, before a person is told.
Short-term memory: the context window
A language model does not remember earlier conversations on its own. Everything it can consider at one moment - its instructions, the conversation so far and tool results - must fit in its context window, a limited amount of text measured in tokens (pieces of words). This is the agent's short-term memory. In a long task, tool results pile up; when the window fills, older material has to be dropped or summarised, and the agent can lose an instruction given at the start. Good designs keep the context lean: pass only what the current step needs and restate the key rules.
Long-term memory: stored notes and retrieval
For anything that must last beyond one task, the software saves notes to a file or database - an approved reply template, a past decision, a user's chosen language. When a later task needs them, the software searches the store and places only the few relevant entries into the context window. This is called retrieval; when retrieved documents are used to ground a model's answer it is often called retrieval-augmented generation (RAG). Search can match keywords, or use embeddings - lists of numbers that capture meaning - to find passages that mean the same even when the words differ.
Long-term memory and retrieval
- Save notes To a file or database.
- Search the store When a later task needs them, by keywords or embeddings.
- Bring back the relevant few Only those entries go into the context window.
| Memory | Where it lives | How long it lasts | Example |
|---|---|---|---|
| Short-term | The context window | The current task only | Tool results from the last few steps |
| Long-term | A file or database, searched when needed | Until updated or deleted | Approved reply templates; earlier decisions |
Worked example 2: a stale note
A student-help agent at a coaching centre is asked, 'When is the next mock test?' It retrieves a note saved three weeks ago: 'Next mock test: Sunday, 10 am.' That test has already taken place, so the answer is wrong though it sounds confident. Better design: each note records its source and the date it was written; for anything that changes, such as a timetable, the agent reads the live timetable through a tool instead of trusting memory; and notes expire after a set time. Memory is only as accurate as its last update.
Keeping memory accurate and private
- Record where each note came from and when; prefer the live source whenever one exists.
- Let people see, correct and delete what is stored about them.
- Store the minimum: never passwords, OTPs, Aadhaar numbers or bank details, and personal data only when the purpose needs it and the law and office policy allow it.
- Keep each person's notes separate, so one user's notes are never retrieved into another user's conversation.
- Delete notes that are no longer needed.
Short-term memory = what fits in the context window now. Long-term memory = stored notes, searched and brought back only when relevant (retrieval).
Key takeaways: fix the route where you can and let the model judge only where needed; use branches for decisions and limited retries for temporary failures. Short-term memory is the context window and fills up; long-term memory is a searched store whose notes need sources, dates, expiry and strict privacy.
Check your understanding
-
1. In which design does the AI model decide the order of steps and which tools to use?
- A fixed workflow
- A nightly backup script
- A printed office checklist
- An open-ended agent
Show answer
Answer: D. In an open-ended agent the model chooses the steps and tools while running. In a fixed workflow or script the order is written in advance.
-
2. A step that uploads a file fails because the server is briefly busy. What is the sensible design?
- Retry for ever until it works
- Retry a small fixed number of times with a pause, then stop and alert a person
- Skip the step silently and report success
- Delete the file and restart the whole workflow
Show answer
Answer: B. Temporary failures deserve a few spaced retries, but an endless loop wastes resources and hides the problem. After the limit, a person must be told.
-
3. What is an agent's short-term memory?
- The context window - the text the model can take into account at one moment
- A database of notes kept for months
- The hard disk of the user's computer
- The data the model was originally trained on
Show answer
Answer: A. Everything the model considers right now - instructions, conversation, tool results - must fit in the context window. Stored notes are long-term memory, and training data is not memory of your task.
-
4. An agent retrieves a three-week-old note saying the mock test is on Sunday, but that test has already taken place. What would best prevent this?
- Making the context window larger
- Storing more notes about each student
- Recording each note's source and date, reading the live timetable for changing facts, and expiring old notes
- Asking the model to sound more confident
Show answer
Answer: C. The problem is a stale note, not a lack of space. Dating notes, preferring the live source and expiring old entries keep memory accurate.
-
5. Which item should never be stored in an agent's long-term memory?
- The office's approved template for replying to fee-receipt requests
- The date on which a note was written
- The name of the document a note came from
- A user's OTP or bank password
Show answer
Answer: D. Secrets such as OTPs and passwords must never be stored or shown to an AI system. Templates, dates and sources are exactly what good memory should keep.
Sign in to keep track of the lessons you finish.