When an agent pipeline fails in production, the question is: where was correctness being enforced, and when did it break down?
Two approaches. Different tradeoffs.
Assertion-First
async def score_company ( state : dict ) -> dict : assert state . get ( " enriched " ), " must be enriched before scoring "
result = await llm . run ( score_prompt , state )
assert result . get ( " score " ) is not None return { ** state , ** result }
Enter fullscreen mode
Exit fullscreen mode
Fast to write. Familiar. Works fine for small pipelines.
Problems at scale: checks scatter across every executor. When a pipeline crashes mid-run, you restart from the beginning — including any external API calls already executed. When the assertion fires, you get a stack trace.…