Skip to content
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
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies = [
"typing-extensions>=4.12.2, <5",
"requests>=2.0, <3",
"types-requests>=2.0, <3",
"mcp; python_version >= '3.10'",
"mcp>=1.6.0, <2; python_version >= '3.10'",
]
classifiers = [
"Typing :: Typed",
Expand Down
2 changes: 2 additions & 0 deletions src/agents/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
transcription_span,
)
from .usage import Usage
from .version import __version__


def set_default_openai_key(key: str, use_for_tracing: bool = True) -> None:
Expand Down Expand Up @@ -247,4 +248,5 @@ def enable_verbose_stdout_logging():
"gen_trace_id",
"gen_span_id",
"default_tool_error_function",
"__version__",
]
2 changes: 1 addition & 1 deletion src/agents/version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import importlib.metadata

try:
__version__ = importlib.metadata.version("agents")
__version__ = importlib.metadata.version("openai-agents")
except importlib.metadata.PackageNotFoundError:
# Fallback if running from source without being installed
__version__ = "0.0.0"
35 changes: 35 additions & 0 deletions tests/test_function_tool_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Any, Optional

import pytest
from inline_snapshot import snapshot

from agents import function_tool
from agents.run_context import RunContextWrapper
Expand Down Expand Up @@ -198,3 +199,37 @@ async def test_all_optional_params_function():
input_data = {"x": 10, "y": "world", "z": 99}
output = await tool.on_invoke_tool(ctx_wrapper(), json.dumps(input_data))
assert output == "10_world_99"


@function_tool
def get_weather(city: str) -> str:
"""Get the weather for a given city.

Args:
city: The city to get the weather for.
"""
return f"The weather in {city} is sunny."


@pytest.mark.asyncio
async def test_extract_descriptions_from_docstring():
"""Ensure that we extract function and param descriptions from docstrings."""

tool = get_weather
assert tool.description == "Get the weather for a given city."
params_json_schema = tool.params_json_schema
assert params_json_schema == snapshot(
{
"type": "object",
"properties": {
"city": {
"description": "The city to get the weather for.",
"title": "City",
"type": "string",
}
},
"title": "get_weather_args",
"required": ["city"],
"additionalProperties": False,
}
)
10 changes: 6 additions & 4 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.