Skip to content
/
15 chapters · about 79 min · Beginner to intermediate

Agent workflows with CrewAI flow

TextView.AI
Start course

Learn to put plain Python in charge of your agents, one small idea at a time, until you have a desk that sorts documents, checks them, and asks a person before it acts.

About#

A short course on putting plain Python in charge of your agents. Each chapter teaches one idea, from the problem it solves to what happens under the hood, with a small program you can run.

The example is a small company's front desk. A contract, an invoice and an agenda come in. By the last chapter, your program sorts them, has agents read them, checks the dates and the sums in code, and asks a person before it files anything. Every output on the pages is copied from a real run.

Contents#

Code in charge

  1. 1Who decides the next stepWhat the course builds, and who should choose each step: a fixed order, the AI, or your own code, and why the desk lets its code choose.5 min
  2. 2One step after anotherBuild the contract's path as your first CrewAI flow: why a step shouldn't call the next one, and how a step can be added without changing the others.5 min
  3. 3What the steps rememberGive the desk a memory: one dictionary that every step can read, so that the check can compare the summary with the contract.5 min
  4. 4A state with rulesWrite the state as a model with a type for each field, so a misspelled name or a word where a number belongs stops the step that put it in.4 min

Paths

  1. 5Pick a pathLet one step, a router, pick the path by the kind of document, so only the steps for that kind run, and send every word it doesn't know to a person.4 min
  2. 6Paths that meetJoin the router's paths with or_(), so one step writes a report for every document, and see why it runs only for the first step to finish.4 min
  3. 7Wait for bothStart two readings together and hold the invoice check with and_() until both have finished, and see what happens when one side fails.4 min

Agents as steps

  1. 8One agent in a stepLet an agent read the invoice inside a step, ask it for a typed answer the check can use, and give that answer a way to say there is nothing to find.6 min
  2. 9A crew in a stepRun a writer and a checker as a crew inside one step, see what each one hands on, and find that a second agent is no proof of a date.6 min
  3. 10Check it in codeWork the notice deadline out in Python and check the memo against it, a check no well-argued memo can talk round.6 min

Ready for real work

  1. 11Test it without a modelPut a stand-in where the agent was, so each test picks what the agent said, and see why the swap must be made where the desk looks the name up.6 min
  2. 12Ask a person firstShow the report to a person before it is filed, let their answer pick the folder, and see why only one clear word should file it.5 min
  3. 13Pick up where it stoppedSave the state after every step with @persist, load it back by the run's id, and see why a costly step must still look in the state first.5 min
  4. 14Many documents at onceStart a run for each document with kickoff_async, wait for them together with asyncio.gather, and see why each run needs a Desk() of its own.5 min
  5. 15The whole deskPut every part together in one flow, run it on the three documents in the inbox, and see who did what: the agents read, the code checks, and a person decides.9 min

Before you start#

You need Python 3.13 and some practice in reading it. You don't need to have built an agent before. The first chapters use no model at all. Later chapters tell you when to set one up.

Questions#

Is the course finished? Not yet. It's a draft, and one chapter is added at a time.