Loop
Question: What's Tesla's P/E ratio?
Thought: I need current stock price + earnings.
Action: get_stock_price[TSLA]
Observation: $220
Thought: Now earnings...
Action: get_earnings[TSLA]
Observation: $4.30 EPS
Thought: 220/4.30 ≈ 51.2
Answer: About 51.2Advertisement
Advantages
Interpretable. Recoverable from errors (see wrong observation, correct). Extensible via new tools.
Advertisement
Prompt structure
System: describe tools + format. Few-shot: 2-3 full trajectories. Model learns to follow pattern.
Failure modes
Wrong tool selection. Infinite loops. Hallucinated observations. Cap loop length + inject 'give up' escape.