get_top_hackernews_stories function as a tool:
hn_agent.py
Magic of the @tool decorator
To modify the behavior of a tool, use the@tool decorator. Some notable features:
requires_confirmation=True: Requires user confirmation before execution.requires_user_input=True: Requires user input before execution. Useuser_input_fieldsto specify which fields require user input.external_execution=True: The tool will be executed outside of the agent’s control.show_result=True: Show the output of the tool call in the Agent’s response,Trueby default. Without this flag, the result of the tool call is sent to the model for further processing.stop_after_tool_call=True: Stop the agent run after the tool call.tool_hooks: Run custom logic before and after this tool call.cache_results=True: Cache the tool result to avoid repeating the same call. Usecache_dirandcache_ttlto configure the cache.
@tool decorator.
advanced_tool.py