openai-agents-python/examples/codex/basic.py
Mark Stuart ba3fbbf400
docs: organize SDK guides around developer tasks (#5920)
* docs: organize SDK guides and clarify examples

* fix: correct native SDK type declarations

* test: update native SDK contract fixtures

* fix: normalize persisted agent profile transport settings

* test: reconcile inherited model settings API snapshot

* test: preserve executor coverage on Windows

---------

Co-authored-by: markstuart-oai <323302876+markstuart-oai@users.noreply.github.com>
2026-11-12 21:00:58 -08:00

29 lines
697 B
Python

"""Run a typed Python function through a native agent.
Run `python -m examples.codex.basic` from the repository root with the matching
SDK installed and OPENAI_API_KEY configured. The answer greets Ada; live wording
can vary. The model request can incur charges.
"""
import asyncio
from agents import Agent, function_tool
@function_tool
async def greeting(name: str) -> str:
return f"Hello, {name}!"
async def main() -> None:
agent = Agent(
name="Assistant",
instructions="Use greeting to greet the user.",
tools=[greeting],
)
result = await agent.run("Greet Ada.")
print(result.final_output)
if __name__ == "__main__":
asyncio.run(main())