Skip to content

use @function_tool decorator in docs #99

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ The most common properties of an agent you'll configure are:
```python
from agents import Agent, ModelSettings, function_tool

@function_tool
def get_weather(city: str) -> str:
return f"The weather in {city} is sunny"

agent = Agent(
name="Haiku agent",
instructions="Always respond in haiku form",
model="o3-mini",
tools=[function_tool(get_weather)],
tools=[get_weather],
)
```

Expand Down
3 changes: 2 additions & 1 deletion docs/context.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class UserInfo: # (1)!
name: str
uid: int

@function_tool
async def fetch_user_age(wrapper: RunContextWrapper[UserInfo]) -> str: # (2)!
return f"User {wrapper.context.name} is 47 years old"

Expand All @@ -44,7 +45,7 @@ async def main():

agent = Agent[UserInfo]( # (4)!
name="Assistant",
tools=[function_tool(fetch_user_age)],
tools=[fetch_user_age],
)

result = await Runner.run(
Expand Down