Demonstrates custom function tools creation using the @function_tool decorator.
Sign in to save downloads to your library and vote.
Preview
Function Tools Agent
Demonstrates custom function tools creation using the @function_tool decorator.
๐ฏ What This Demonstrates
- Custom Function Tools: Creating tools with
@function_tooldecorator - Tool Descriptions: Providing clear docstrings for LLM understanding
- Parameter Handling: Type hints and default parameters
- Error Handling: Graceful tool failure management
๐ Quick Start
-
Install OpenAI Agents SDK:
pip install openai-agents -
Set up environment:
cp ../env.example .env # Edit .env and add your OpenAI API key -
Run the agent:
from agents import Runner from agent import root_agent result = Runner.run_sync(root_agent, "What time is it in New York?") print(result.final_output)
๐ก Key Concepts
- @function_tool Decorator: Converting Python functions to agent tools
- Tool Docstrings: How LLM understands when to use tools
- Type Hints: Parameter validation and documentation
- Tool Registration: Adding tools to agent configuration
๐งช Available Tools
get_current_time(timezone: str = "UTC")
- Returns current time in specified timezone
- Handles timezone validation and error cases
greet_user(name: str)
- Simple greeting tool demonstrating basic tool usage
- Shows parameter passing from LLM to tool
๐ Next Steps
- Built-in Tools - Using WebSearch, CodeInterpreter
- Agents as Tools - Advanced agent orchestration
Ingestion metadata
- Source catalog
- awesome-llm-apps
- Repository
- Shubhamsaboo/awesome-llm-apps ยท main
- File path
- ai_agent_framework_crash_course/openai_sdk_crash_course/3_tool_using_agent/3_1_function_tools/README.md
- Last refreshed
- 10/24/2026, 3:00:14 AM (5h ago)
- Refresh schedule
- Daily ยท 03:00 UTC
- Dedupe status
- Unique ยท deduped by (source, url)