Agents extend LLMs with the ability to take actions — search the web, call APIs, run code, and more.
Architecture
A basic agent loop:
- Receive user input
- Decide which tool to use (if any)
- Execute the tool
- Feed results back to the model
- Repeat until done
Tool design
Keep tools focused and well-documented. The model reads tool descriptions to decide when to use them.
def search_docs(query: str) -> str:
"""Search internal documentation for relevant pages."""
return doc_store.search(query)
Common pitfalls
- Too many tools confuse the model
- Missing error handling leads to infinite loops
- No observability makes debugging painful
Start simple. Add complexity only when needed.