Tutorials · Chapter D (4/4) · ~11 min
Agents in code
Try it → see it → read → next
Wire a **Think → Act → Observe** loop — model picks tools, your code runs them, results feed back until done or max steps.
Optional on: Professional
Try tools: Agents & automation
Try yourself
Playground
Agent loop in code
Think → act → observe — cap steps and gate dangerous tools.
- Model plans next action
- Tool call returned — validate args
- Append tool result to messages
- Stop at max steps or final answer
Recap
What you just did
You stepped through the minimal loop: plan → validate tool call → append observation → stop at a cap.
Read
Starter pattern
Read
Safety gates
- No shell/exec without human approval
- Log every step (see tracing lab)
- Eval golden tasks before shipping