openai-agents-python/examples/codex/classic.py
Mark Stuart 96f2bbf3f8
chore: restore classic examples and organize example collections (#5566)
* chore: restore and organize SDK examples

* fix: repair restored example setup and assets

* fix: bound SIP webhooks and repair example commands

* fix: validate local example hosts and provider setup

* fix: normalize classic example filters across platforms

---------

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

29 lines
837 B
Python

"""Run a retained v0 tool workflow without model credentials or native execution."""
import asyncio
from agents.classic import Agent, RunConfig, Runner, function_tool
from agents.classic.testing import ScriptedModel, assistant_message, function_call
@function_tool
def greet(name: str) -> str:
"""Greet the named person."""
return f"Hello, {name}!"
async def main() -> None:
model = ScriptedModel(
[
[function_call("greet", {"name": "Ada"}, call_id="greeting-1")],
[assistant_message("Hello, Ada!")],
]
)
agent = Agent(name="Greeter", model=model, tools=[greet])
result = await Runner.run(agent, "Greet Ada.", run_config=RunConfig(tracing_disabled=True))
model.assert_complete()
print(result.final_output)
if __name__ == "__main__":
asyncio.run(main())