ReAct, Function Calling, and Context Engineering — explained with live demos powered by the Anthropic API. Run real examples in the browser.
ReAct = Reasoning + Acting. Instead of asking a model to answer immediately, you instruct it to alternate between thinking out loud and taking actions — then observe results before continuing.
This externalises the reasoning chain. Errors become visible. Each step is checkable. Hallucinations drop because the model is forced to justify every move.
// the loop
// the system prompt
// live demo
You give the model a typed interface to the real world. Instead of returning free-text, the model returns a structured JSON payload that your code executes. The model doesn't run the function — you do. It just knows how to ask for it correctly.
This is the architecture behind every serious AI integration: job trackers, search tools, data lookups, form submissions.
// the three-part contract
You describe available functions in JSON: name, description, parameters, types, required fields. The model reads this like documentation.
You don't tell it when. Given the right context, it will return a structured call object instead of prose — because it knows a tool is available.
Your code runs the function, gets real data, feeds the result back. The model then generates a natural language response informed by live data.
This is the critical mental model: the AI only ever produces text. "Function calling" means it produces specially-formatted text that your code intercepts and acts on. You are the executor.
// schema definition
// live demo · simulated tool pipeline
What you put in the context window, in what order, and how much of it — models are extremely sensitive to all three. This is the highest-leverage skill because it affects every single prompt you write.
Most prompt failures aren't model failures. They're context failures: too much noise, wrong order, missing examples, or competing instructions.
// the four levers
Models weight the start and end of context most. Put system instructions at the top. Put the actual task at the bottom. Background goes in the middle.
Every token competes. Verbose context buries signal in noise. Ruthlessly remove filler. 10 precise words beat 100 vague ones.
One well-chosen input→output example beats three paragraphs of instruction. Show the model exactly what you want rather than describing it.
Telling the model who it is AND what it must not do is more reliable than telling it what to do. Negative constraints are powerful.
// primacy & recency — the golden structure
// live demo · a/b comparison
See how different context quality produces different outputs for the same underlying task.