Skip to content

OpenAI responses.compact() not instrumented (wrapper and auto-instrumentation) #1702

@braintrust-bot

Description

@braintrust-bot

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 intercepts create, stream, and parse. The compact method falls through to Reflect.get untraced.
  • Auto-instrumentation config (js/src/auto-instrumentations/configs/openai.ts): Only defines configs for Responses.create, Responses.stream, and Responses.parse (lines 147–188). No config for Responses.compact.
  • Channels (js/src/instrumentation/plugins/openai-channels.ts): Only responsesCreate, responsesStream, and responsesParse are defined. No responsesCompact channel.
  • 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 Responses class includes compact() alongside create, stream, parse, retrieve, delete, and cancel.
  • compact() is an AI inference call — it requires a model parameter 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.ts and openai-common.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    bot-automationIssues generated by an agent automation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions