feat(agent): identify Agent SDK traffic in the user agent - #120
feat(agent): identify Agent SDK traffic in the user agent#120LukasParke wants to merge 1 commit into
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Original prompt from Luke
|
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Summary
@openrouter/agentnow identifies itself in theuser-agentheader, so OpenRouter can attribute traffic to the Agent SDK and to a specific agent package version instead of inferring it. Today an agent request is indistinguishable on the wire from a direct@openrouter/sdkrequest, apart from thex-openrouter-callmodelmarker that onlycallModelsends.The
OpenRouterclient defaultsSDKOptions.userAgent, and an explicit caller value still wins:AGENT_USER_AGENTappends one conventionalproduct/versiontoken to the generated Speakeasy string, keeping the base byte-identical so anything already parsing it keeps working:Both halves are composed at runtime from
SDK_METADATA.userAgentand the generatedPACKAGE_VERSION, so a dependency bump or a release moves them without another edit here.Two design points worth stating, both of which are why the
x-openrouter-callmodelheader stays exactly as it was:@openrouter/sdkskips the user agent entirely underif (!isBrowserLike), because CORS forbids setting it.options.headers, readingclient._options.userAgentper operation, so a per-request header cannot win.callModelalso accepts anyOpenRouterCore, and a caller who passes a plain SDK client is deliberately left alone rather than having their client's options mutated.The matching analytics side is openrouter-web#37298, which parses this string into
sdk_client,sdk_package,sdk_versionand the agent version on generations.How I verified
pnpm run lint,pnpm run typecheck,pnpm run build,pnpm run testandpnpm run verify:packagesall pass. Full agent suite is 103 files and 1222 tests.Requestthrough an injectedhttpClient. That is the test that fails if the SDK ever changes its override order:speakeasy-sdk/typescriptprefix and a trailing@openrouter/agent/<semver>token, so a reformat of the string breaks the test here rather than silently dropping attribution in production.pnpm run test:e2ewas not run, it requires a liveOPENROUTER_API_KEY.Link to Devin session: https://openrouter.devinenterprise.com/sessions/4694f6390dd142739b1941b796452585
Requested by: @LukasParke