openllmetry icon indicating copy to clipboard operation
openllmetry copied to clipboard

Responses API: Remove completed responses from the global responses dictionary

Open archiep867-sys opened this issue 1 month ago • 1 comments

The OpenAI Responses API instrumentation stores trace data in a module-level responses dictionary in responses_wrappers.py. However, completed responses are never removed after their spans end, causing the dictionary to grow continuously in long-running applications.

Suggested fix:

  • Remove the response entry with responses.pop(response_id, None) when the span ends.
  • Apply the cleanup to the synchronous, asynchronous, and streaming response paths.
  • Add a test verifying that the responses dictionary is empty after a completed response.

archiep867-sys avatar Oct 06 '26 16:10 archiep867-sys

already fixed in #4531

doronkopit5 avatar Oct 06 '26 18:10 doronkopit5