"""One model/tool workflow using your own OpenAI account.

Download planisphere_openai.py beside this file. Set OPENAI_API_KEY,
OPENAI_MODEL (a model available to your project), and PLANISPHERE_API_KEY.
This calls OpenAI and records billable Planisphere receipts.
"""
import os

from agents import Agent, Runner, function_tool

from planisphere_openai import connect


@function_tool
def add(a: int, b: int) -> int:
    """Add two integers."""
    return a + b


def main() -> None:
    evidence = connect(
        system_id=os.environ.get("PLANISPHERE_SYSTEM_ID", "openai-connection-check"),
        environment="development",
        surface="connection-check",
    )
    try:
        agent = Agent(name="Connection check", model=os.environ["OPENAI_MODEL"], tools=[add])
        Runner.run_sync(agent, "Use the add tool to add 2 and 3, then report the result.")
    finally:
        evidence.shutdown()
        print(evidence.status())


if __name__ == "__main__":
    main()
