Intermediate~12 minHazelJS
Retrieval Before Action
Require grounded lookup/RAG before write tools fire—via policy, graph edges, or tool allow-order discipline.
- Authors
- editorial-team
- Published
- Last reviewed
Problem
Agents act on stale assumptions without checking systems of record.
Context
Ops and support agents that must read tickets/docs before mutating.
Forces and constraints
- Writes without reads cause incidents
- Forced retrieval adds latency
- RAG alone may still be stale vs transactional reads
Recommended design
Structure graphs/pipelines so lookup tools precede writes; PolicyEngine or evals fail if write occurs without prior read tool in the trace; enableRAG for doc grounding but prefer transactional @Tool lookups for order/ticket state.
Minimal pseudocode
// Eval gate
expectTools(result, ['lookupOrder', 'processRefund']);
// Policy: deny processRefund if no prior lookup in run (app-level guard)
// Graph: lookup node → decide node → write nodeFailure modes
- RAG-only grounding for transactional truth
Security considerations
- Read tools still need authz
Observability signals
- Flag writes without preceding reads
Evaluation approach
Forbidden write-without-lookup cases in describeAgent
Trade-offs
- Extra read cost vs safer writes