-
Notifications
You must be signed in to change notification settings - Fork 3
OpenAI responses.compact() not instrumented (wrapper and auto-instrumentation) #1702
Description
Summary
The OpenAI Node SDK provides a stable responses.compact() method (since v6.10.0) that uses an AI model to compress conversation history, but neither the wrapper (wrapOpenAI) nor the auto-instrumentation plugin instruments it. Calls to responses.compact() produce no Braintrust spans. The other three methods on the same Responses class — create, stream, and parse — are all fully instrumented.
What is missing
- Wrapper (
js/src/wrappers/oai_responses.ts):responsesProxy(lines 27–48) only interceptscreate,stream, andparse. Thecompactmethod falls through toReflect.getuntraced. - Auto-instrumentation config (
js/src/auto-instrumentations/configs/openai.ts): Only defines configs forResponses.create,Responses.stream, andResponses.parse(lines 147–188). No config forResponses.compact. - Channels (
js/src/instrumentation/plugins/openai-channels.ts): OnlyresponsesCreate,responsesStream, andresponsesParseare defined. NoresponsesCompactchannel. - Plugin (
js/src/instrumentation/plugins/openai-plugin.ts): No handler for compact calls.
Upstream reference
- OpenAI Responses Compact API: https://platform.openai.com/docs/api-reference/responses/compact
- OpenAI Conversation State guide: https://platform.openai.com/docs/guides/conversation-state
- OpenAI Node SDK
Responsesclass includescompact()alongsidecreate,stream,parse,retrieve,delete, andcancel. compact()is an AI inference call — it requires amodelparameter and uses that model to intelligently compress conversation context. It consumes tokens and incurs model usage costs.- Added in OpenAI Node SDK v6.10.0 (December 2025). Not marked beta or experimental.
- Parameters:
model(required),input(conversation messages),instructions(optional system prompt for compaction).
Braintrust docs status
The Braintrust trace-llm-calls page documents responses.create() and mentions streaming support but does not mention responses.compact() (not_found).
Precedent in this repo
The three sibling methods on the same Responses class are instrumented across all layers:
| Method | Wrapper | Auto-instrumentation | Channel | Plugin |
|---|---|---|---|---|
create |
oai_responses.ts:29 |
openai.ts:148 |
responsesCreate |
Yes |
stream |
oai_responses.ts:34 |
openai.ts:162 |
responsesStream |
Yes |
parse |
oai_responses.ts:39 |
openai.ts:176 |
responsesParse |
Yes |
compact |
Missing | Missing | Missing | Missing |
Since compact returns a response object with the same structure as create, the existing responsesCreate plugin handler logic (input/output extraction, metrics, metadata) should be largely reusable.
Local files inspected
js/src/wrappers/oai_responses.ts(lines 27–48: proxy only intercepts create/stream/parse)js/src/auto-instrumentations/configs/openai.ts(lines 147–188: only create/stream/parse)js/src/instrumentation/plugins/openai-channels.ts(only responsesCreate/Stream/Parse)js/src/instrumentation/plugins/openai-plugin.ts(no compact handler)js/src/vendor-sdk-types/openai.tsandopenai-common.ts