Generative AI & Agentic AIAgent workflows and state

Design typed state for a multi-step workflow

PK
Pankit Kumar
Sr. Data Scientist at Parexel (a Goldman Sachs–backed company) · 20 September 2026 · 2 min read
Technically reviewed by Ishaan Sharma
In this article (5 sections)

Conversation text is a poor source of operational truth. A multi-step workflow needs typed state that can be validated, checkpointed and resumed without asking a model what happened.

Execute a serializable state contract

The agent controls lab defines a Python dataclass.

python
from agent_cases import typed_state_case

result = typed_state_case()
assert result["complete"] is True
assert result["serializable"] is True
assert result["state"]["current_step"] == "approval"
assert result["state"]["approval"] is None

The record includes run ID, status, current/completed steps, attempts, approval and last error. It contains no hidden model memory.

Separate durable and derived fields

Durable state includes stable identifiers, user scope, validated inputs, completed side effects, idempotency keys, approvals and checkpoint version. Derived summaries can be recomputed and should not override source records.

Define allowed transitions such as running→approval_pending→approved→executing→complete. Reject impossible transitions and unknown schema versions. Keep sensitive content out of state unless necessary and protected.

Test recovery and concurrency

Serialize/deserialize, resume after each step and verify completed actions do not repeat. Handle two workers attempting the same transition with optimistic locking or transactions. Migrate old state versions explicitly.

The Generative & Agentic AI course uses typed state as the base for LangGraph or other orchestration frameworks, rather than binding learning to one library.

Exercise

Define a typed state and transition table for a five-step workflow. Add schema/version validation, simulate concurrent approval and cancellation, and prove one valid terminal result.

Continue learning

This article is part of the Agent workflows and state sequence. Use the neighbouring tasks when you need the prerequisite or the next application.

Reference: LangGraph persistence.

PK
Pankit Kumar
Lead Instructor, NeuraPath Academy

Pankit Kumar has 10 years in Data Science & AI, building and shipping production systems in regulated pharma and clinical environments. He is a freelance trainer at Boston Institute of Analytics, AnalytixLabs and Scaler, and has taught this material to thousands of working professionals.

This article is part of our Generative & Agentic AI programme — 3 months. Add practical GenAI, retrieval and agent-building skills to your existing toolkit.

Explore Generative & Agentic AI
Counselling is free · no obligation

Not sure which programme fits?

Tell us your background and we will map it to the right entry point — including saying so when a cheaper programme is the better fit. A counsellor replies within one working day.