When a step ends and the next one starts, what travels between them? Two opposite sins:
The rule: each step receives the minimum it needs to do its job well. No more, no less.
fields, the next step receives fields. Not the raw text it came from, unless it needs it.document_id, not the document. The step that needs it fetches with a tool.Think of shared context as the kitchen counter. You have what you're using now, not the whole pantry. If you work with ALL the pantry open on the counter, you can't find the knife when you need it. The model is the same: with too much context it loses sight of what matters.
In the chain YAML, explicitly declare what enters each step. Not "everything in the context", but "these keys, from these steps":
- id: recommend
input:
category: from chain.steps.classify.output.category
severity: from chain.steps.severity.output.score
fields: from chain.steps.extract.output.fields
# NOT: 'the whole context'Declarative, auditable, debuggable. If a step receives something, it's written; if it doesn't, that's written too.
On the right, four transitions in your chain. For each one, drag the piece that describes the correct minimum that should be in the context. One of the pieces is never passed. that one goes in the "never" slot.