1 minute read · ai
Agents loop: reason, call tool, observe, repeat until done.
Define a Tool
@tool
def search_web(query: str) -> str:
"""Search the web for current info."""
return requests.get(f'https://api.search.com?q={query}').textRun the Agent
executor = AgentExecutor(agent=create_react_agent(llm, tools), tools=tools)
executor.invoke({'input': 'Find top Python packages this week'})Conclusion
Reliable tools and error handling are the keys to production agents.