CrewAI Flows: Deterministic Control with Branching, Retries, and Shared State
Advanced · 30 minutes · 5 tasks, checked automatically · 100 points
In this advanced lab you will build a CrewAI Flow that wraps a real crew inside deterministic Python control logic. You will implement branching between flow steps based on crew output, automatic retries when a step produces a bad result, and shared state that persists across every step of the flow. By the end you will have a production-style pattern for making agentic pipelines reliable and inspectable — without relying on a frontier model.
What you’ll learn
- Install CrewAI and verify the local qwen2.5:3b sandbox is reachable from the toolbox container
- Define a typed FlowState Pydantic model that carries attempt count, crew output, and a status flag across all flow steps
- Build a Flow with @start, @router, and @listen steps that branch on crew success/failure and retry a failing step up to three times before writing a final report
How this lab works
- Start the lab: One click starts a sandbox with a local model and the agent’s toolbox: no API key and no token bill.
- Work through 5 tasks: Each task says what to build or fix. You do it yourself, in a real terminal, with hints when you get stuck.
- Check your work: Check my work inspects the agent, its config and its output, and says what passed and what to fix.
- Finish and keep going: 100 points, your progress saved, and the next lab to try.
What it runs on
- Runs: Locally, against a model on your computer: no API key, no tokens
- Model: qwen2.5:3b
- Open source: github.com/crewAIInc/crewAI
What you need
- A free LearnXops account
- The LearnXops desktop app for macOS, Windows or Linux
- Docker Desktop (or Podman / Rancher Desktop) installed and running
- A model sandbox started in the Agent Playground
Topics: crewai, flows, deterministic-control, branching, retry, shared-state, pydantic, local-llm, qwen2.5, automation
Create a free account to start this lab.
Keep going
- Autonomous File Triage & Daily Digest with OpenClaw
- Drive a Codebase with Hermes: ripgrep Search, Multi-File Edits, and Running the Test Suite from the Agent Loop
- Build a Research-and-Write Crew with Local Documents
- Cyclic Self-Correcting LangGraph: Generate, Critique, Revise with Loop Guard
- Self-Correcting LangGraph on Claude: Generate, Critique, Revise
- Hermes Self-Skill Engineering: Teach the Agent to Teach Itself