import sys
import asyncio
import traceback
from dotenv import load_dotenv

from agents import Agent
from agents.lifecycle import AgentHooks


# Load environment variables from .env (if present) before using the SDK
load_dotenv()


class BadHooks(AgentHooks):
    # Intentionally empty to trigger mismatch early (Runner.run expects RunHooks methods)
    pass


async def main() -> None:
    agent = Agent(name="ExampleAgent")
    print("About to run with WRONG hooks type: passing AgentHooks as global hooks...")
    try:
        from agents.run import Runner
        await Runner.run(agent, input="hi", hooks=BadHooks())
        print("Unexpected: no error")
    except AttributeError as e:
        print("Caught AttributeError (expected for repro):", e)
        traceback.print_exc()


if __name__ == "__main__":
    try:
        asyncio.run(main())
    except KeyboardInterrupt:
        sys.exit(130)
