Failure Index / Data & schema · critical · LangChain · OpenAI Agents SDK · CrewAI
Agent step fails with KeyError: expected field missing from previous output
The step tried to read a field that wasn't there. The data contract between two steps broke — either the upstream API changed its response shape, or the previous step returned an error/empty payload that the next step assumed was data.
The error
KeyError agent tool langchain
agent missing key previous step output
KeyError crewai task outputRoot cause
Two usual suspects: (1) the upstream service changed or removed a field, silently breaking every consumer; (2) a previous step failed soft — returned an error object or empty result — and the pipeline treated it as valid data.
The fix
Print the previous step's actual output and diff it against what the failing code expects. If the API changed, update the parser. If the previous step failed silently, make it fail loud — validate outputs before passing them on.
Preventing it next time
Validate each tool's output against a schema (even a loose one) before the next step consumes it — schema drift then fails at the boundary with a clear message, not deep inside the next step.
pip install vorlo-trace · npm install vorlo-trace. Start free