Skip to content

fix(portkey): do not consume generator content and map image parts (#829) - #988

Open
VimalN2005 wants to merge 2 commits into
open-telemetry:mainfrom
VimalN2005:fix/portkey-generator-content-829
Open

VimalN2005 wants to merge 2 commits into
open-telemetry:mainfrom
VimalN2005:fix/portkey-generator-content-829

Conversation

@VimalN2005

@VimalN2005 VimalN2005 commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #829.

When OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT is enabled:

  1. _prepare_input_messages iterated generic Iterable content. If content was a generator or iterator (or if messages/tools were one-shot iterables), walking it prior to the wrapped SDK invocation drained it, causing empty content to be sent to the model provider.
  2. Non-list sequences (such as tuple inputs for messages and content) were either dropped or lacked full sequence handling.
  3. Image parts (e.g., image_url dicts or data URLs) were skipped instead of being mapped to BlobPart or UriPart.

Changes Made

  • Restricted iteration of content, messages, and tools to Sequence (excluding str, bytes, bytearray), ensuring generator/iterator content is not consumed by telemetry prior to the client call.
  • Accepted tuple inputs for messages, content, and tool sequences.
  • Added _extract_content_part to map image parts using image_from_url (BlobPart for base64 data URLs, UriPart for standard URLs).
  • Added unit regression tests covering unconsumed generator content, tuple inputs, and image part extraction.
  • Added changelog fragment .changelog/829.fixed.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation / Changelog update

Testing

Ran unit tests for opentelemetry-instrumentation-genai-portkey:

@VimalN2005
VimalN2005 requested a review from a team as a code owner October 26, 2026 11:07
Copilot AI balanced review requested due to automatic review settings October 26, 2026 11:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Waiting on the author · refreshed 2026-10-28 20:49 UTC

Two things need attention:

  • Required checks are failing — investigate the failures.
  • 1 review item — respond to each (e.g. link a commit, explain why not, ask a follow-up):
    • Top-level threads: 1
Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Should this be with reviewers? Comment /dashboard route:reviewers to route it to them.
  • Anything wrong — including the routing? Report it with what you expected; it helps us improve the dashboard.

@DylanRussell

Copy link
Copy Markdown
Contributor

#843 is a related PR.. not sure exactly what the status is of that one.. author stopped responding

@VimalN2005
VimalN2005 force-pushed the fix/portkey-generator-content-829 branch from e957283 to 94e10f0 Compare October 28, 2026 20:19

This branch has not been deployed

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

[genai-portkey] With content capture enabled, generator/iterator message content is consumed and sent empty

4 participants