Skip to content

fix: align responses ids and text handling#1310

Merged
zerob13 merged 2 commits intodevfrom
fix/responses-api-alignment
Feb 13, 2026
Merged

fix: align responses ids and text handling#1310
zerob13 merged 2 commits intodevfrom
fix/responses-api-alignment

Conversation

@yyhhyyyyyy
Copy link
Collaborator

@yyhhyyyyyy yyhhyyyyyy commented Feb 13, 2026

Aligned our OpenAI Responses integration with official docs by using input_text/output_text correctly and fixing streamed function-call item_id/call_id mapping with regression tests.

Summary by CodeRabbit

  • Bug Fixes

    • Improved robustness of tool call event handling during OpenAI streaming by ensuring consistent internal call identifier mapping throughout the response stream, reducing potential mismatches.
  • Tests

    • Added comprehensive test coverage for tool call mapping logic, validating streaming scenarios with varying identifier configurations to ensure correct event emission.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 13, 2026

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

💤 Files selected but had no reviewable changes (1)
  • resources/model-db/providers.json

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR enhances OpenAI response provider's tool call tracking by introducing state mappings to correlate item IDs, output indices, and call IDs, ensuring consistent tool_call_id references in streamed events while replacing dynamic response parsing with fixed content type assignment.

Changes

Cohort / File(s) Summary
Tool Call ID Mapping & Event Handling
src/main/presenter/llmProviderPresenter/providers/openAIResponsesProvider.ts, test/main/presenter/llmProviderPresenter/openAIResponsesProvider.test.ts
Added nativeToolCallIdByItemId and nativeToolCallIdByOutputIndex state mappings to track and resolve tool call IDs across streaming chunks. Updated tool_call_start, tool_call_chunk, and tool_call_end events to use derived callId instead of raw item.call_id. Enhanced both native and non-native function call handling with consistent ID resolution. Changed response parsing from response.output[0].content to response.output_text. Added comprehensive test suite validating ID mapping with itemId and output_index fallback scenarios.

Sequence Diagram

sequenceDiagram
    participant OpenAI as OpenAI API
    participant Provider as OpenAI Provider
    participant State as State Mappings
    participant EventBus as Event Bus

    OpenAI->>Provider: Stream: output_item.added (item.id, item.call_id)
    Provider->>State: Store nativeToolCallIdByItemId[item.id] = item.call_id
    Provider->>EventBus: Emit tool_call_start (tool_call_id = resolved callId)

    OpenAI->>Provider: Stream: function_call_arguments.delta
    Provider->>State: Lookup callId via itemId or output_index
    Provider->>EventBus: Emit tool_call_chunk (tool_call_id = resolved callId, partial args)

    OpenAI->>Provider: Stream: function_call_arguments.done
    Provider->>State: Retrieve complete arguments from mapping
    Provider->>EventBus: Emit tool_call_chunk (tool_call_id = resolved callId, complete args)

    OpenAI->>Provider: Stream: output_item.done
    Provider->>State: Store mapping for output_index to call_id
    Provider->>EventBus: Emit tool_call_end (tool_call_id = resolved callId)
    
    OpenAI->>Provider: Stream: completed
    Provider->>EventBus: Emit stop (reason = 'tool_use')
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly Related PRs

Poem

🐰 Hop, hop! The provider now tracks every call,
With mappings precise and IDs that don't fall,
Each stream chunk knows its ID, no more missing trace,
The tests verify the flow—events land in their place! ✨

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: align responses ids and text handling' directly addresses the main changes: correcting ID mapping and response text handling in OpenAI responses provider.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into dev

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/responses-api-alignment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@yyhhyyyyyy yyhhyyyyyy requested a review from zerob13 February 13, 2026 12:00
@zerob13 zerob13 merged commit c6facde into dev Feb 13, 2026
2 checks passed
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.

2 participants