Skip to content

fix(openai): preserve response output content index - #1437

Open
yaodong-shen wants to merge 1 commit into
AgentOps-AI:mainfrom
yaodong-shen:fix/openai-response-content-index
Open

fix(openai): preserve response output content index#1437
yaodong-shen wants to merge 1 commit into
AgentOps-AI:mainfrom
yaodong-shen:fix/openai-response-content-index

Conversation

@yaodong-shen

Copy link
Copy Markdown

📥 Pull Request

📘 Description

Fixes #1436.

OpenAI Responses can return a reasoning output before the assistant message. The message metadata correctly used its index in response.output, but nested ResponseOutputText attributes used the index within message.content. This placed message text under the preceding reasoning completion and left the actual message completion without content.

This change preserves the parent output index while extracting nested message text. The regression test uses the real OpenAI response models and verifies that a reasoning item at index 0 cannot absorb message content from index 1.

🧪 Testing

  • .venv/bin/python -m pytest tests/unit/instrumentation/openai_core/test_response_attributes.py -q -o log_cli=false — 14 passed
  • .venv/bin/python -m pytest tests/unit -q -o log_cli=false — 489 passed, 1 skipped
  • targeted Ruff check and format check — passed
  • project pre-commit hooks on both changed files — passed
  • git diff --check — passed

Use the parent output item's completion index for nested message content so reasoning outputs cannot absorb the following message text. Add coverage with real OpenAI response models.
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.

OpenAI Responses message content uses the wrong completion index

1 participant