[PR #4728] prebuilt: support LLM provider builtin tools in react agent #4028

Closed
opened 2026-02-20 17:49:32 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langchain-ai/langgraph/pull/4728

State: closed
Merged: No


from langgraph.prebuilt import create_react_agent

def add(a: int, b: int):
    """Add two numbers"""
    return a + b

# OpenAI
web_search = {
    "type": "web_search_preview"
}
agent = create_react_agent(
    model="openai:gpt-4.1",
    tools=[add, web_search]
)
search_result = agent.invoke({
    "messages": [{"role": "user", "content": "what's the weather in nyc today?"}]
})
math_result = agent.invoke({
    "messages": [{"role": "user", "content": "what's 42 + 7?"}]
})

# Anthropic
web_search = {
    "type": "web_search_20250305",
    "name": "web_search",
    "max_uses": 3
}
agent = create_react_agent(
    model="anthropic:claude-3-5-sonnet-latest",
    tools=[add, web_search]
)
search_result = agent.invoke({
    "messages": [{"role": "user", "content": "what's the weather in nyc today?"}]
})
math_result = agent.invoke({
    "messages": [{"role": "user", "content": "what's 42 + 7?"}]
})

# TODO: need to verify that this works with google tools

**Original Pull Request:** https://github.com/langchain-ai/langgraph/pull/4728 **State:** closed **Merged:** No --- ```python from langgraph.prebuilt import create_react_agent def add(a: int, b: int): """Add two numbers""" return a + b # OpenAI web_search = { "type": "web_search_preview" } agent = create_react_agent( model="openai:gpt-4.1", tools=[add, web_search] ) search_result = agent.invoke({ "messages": [{"role": "user", "content": "what's the weather in nyc today?"}] }) math_result = agent.invoke({ "messages": [{"role": "user", "content": "what's 42 + 7?"}] }) # Anthropic web_search = { "type": "web_search_20250305", "name": "web_search", "max_uses": 3 } agent = create_react_agent( model="anthropic:claude-3-5-sonnet-latest", tools=[add, web_search] ) search_result = agent.invoke({ "messages": [{"role": "user", "content": "what's the weather in nyc today?"}] }) math_result = agent.invoke({ "messages": [{"role": "user", "content": "what's 42 + 7?"}] }) ``` \# TODO: need to verify that this works with google tools
yindo added the pull-request label 2026-02-20 17:49:32 -05:00
yindo closed this issue 2026-02-20 17:49:32 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#4028