Build an Autonomous Coding Agent · 40 min · Python · Anthropic Python SDK · Pydantic
Planning Engine
A plan that references a file that doesn't exist is a bug to catch before execution, not one to discover mid-run.
Hiring signal: Extracting and validating structured plans from an LLM -- rather than trusting free-form output -- is the pattern that makes an agent's actions auditable and debuggable before anything irreversible happens.
What you will learn
- Design a Pydantic plan schema with file targets, action types, and acceptance criteria
- Generate a structured plan from an LLM call and parse it reliably
- Validate a plan against the real repo before executing any of it
Introduction
You can identify which files matter. Today, before any code gets written, the agent has to say exactly what it intends to do — as data you can inspect and validate, not as a paragraph of prose you have to trust.
The plan schema: structured, not free text
from pydantic import BaseModel
from typing import Literal
class PlanStep(BaseModel):
file_path: str
action: Literal["modify", "create"]
description: str
acceptance_criteria: str # what "done" looks like for this specific step
class ImplementationPlan(BaseModel):
task: str
steps: list[PlanStep]
risk_notes: str # anything the agent flags as risky about this plan
Compare this to just asking the model "make a plan" and parsing whatever prose comes back with regex -- fragile, and you have no reliable way to programmatically check "does step 3 reference a real file?" before you've already started executing steps 1 and 2. A Pydantic schema forces the model's plan into a shape your code can actually inspect and validate.
Unlock the full lesson
You've read the first 2 sections. The rest of this lesson covers Getting the model to produce this shape reliably, Validation before execution: catch it here, not mid-run, What You're Building — plus a hands-on lab, quiz, and project artifact.
Create a free account to unlock Phase 0 and Phase 1 of every course — no credit card.
Browse all courses · View pricing · DeVenture Academy