Work effectively with AI coding agents. Understand them as language models running in a tool loop with limited context, which is why they guess, game the visible signal and report confidently. Recognise the shortcut and correctness tells in their code across Python, TypeScript/JavaScript, Rust, Java and Go, and know the damage each one does later. Verify changes instead of trusting them, review diffs fast for quality and security, judge when work is truly finished, and choose, design and steer tasks so agents can finish them well.
Training cutoff and API drift
card 4 of 6
A v1 decorator in a v2 project
builds on: Why agents fill gaps with plausible guesses
The tell is the import: `validator` is the Pydantic 1 API. In 2.x it still runs and only emits a `PydanticDeprecatedSince20` warning, so the tests go green even though the code targets the wrong version. **Later cost:** the code breaks when Pydantic removes the v1 names, and readers now see two validation styles in one codebase. The trustworthy version, written after the agent has read the installed Pydantic: `@field_validator("qty")` stacked on `@classmethod`.
// Python
--- a/app/schemas.py
+++ b/app/schemas.py
-from pydantic import BaseModel
+from pydantic import BaseModel, validator
class Order(BaseModel):
qty: int
+
+ @validator("qty")
+ def positive(cls, v):
+ if v <= 0:
+ raise ValueError("qty must be > 0")
+ return v
Terms on this card
- Pydantic
- A Python library for validating data with typed model classes. Version 2 renamed many version 1 APIs.
- decorator
- In Python, a line like @validator(...) placed above a function that wraps or registers it.
- field_validator
- The Pydantic 2 decorator for validating one field. It replaces the version 1 @validator and is normally stacked on @classmethod.
- @classmethod
- A built-in Python decorator that makes a method receive the class (cls) instead of an instance.
- PydanticDeprecatedSince20
- The warning class Pydantic 2 emits when code calls an API carried over from version 1.
Lesson goal: Explain that a model's library knowledge is frozen at training time and blended across versions. It therefore defaults to whatever was most common in its training data, not to the version in your lockfile. Predict when this will bite (fast-moving libraries, recent major versions) and how to counter it: state the versions, and point the agent at the installed docs, type definitions or the lockfile. ·
the whole lesson