You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Preserve raw response bodies in automatic AI instrumentation #24882
Automatic AI instrumentation eagerly observes custom API promises, which can consume the response body before application code reads it. The request succeeds, but reading the raw response fails:
constresponse=awaitclient.messages.create(body).asResponse();awaitresponse.json();// TypeError: Body is unusable: Body has already been read
Groq and Together: chat.completions.create(...).asResponse()
OpenAI: embeddings.create(...).asResponse() and conversations.create(...).asResponse()
Ordinary await create(...) works. Anthropic messages.parse() and beta.messages.parse() also worked in the tested version; this is not a general failure of structured output helpers.
Anthropic's APIPromise extends the native Promise. Its .then() triggers parsing, whereas .asResponse() accesses the underlying HTTP response without parsing. Sentry's automatic instrumentation uses Auto for Anthropic, Groq/Together, and the remaining OpenAI methods, which starts parsing through promise observation.
Follow up on #24783, which fixes automatic OpenAI chat/responses parsing. Preserve lazy body consumption across the affected integrations while retaining span completion and streaming behavior. Add regression tests that actually read .asResponse() bodies and verify spans, alongside normal and structured output calls.
Reproduced with OpenAI 5.18.1, Anthropic 0.63.0 and 0.129.0, Groq 1.6.0, and Together 0.54.0. No equivalent failure reproduced in the tested Google GenAI, Vercel AI, LangChain, LangGraph, Mistral, or TypeSafe paths. Scope: automatic instrumentation; manual wrapper issues are separate.
Activity
linear-code commentedon Sep 30, 2026
JS-3856
fix(server-utils): Preserve raw Groq and Together response bodies (#2…
fix(server-utils): Preserve raw OpenAI embeddings and conversation re…
github-actions commentedon Oct 1, 2026
A PR closing this issue has just been released 🚀
This issue was referenced by PR #24908, which was included in the 11.2.0 release.