Ai Agents
PART 17 — AI Agents¶
Agents use the LLM to output structured JSON to trigger Python functions (Tools).
Example Trace (ReAct Loop): User: "Find out how much AAPL is, and email john@test.com"
Loop 1 (LLM Output):
{
"thought": "I need to get the stock price of AAPL first.",
"action": "get_stock_price",
"args": {"ticker": "AAPL"}
}
get_stock_price("AAPL") and gets $150. It appends this observation to the prompt.
Loop 2 (LLM Output):
{
"thought": "Now I need to email John the price of $150.",
"action": "send_email",
"args": {"to": "john@test.com", "body": "AAPL is $150"}
}
send_email(). Agent finishes.