Skip to content

effect/ai: provider web_search tool-result is treated as local tool output and sent to OpenAI /responses API as function_call_output #5939

@tensor2077

Description

@tensor2077

What version of Effect is running?

effect/ai 0.33.0

What steps can reproduce the bug?

  1. Enable the provider-defined web_search tool and send a streaming /responses request (gpt5.2).
  2. Ask the model to perform a web search (e.g., “Use web search to define AI agent and summarize.”).
  3. After the first turn completes, send a second message in the same chat session (any text).
  4. Observe HTTP 400: No tool call found for function call output with call_id ws_....

What is the expected behavior?

success response

What do you see instead?

{
"error": {
"message": "No tool call found for function call output with call_id ws_029e7d51de056f790069536f1df6488196ab10f32c7a3d915e.",
"type": "invalid_request_error",
"param": "input",
"code": null
}
}

Additional information

After the first turn (a web search + answer), the persisted history looks like:

 {
    "content": [
      {
        "role": "system",
        "content": "You are an AI assistant.",
        "options": {}
      },
      {
        "role": "user",
        "content": "Use web search to look up the concept of an acquisition and summarize briefly.",
        "options": {}
      },
      {
        "role": "assistant",
        "content": [
          {
            "type": "tool-call",
            "id": "ws_029e7d51de056f790069536f1df6488196ab10f32c7a3d915e",
            "name": "web_search",
            "params": {
              "action": {
                "type": "search",
                "query": "acquisition definition",
                "sources": [{ "type": "url", "url": "https://en.wikipedia.org/wiki/Acquisition" }]
              }
            },
            "providerExecuted": true,
            "options": {}
          },
          {
            "type": "text",
            "text": "An acquisition is ...",
            "options": {}
          }
        ],
        "options": {}
      },
      {
        "role": "tool",
        "content": [
          {
            "type": "tool-result",
            "id": "ws_029e7d51de056f790069536f1df6488196ab10f32c7a3d915e",
            "name": "web_search",
            "isFailure": false,
            "result": { "status": "completed" },
            "options": {}
          }
        ],
        "options": {}
      }
    ]
  }

So far, everything looks correct.
However, sending any second user message fails with:

  {
    "error": {
      "message": "No tool call found for function call output with call_id ws_029e7d51de056f790069536f1df6488196ab10f32c7a3d915e.",
      "type": "invalid_request_error",
      "param": "input",
      "code": null
    }
  }

ERROR cause

The provider-executed tool result

 {
        "role": "tool",
        "content": [
          {
            "type": "tool-result",
            "id": "ws_029e7d51de056f790069536f1df6488196ab10f32c7a3d915e",
            "name": "web_search",
            "isFailure": false,
            "result": { "status": "completed" },
            "options": {}
          }
        ],
        "options": {}
      }

was mistakenly treated as a local tool call result and sent back to the OpenAI API as a function_call_output.

The request payload look like this

{
    "model": "gpt-5.2",
    "reasoning": {
        "summary": "auto"
    },
    "input": [
        {
            "role": "developer",
            "content": "You are an AI assistant."
        },
        {
            "role": "user",
            "content": [
                {
                    "type": "input_text",
                    "text": ""
                }
            ]
        },
        {
            "role": "user",
            "content": [
                {
                    "type": "input_text",
                    "text": "Use web search to look up the concept of an acquisition and summarize briefly."
                }
            ]
        },
        {
            "role": "assistant",
            "content": [
                {
                    "type": "output_text",
                    "text": "{AI_RESPONSE_TEXT}"
                }
            ]
        },
        {
            "type": "function_call_output",
            "call_id": "ws_029e7d51de056f790069536f1df6488196ab10f32c7a3d915e",
            "output": "{\"status\":\"completed\"}"
        },
        {
            "role": "user",
            "content": [
                {
                    "type": "input_text",
                    "text": "go on"
                }
            ]
        }
    ],
    "include": [
        "web_search_call.action.sources"
    ],
    "text": {
        "format": {
            "type": "text"
        }
    },
    "tools": [
        {
            "search_context_size": "medium",
            "type": "web_search"
        }
    ],
    "tool_choice": "auto",
    "stream": true
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions