langchain - 💡(How to fix) Fix OpenAI computer-use tool calls are not executed as LangChain tool calls

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

LangChain does not currently execute OpenAI Responses API computer tool requests through the standard LangChain tool-call loop.

When ChatOpenAI(..., use_responses_api=True) is used with:

tools = [{"type": "computer"}]

OpenAI correctly returns a computer_call, such as a screenshot request. However, LangChain keeps this computer_call inside AIMessage.content instead of exposing it as an executable AIMessage.tool_calls entry.

As a result, create_agent() does not execute the requested computer action. In practice, the model asks to use the computer, but the LangChain agent loop silently stops without running the computer-use tool.

This makes OpenAI computer use difficult to integrate with LangChain agents, even though similar computer-use tools from Anthropic and Google are exposed as executable LangChain tool calls.

Error Message

Error Message and Stack Trace (if applicable)

Before PR #36261 added "computer" to _WellKnownOpenAITools, passing {"type": "computer"} raised an explicit error. After that PR, the error no longer occurs, but the returned OpenAI computer_call still does not participate in the standard LangChain tool execution loop.

Root Cause

The conversion should preserve the OpenAI call_id, because the follow-up response must be sent back as computer_call_output.

Fix Action

Fix / Workaround

  • This is a bug, not a usage question.
  • I added a clear and descriptive title that summarizes this issue.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
  • This is not related to the langchain-community package.
  • I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.

Other Dependencies

anthropic: 0.106.0 filetype: 1.2.0 google-genai: 2.8.0 httpx: 0.28.1 jsonpatch: 1.33 langgraph: 1.1.8 openai: 2.32.0 orjson: 3.11.8 packaging: 26.1 pydantic: 2.13.2 pyyaml: 6.0.3 requests: 2.33.1 requests-toolbelt: 1.0.0 tenacity: 9.1.4 tiktoken: 0.12.0 typing-extensions: 4.15.0 uuid-utils: 0.14.1 websockets: 16.0 xxhash: 3.6.0 zstandard: 0.25.0

Code Example

from langchain.agents import create_agent
from langchain_core.messages import AIMessage
from langchain_openai import ChatOpenAI

# Helper to challenge the computer tool
def test_computer_tool(model, computer_use_tool):
    agent = create_agent(
        model=model,
        tools = [computer_use_tool],
    )
    result = agent.invoke(
        {"messages": [
            {
                "role": "user",
                "content": "Take a screenshot of the current computer screen."
            }
        ]},
    )
    for r in result["messages"]:
        if isinstance(r, AIMessage):
            # Tool calls
            if r.tool_calls:
                print("=== Computer tools successfully called ✅ ===")
                for i, c in enumerate(r.tool_calls):
                    print(f"Tool No. {i + 1}:")
                    print(c)
                print("==========================================")
            else:
                print("=== No computer tools were called ‼️ ====")
                print("Instead, the following message was generated:")
                print(r.content[0])
                print("=======================================")


model = ChatOpenAI(
    model="gpt-5.4",
    use_responses_api=True,
    api_key=OPENAI_API_KEY,
)
openai_computer_tool = {"type":"computer"}

test_computer_tool(model, openai_computer_tool)

---

from langchain.agents import create_agent
from langchain_core.messages import AIMessage
from langchain_openai import ChatOpenAI

# Helper to challenge the computer tool
def test_computer_tool(model, computer_use_tool):
    agent = create_agent(
        model=model,
        tools = [computer_use_tool],
    )
    result = agent.invoke(
        {"messages": [
            {
                "role": "user",
                "content": "Take a screenshot of the current computer screen."
            }
        ]},
    )
    for r in result["messages"]:
        if isinstance(r, AIMessage):
            # Tool calls
            if r.tool_calls:
                print("=== Computer tools successfully called ✅ ===")
                for i, c in enumerate(r.tool_calls):
                    print(f"Tool No. {i + 1}:")
                    print(c)
                print("==========================================")
            else:
                print("=== No computer tools were called ‼️ ====")
                print("Instead, the following message was generated:")
                print(r.content[0])
                print("=======================================")


model = ChatOpenAI(
    model="gpt-5.4",
    use_responses_api=True,
    api_key=OPENAI_API_KEY,
)
openai_computer_tool = {"type":"computer"}

test_computer_tool(model, openai_computer_tool)

---

tools = [{"type": "computer"}]

---

from langchain.agents import create_agent
from langchain_core.messages import AIMessage
from langchain_openai import ChatOpenAI


def test_computer_tool(model, computer_use_tool):
    agent = create_agent(
        model=model,
        tools=[computer_use_tool],
    )

    result = agent.invoke(
        {
            "messages": [
                {
                    "role": "user",
                    "content": "Take a screenshot of the current computer screen.",
                }
            ]
        }
    )

    for message in result["messages"]:
        if isinstance(message, AIMessage):
            if message.tool_calls:
                print("=== Computer tools successfully called ===")
                for i, call in enumerate(message.tool_calls):
                    print(f"Tool No. {i + 1}:")
                    print(call)
                print("==========================================")
            else:
                print("=== No computer tools were called ===")
                print("Instead, the following message was generated:")
                print(message.content[0])
                print("=======================================")


model = ChatOpenAI(
    model="gpt-5.4",
    use_responses_api=True,
    api_key=OPENAI_API_KEY,
)

openai_computer_tool = {"type": "computer"}

test_computer_tool(model, openai_computer_tool)

---

=== No computer tools were called ===
Instead, the following message was generated:
{
    "id": "cu_045c3f3a182597c8006a23eb617b24819a91a7a89d4786a09e",
    "call_id": "call_3cNfranspy4UFye2mJ8tyKQs",
    "status": "completed",
    "type": "computer_call",
    "actions": [
        {"type": "screenshot"}
    ],
}
=======================================

---

{
    "name": "computer_call",
    "args": {"action": "screenshot"},
    "id": "call_3cNfranspy4UFye2mJ8tyKQs",
    "type": "tool_call",
}

---

from langchain_anthropic import ChatAnthropic

model = ChatAnthropic(
    model="claude-sonnet-4-6",
    anthropic_api_key=ANTHROPIC_API_KEY,
)

anthropic_computer_tool = {
    "type": "computer_20251124",
    "name": "computer",
    "display_width_px": 1400,
    "display_height_px": 900,
    "display_number": 99,
    "enable_zoom": False,
}

test_computer_tool(model, anthropic_computer_tool)

---

=== Computer tools successfully called ===
Tool No. 1:
{
    "name": "computer",
    "args": {"action": "screenshot"},
    "id": "toolu_01MCjE9jnymndUZAMzHEqkWA",
    "type": "tool_call",
}
==========================================

---

from langchain_google_genai import ChatGoogleGenerativeAI, Environment

model = ChatGoogleGenerativeAI(
    model="gemini-3-flash-preview",
    google_api_key=GOOGLE_API_KEY,
)

gemini_computer_tool = {
    "computer_use": {
        "environment": Environment.ENVIRONMENT_BROWSER,
        "excludedPredefinedFunctions": [],
    }
}

test_computer_tool(model, gemini_computer_tool)

---

=== Computer tools successfully called ===
Tool No. 1:
{
    "name": "open_web_browser",
    "args": {},
    "id": "b6u5u9qv",
    "type": "tool_call",
}
==========================================

---

{
    "type": "computer_call",
    "call_id": "call_...",
    "actions": [
        {"type": "screenshot"}
    ],
}

---

{
    "name": "computer",
    "args": {"action": "screenshot"},
    "id": "call_...",
    "type": "tool_call",
}
RAW_BUFFERClick to expand / collapse

Submission checklist

  • This is a bug, not a usage question.
  • I added a clear and descriptive title that summarizes this issue.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
  • This is not related to the langchain-community package.
  • I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.

Package (Required)

  • langchain
  • langchain-openai
  • langchain-anthropic
  • langchain-classic
  • langchain-core
  • langchain-model-profiles
  • langchain-tests
  • langchain-text-splitters
  • langchain-chroma
  • langchain-deepseek
  • langchain-exa
  • langchain-fireworks
  • langchain-groq
  • langchain-huggingface
  • langchain-mistralai
  • langchain-nomic
  • langchain-ollama
  • langchain-openrouter
  • langchain-perplexity
  • langchain-qdrant
  • langchain-xai
  • Other / not sure / general

Related Issues / PRs

Issue #37938 explains an additional motivation for updating OpenAI computer-use support: the legacy computer-use-preview path is deprecated, and the current OpenAI direction is the Responses API computer tool.

Together, this issue and #37938 suggest that now is a good time to update LangChain's OpenAI computer-use integration more broadly: this issue shows that the current computer tool is not executed through the standard agent loop, while #37938 explains why continuing to rely on the older preview-specific path is no longer appropriate.

Reproduction Steps / Example Code (Python)

from langchain.agents import create_agent
from langchain_core.messages import AIMessage
from langchain_openai import ChatOpenAI

# Helper to challenge the computer tool
def test_computer_tool(model, computer_use_tool):
    agent = create_agent(
        model=model,
        tools = [computer_use_tool],
    )
    result = agent.invoke(
        {"messages": [
            {
                "role": "user",
                "content": "Take a screenshot of the current computer screen."
            }
        ]},
    )
    for r in result["messages"]:
        if isinstance(r, AIMessage):
            # Tool calls
            if r.tool_calls:
                print("=== Computer tools successfully called ✅ ===")
                for i, c in enumerate(r.tool_calls):
                    print(f"Tool No. {i + 1}:")
                    print(c)
                print("==========================================")
            else:
                print("=== No computer tools were called ‼️ ====")
                print("Instead, the following message was generated:")
                print(r.content[0])
                print("=======================================")


model = ChatOpenAI(
    model="gpt-5.4",
    use_responses_api=True,
    api_key=OPENAI_API_KEY,
)
openai_computer_tool = {"type":"computer"}

test_computer_tool(model, openai_computer_tool)

Error Message and Stack Trace (if applicable)

from langchain.agents import create_agent
from langchain_core.messages import AIMessage
from langchain_openai import ChatOpenAI

# Helper to challenge the computer tool
def test_computer_tool(model, computer_use_tool):
    agent = create_agent(
        model=model,
        tools = [computer_use_tool],
    )
    result = agent.invoke(
        {"messages": [
            {
                "role": "user",
                "content": "Take a screenshot of the current computer screen."
            }
        ]},
    )
    for r in result["messages"]:
        if isinstance(r, AIMessage):
            # Tool calls
            if r.tool_calls:
                print("=== Computer tools successfully called ✅ ===")
                for i, c in enumerate(r.tool_calls):
                    print(f"Tool No. {i + 1}:")
                    print(c)
                print("==========================================")
            else:
                print("=== No computer tools were called ‼️ ====")
                print("Instead, the following message was generated:")
                print(r.content[0])
                print("=======================================")


model = ChatOpenAI(
    model="gpt-5.4",
    use_responses_api=True,
    api_key=OPENAI_API_KEY,
)
openai_computer_tool = {"type":"computer"}

test_computer_tool(model, openai_computer_tool)

Description

Description

LangChain does not currently execute OpenAI Responses API computer tool requests through the standard LangChain tool-call loop.

When ChatOpenAI(..., use_responses_api=True) is used with:

tools = [{"type": "computer"}]

OpenAI correctly returns a computer_call, such as a screenshot request. However, LangChain keeps this computer_call inside AIMessage.content instead of exposing it as an executable AIMessage.tool_calls entry.

As a result, create_agent() does not execute the requested computer action. In practice, the model asks to use the computer, but the LangChain agent loop silently stops without running the computer-use tool.

This makes OpenAI computer use difficult to integrate with LangChain agents, even though similar computer-use tools from Anthropic and Google are exposed as executable LangChain tool calls.

Reproduction: OpenAI

from langchain.agents import create_agent
from langchain_core.messages import AIMessage
from langchain_openai import ChatOpenAI


def test_computer_tool(model, computer_use_tool):
    agent = create_agent(
        model=model,
        tools=[computer_use_tool],
    )

    result = agent.invoke(
        {
            "messages": [
                {
                    "role": "user",
                    "content": "Take a screenshot of the current computer screen.",
                }
            ]
        }
    )

    for message in result["messages"]:
        if isinstance(message, AIMessage):
            if message.tool_calls:
                print("=== Computer tools successfully called ===")
                for i, call in enumerate(message.tool_calls):
                    print(f"Tool No. {i + 1}:")
                    print(call)
                print("==========================================")
            else:
                print("=== No computer tools were called ===")
                print("Instead, the following message was generated:")
                print(message.content[0])
                print("=======================================")


model = ChatOpenAI(
    model="gpt-5.4",
    use_responses_api=True,
    api_key=OPENAI_API_KEY,
)

openai_computer_tool = {"type": "computer"}

test_computer_tool(model, openai_computer_tool)

Actual behavior

OpenAI returns a computer_call, but LangChain does not execute it as a tool call.

Example output:

=== No computer tools were called ===
Instead, the following message was generated:
{
    "id": "cu_045c3f3a182597c8006a23eb617b24819a91a7a89d4786a09e",
    "call_id": "call_3cNfranspy4UFye2mJ8tyKQs",
    "status": "completed",
    "type": "computer_call",
    "actions": [
        {"type": "screenshot"}
    ],
}
=======================================

So the model did request a computer action, but the LangChain agent loop did not execute it.

Expected behavior

OpenAI computer_call outputs should be exposed to LangChain agents as executable tool calls.

For example, the screenshot request above should result in something equivalent to:

{
    "name": "computer_call",
    "args": {"action": "screenshot"},
    "id": "call_3cNfranspy4UFye2mJ8tyKQs",
    "type": "tool_call",
}

or another LangChain-native representation that allows the agent loop to execute the computer action and return the corresponding computer_call_output.

Comparison with other providers

Using the same helper function, Anthropic and Google computer-use integrations return executable LangChain tool calls.

This suggests that the issue is specific to how OpenAI Responses API computer_call items are represented in LangChain.

<details> <summary>Anthropic example</summary>
from langchain_anthropic import ChatAnthropic

model = ChatAnthropic(
    model="claude-sonnet-4-6",
    anthropic_api_key=ANTHROPIC_API_KEY,
)

anthropic_computer_tool = {
    "type": "computer_20251124",
    "name": "computer",
    "display_width_px": 1400,
    "display_height_px": 900,
    "display_number": 99,
    "enable_zoom": False,
}

test_computer_tool(model, anthropic_computer_tool)

Output:

=== Computer tools successfully called ===
Tool No. 1:
{
    "name": "computer",
    "args": {"action": "screenshot"},
    "id": "toolu_01MCjE9jnymndUZAMzHEqkWA",
    "type": "tool_call",
}
==========================================
</details> <details> <summary>Google example</summary>
from langchain_google_genai import ChatGoogleGenerativeAI, Environment

model = ChatGoogleGenerativeAI(
    model="gemini-3-flash-preview",
    google_api_key=GOOGLE_API_KEY,
)

gemini_computer_tool = {
    "computer_use": {
        "environment": Environment.ENVIRONMENT_BROWSER,
        "excludedPredefinedFunctions": [],
    }
}

test_computer_tool(model, gemini_computer_tool)

Output:

=== Computer tools successfully called ===
Tool No. 1:
{
    "name": "open_web_browser",
    "args": {},
    "id": "b6u5u9qv",
    "type": "tool_call",
}
==========================================
</details>

Related context

Before PR #36261 added "computer" to _WellKnownOpenAITools, passing {"type": "computer"} raised an explicit error.

After that PR, the error no longer occurs, but the returned OpenAI computer_call still does not participate in the standard LangChain tool execution loop.

The current behavior is therefore silent: OpenAI returns a valid computer_call, but LangChain does not execute the requested computer action.

Suggested fix

OpenAI Responses API computer_call items should be converted into a LangChain-native executable tool-call representation.

The conversion should preserve the OpenAI call_id, because the follow-up response must be sent back as computer_call_output.

A possible mapping could be:

{
    "type": "computer_call",
    "call_id": "call_...",
    "actions": [
        {"type": "screenshot"}
    ],
}

to something conceptually equivalent to:

{
    "name": "computer",
    "args": {"action": "screenshot"},
    "id": "call_...",
    "type": "tool_call",
}

For multiple actions, LangChain could either emit multiple tool calls or use another LangChain-native representation that can be executed by the standard agent loop.

I already have a local prototype and have tested it in a production-level computer-use environment. The environment itself is research-related and cannot be shared publicly, but the modified LangChain code successfully allows OpenAI computer actions to be executed through the standard agent/tool-call flow.

I have a proposed implementation that addresses both issues together. If this direction sounds acceptable, I would be happy to open a PR with tests.

System Info

System Information

OS: Darwin OS Version: Darwin Kernel Version 24.2.0: Fri Dec 6 19:03:40 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T6041 Python Version: 3.13.11 (main, Jan 13 2026, 22:52:06) [Clang 16.0.0 (clang-1600.0.26.6)]

Package Information

langchain_core: 1.4.1 langchain: 1.2.15 langsmith: 0.7.32 langchain_anthropic: 1.4.4 langchain_google_genai: 4.2.4 langchain_openai: 1.1.14 langchain_protocol: 0.0.16 langgraph_sdk: 0.3.13

Optional packages not installed

deepagents deepagents-cli

Other Dependencies

anthropic: 0.106.0 filetype: 1.2.0 google-genai: 2.8.0 httpx: 0.28.1 jsonpatch: 1.33 langgraph: 1.1.8 openai: 2.32.0 orjson: 3.11.8 packaging: 26.1 pydantic: 2.13.2 pyyaml: 6.0.3 requests: 2.33.1 requests-toolbelt: 1.0.0 tenacity: 9.1.4 tiktoken: 0.12.0 typing-extensions: 4.15.0 uuid-utils: 0.14.1 websockets: 16.0 xxhash: 3.6.0 zstandard: 0.25.0

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

OpenAI computer_call outputs should be exposed to LangChain agents as executable tool calls.

For example, the screenshot request above should result in something equivalent to:

{
    "name": "computer_call",
    "args": {"action": "screenshot"},
    "id": "call_3cNfranspy4UFye2mJ8tyKQs",
    "type": "tool_call",
}

or another LangChain-native representation that allows the agent loop to execute the computer action and return the corresponding computer_call_output.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING