Skip to content

fix(llm): replay OpenAI Responses hosted tool history as native input items #29159

Closed as not planned

Description

@gzb1128

Description

The native OpenAI Responses adapter rejects replayed assistant history that contains provider-executed hosted tool results.

This affects the native @opencode-ai/llm OpenAI Responses path, not the default TS AI SDK path. The failure happens before any network call:

ProviderShared.request: OpenAI Responses assistant messages only support text, reasoning, and tool-call content for now

Root cause: OpenAI Responses hosted tools such as web_search_call are parsed into common tool-call + tool-result events with providerExecuted: true. The tool runtime can later replay those as assistant message content, but openai-responses.ts only lowers assistant text, reasoning, and tool-call parts.

Based on Codex’s Responses handling, hosted tool history should be replayed as native top-level Responses input items, for example:

{
  "type": "web_search_call",
  "id": "ws_1",
  "status": "completed",
  "action": { "type": "search", "query": "effect 4" }
}

Suggested fix: detect matching providerExecuted tool-call + tool-result pairs in lowerMessages, and lower them to native hosted Responses input items (or item_reference when stored state is usable). Malformed or mismatched hosted results should fail with a clear invalid-request error.

Repro branch: https://github.com/gzb1128/opencode/tree/repro/openai-responses-hosted-tool-history

I’d be happy to take this issue and submit a PR if maintainers agree with the direction.

Plugins

N/A

OpenCode version

Current dev checkout: 03bb53c38 (@opencode-ai/llm package version 1.15.10)

Steps to reproduce

  1. Check out the repro branch:
git fetch https://github.com/gzb1128/opencode.git repro/openai-responses-hosted-tool-history
git switch --detach FETCH_HEAD
  1. Run from packages/llm:
bun test test/provider/openai-responses.test.ts -t "replays provider-executed hosted tool results in assistant history"

Actual result:

ProviderShared.request: OpenAI Responses assistant messages only support text, reasoning, and tool-call content for now

Expected result:

The request should prepare successfully and include the hosted tool as a top-level OpenAI Responses input item, not as assistant tool-result content or generic function_call history.

Screenshot and/or share link

N/A

Operating System

macOS

Terminal

N/A

Activity

  1. github-actions commented on Jul 25, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions