HackerNews:
hackernews_agent.py
Run your Agent
UseAgent.print_response() for development. It prints the response in a readable format in your terminal.
For production, use Agent.run() or Agent.arun():
Callable Factories
Pass a function instead of a static list fortools or knowledge. The function is called at the start of each run, so the toolset or knowledge base can vary per user or session.
callable_tools.py
Callable Caching Settings
Factory results are cached by default. The cache key is resolved in this order: custom key function >user_id > session_id. If none are available, caching is skipped and the factory runs every time.
| Setting | Default | Description |
|---|---|---|
cache_callables | True | Enable or disable caching for all callable factories |
callable_tools_cache_key | None | Custom cache key function for tools factory |
callable_knowledge_cache_key | None | Custom cache key function for knowledge factory |
callable_members_cache_key | None | Custom cache key function for members factory (Team only) |
cache_callables=False when session_state changes between runs and the factory should re-evaluate each time.
Clear cached results programmatically:
aclear_callable_cache() in async code.
Next Steps
After getting familiar with the basics, add functionality as needed:| Task | Guide |
|---|---|
| Run agents | Running agents |
| Debug agents | Debugging agents |
| Manage sessions | Agent sessions |
| Handle input/output | Input and output |
| Add tools | Tools |
| Manage context | Context engineering |
| Add knowledge | Knowledge |
| Handle images, audio, video, files | Multimodal |
| Add guardrails | Guardrails |
| Cache responses during development | Response caching |