Repository navigation
fix(mcp): Restore sentry-mcp User-Agent on streamText provider calls - #2011
Merged
Merged
Conversation
…llers #1994 moved the embedded agent's User-Agent onto the generateText call and dropped it from the providers. The chat playground calls streamText with getOpenRouterModel() directly, and streamText adds no call-level user-agent, so playground requests stopped sending sentry-mcp/... at all. Restore the header on all four providers, still computed when the model is built, and keep the call-level header in callEmbeddedAgent, which generateText would otherwise overwrite. Add a streamText test. In the bundle User-Agent test, drain the child's stderr into failure messages and turn a non-JSON stdout line into a clean failure.
…ider Replace the OpenRouter-only streamText test with one parametrized over OpenAI, Anthropic, OpenRouter, and Azure OpenAI (v1 and deployment URLs), built through the real provider factory. Removing the header from any one provider fails its case. Co-Authored-By: David Cramer <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
7 tasks done
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#1994 (
d32e146) moved the embedded agent'sUser-Agentonto thegenerateTextcall and removed it from the four LLM providers. That fixedcallEmbeddedAgent, wheregenerateText's own call-leveluser-agentreplaced the provider header.It broke direct
streamTextcallers. The chat playground's/api/chatroute (packages/mcp-cloudflare/src/server/routes/chat.ts) callsstreamText({ model: getOpenRouterModel(), … }).streamTextadds no call-level user-agent, so since #1994 playground requests send onlyai-sdk/openai/… ai-sdk/provider-utils/… runtime/…and nosentry-mcp/....This puts
"User-Agent": getUserAgent()back on all four providers: OpenAI, Anthropic, OpenRouter, and Azure OpenAI. The header is still computed when the model is built, not at module load. The call-level header ongenerateTextincallEmbeddedAgentstays, becausegenerateTextwould otherwise overwrite the provider's. Having both is harmless: the call-level value wins where it's set, and the provider value covers any directstreamTextcaller.Tests:
provider-user-agent.test.tsbuilds each provider through the realsetAgentProvider/setProviderBaseUrlsfactory, with a stubbedfetchandsetServerVersion("1.2.3-x"). It callsstreamTextand asserts exactly oneuser-agentthat starts withsentry-mcp/1.2.3-x (https://mcp.sentry.dev). It covers OpenAI, Anthropic, OpenRouter, and both Azure URL shapes (/openai/v1and/openai/deployments/<name>).bundle.test.mjs: the User-Agent test now drains the child's stderr into its failure messages. A non-JSON stdout line now fails the test cleanly instead of throwing an uncaught exception.Review: a reviewer passed
9885b7b(the fix plus the bundle test change) with no must-fix findings.00b74e0came after that review. It replaces the OpenRouter-only test with the parametrized test for all four providers.Checks: all scoped to the affected packages, with
SENTRY_AUTH_TOKENunset.bundle.test.mjs(17).pnpm run lintpasses.pnpm run tsc/test/build: they build mcp-cloudflare, which uploads source maps.via @dcramer.
--
View Session [Sentry]