Learning / Agentic Operations / Lesson 0008
The ReAct Multi-Hop Build
Thought → action → observation, looped — the workhorse pattern, built and logged by hand.
1 · The corpus (offline, deterministic)
No web APIs needed — the pattern is the point. Create
exercises/notes/ with 6–10 small text files forming a chain of facts, e.g.
team.md ("The pipeline runs on Temporal; Marisol owns the worker fleet"),
marisol.md ("Marisol's runbook lives at runbook-w3.md"),
runbook-w3.md ("Worker restarts require the ops channel approval; the channel is
#ops-west")… Design a question that takes 3+ hops:
"Which channel must approve a restart of the fleet owned by the person who owns the
pipeline workers?"
2 · Two tools
Extend your 0005 loop with two tools (same schema discipline — descriptions say when):
search_notes(query) -> filenames whose content matches the query terms
read_note(filename) -> the file's full text
Implementation stays boring: substring/keyword match for search; path-validate
read_note against the notes directory (untrusted input — 0005's rule).
3 · Elicit the pattern
ReAct is interleaved reasoning and acting (Yao et al.): the model states a thought, takes one action, reads the observation, adjusts. Two changes produce it:
- System prompt: "Work step by step. Before each tool call, state in one sentence what you're looking for and why. After each result, state what you learned. Search before you read; read before you answer."
- Trace logging: extend your context logger to also write a compact
per-step trace:
{step, thought, action, action_input, observation}— thought = the text block preceding the tool call, observation = the tool result you returned.
4 · Watch it adjust — the part CoT can't do
Now sabotage one hop: rename a file so a search comes back empty, or plant a note whose content contradicts another. Re-run and read the trace.
Self-grade
- Multi-hop works — 3+ dependent lookups, correct final answer
- Trace is legible — thought/action/observation per step, replayable by a reader who wasn't there
- Adjustment demonstrated — the sabotage run shows reformulation, not denial
- Choice justified — the three-sentence CoT/ReAct/ToT justification, with real costs
Next
Lesson 0009 — RAG build & break: grounding at scale, and what happens when chunking is wrong.