openllmetry
openllmetry copied to clipboard
Responses API: Remove completed responses from the global responses dictionary
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
responsesdictionary is empty after a completed response.
already fixed in #4531