Skip to content

fix(ai): accept responses calls without item ids - #45081

Merged
rekram1-node merged 1 commit into
v2from
optional-call-id
Aug 25, 2026
Merged

rekram1-node merged 1 commit into
v2from
optional-call-id

Conversation

@rekram1-node

Copy link
Copy Markdown
Collaborator

Summary

  • accept valid Responses function_call output items that include required call_id but omit optional provider item id
  • route streamed arguments and terminal reconciliation using the actual item ID when present or call_id otherwise
  • preserve public tool identity and call/result pairing by call_id without inventing provider item metadata
  • retain required event-level item_id validation and existing WebSocket incremental continuation

Before and after

The Responses API permits a completed function call without an item ID:

{
  "type": "response.output_item.done",
  "item": {
    "type": "function_call",
    "call_id": "call_1",
    "name": "lookup",
    "arguments": "{\"query\":\"weather\"}"
  }
}

Before: OpenCode ignored the call because item.id was absent.

After: OpenCode emits the normal tool call with ID call_1, parses its arguments, and replays the subsequent history without fabricating a provider item ID:

[
  { "type": "function_call", "call_id": "call_1", "name": "lookup", "arguments": "{\"query\":\"weather\"}" },
  { "type": "function_call_output", "call_id": "call_1", "output": "{\"forecast\":\"sunny\"}" }
]

Argument-stream events still require their own protocol-level item_id; when it differs from call_id, registered output_index routes the event to the correct pending call.

Verification

  • bun test test/partial-json.test.ts test/tool-stream.test.ts test/provider/openai-responses.test.ts test/provider/openai-compatible-responses.test.ts test/provider/openai-responses-images.recorded.test.ts test/provider/openai-responses-websocket.recorded.test.ts test/provider/openai-chat.test.ts test/provider/anthropic-messages.test.ts test/provider/bedrock-converse.test.ts test/provider/xai-responses.test.ts test/response.test.ts test/tool-runtime.test.ts --timeout 30000 --only-failures (379 passing)
  • RECORDED_PREFIX=openai-responses bun test test/provider/golden.recorded.test.ts --timeout 30000 --only-failures
  • bun typecheck from packages/ai
  • bunx prettier --check packages/ai/src/protocols/open-responses.ts packages/ai/test/provider/openai-responses.test.ts packages/ai/test/provider/openai-compatible-responses.test.ts

@rekram1-node
rekram1-node merged commit 0a84625 into v2 Aug 25, 2026
8 of 9 checks passed
@rekram1-node
rekram1-node deleted the optional-call-id branch August 25, 2026 22:29
jinhuang712 pushed a commit to jinhuang712/opencode that referenced this pull request Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant