#!/usr/bin/env python3
"""
Generated test file for Tool Call Agent Test
Framework: langgraph
Execution mode: async
Streaming: no"""

import os
import sentry_sdk
import asyncio

from langgraph.prebuilt import create_react_agent
from langchain_anthropic import ChatAnthropic
from langchain_core.messages import HumanMessage, SystemMessage


sentry_sdk.init(
    dsn=os.environ.get("SENTRY_DSN"),
    traces_sample_rate=1.0,
    send_default_pii=True,
    stream_gen_ai_spans=True,
)

# Initialize ChatAnthropic for LangGraph
llm = ChatAnthropic(
    model="claude-haiku-4-5",
    api_key=os.environ.get("ANTHROPIC_API_KEY"),
)

# Define tools for the agent
def add(a, b):
    """Add two numbers together"""
    return 8

def multiply(a, b):
    """Multiply two numbers together"""
    return 32

tools = [add, multiply]

# Create react agent
agent = create_react_agent(llm, tools=tools, name="math_assistant")

async def main():
    # Turn 1: Run agent
    messages = [
        HumanMessage(content="Calculate (3 + 5) * 4. First use the add tool to add 3 and 5, then use the multiply tool to multiply the result by 4."),
    ]

    result = await agent.ainvoke({"messages": messages})

    # Extract the AI's response from the result
    response_text = result["messages"][-1].content

    # Print response
    print(f"Turn 1 Response: {response_text}")

if __name__ == "__main__":
    with sentry_sdk.start_transaction(op="test", name="Tool Call Agent Test"):
        asyncio.run(main())
    sentry_sdk.flush(timeout=5)
