Module 03 · agentic AI
ReAct: reason, act, observe
The agent investigates an AML alert. Reveal one step at a time and narrate it: the model only ever emits text, the loop is what turns that text into a tool call, and the observation is what gets appended back into the context window.
$ python -m fde_toolkit react
Agent loop
1/6 steps revealed
System prompt
You are an AML investigation agent. Reason step by step. Use the available tools. Never move funds without a policy check.
- step 1
CustomerDBThought: I need the customer's KYC status before I evaluate anything else.
Action:
CustomerDB[CUST-3311]Observation: KYC status: pending, risk: high, legal name: Halcyon Trading
context window99/512 tokens
Tool manifest
MCP-style descriptors
CustomerDBLook up a customer's KYC status and risk rating by customer id.
{"type":"object","properties":{"customer_id":{"type":"string"}}}SanctionsScreenScreen a two-letter country code against the consolidated sanctions list.
{"type":"object","properties":{"country":{"type":"string"}}}TransactionHistoryReturn recent transfer activity for a customer id.
{"type":"object","properties":{"customer_id":{"type":"string"}}}PolicyCheckEvaluate a transaction scenario against the runtime guardrail policy.
{"type":"object","properties":{"scenario":{"type":"string"}}}FileSARFile a draft Suspicious Activity Report for human review.
{"type":"object","properties":{"case_id":{"type":"string"}}}
Teaching notes
- The model never calls anything. It emits a string; your loop parses it and dispatches. That is the whole of “tool calling” at the API level.
- Every observation is appended to the prompt. Context is a budget, not a memory — watch the meter climb and ask the room what happens at 100%.
- Note that the agent checks policy before it acts. In a regulated enterprise that ordering is the deliverable, not the model choice.