Agentic AI · Intermediate level

Intermediate level · Module 6 of 9 · 11 guided hours

Agent State Management

Making agent progress explicit and recoverable: state objects, state machines, persistence and checkpoints, resuming interrupted tasks and idempotent steps.

Learning objectives

  • Represent agent progress as an explicit state object
  • Model agent behaviour as a state machine
  • Persist, checkpoint and resume tasks safely

Topics

  • explicit state objects
  • state machines and transitions
  • persisting state in SQLite
  • checkpoints and resuming
  • idempotent steps
  • state for audit

Lessons

  1. Lesson 1 Explicit State Objects

    Learners replace scattered variables with one Pydantic state object that records the question, plan, evidence, drafts, errors and status of a task.

    state objectstatus fieldevidence listimmutability and copiessingle source of truth

  2. Lesson 2 Agents as State Machines

    Learners model the agent as a state machine with named statuses and allowed transitions, so that impossible or unsafe sequences are prevented by design.

    state machinestatus (planning, searching, drafting, reviewing, done, handed_over)allowed transitionsterminal statesinvalid transition errors

  3. Lesson 3 Persistence, Checkpoints and Resuming

    Learners save state after each step to SQLite so that tasks can resume after a crash, a power cut or a lost connection, and make steps idempotent.

    checkpointserialisation (model_dump_json)resumeidempotencytask ID

Practical activity

Refactor the project agent around an explicit state object and state machine, with SQLite checkpoints and resume.

Expected outcomes

  • Explicit, recoverable agent state
  • Foundations for graph orchestration

Assessment

State implementation and tests (70%) and state diagram (30%).

Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.