@@ -3,6 +3,7 @@ import { v7 as uuidv7 } from "uuid"
33import { Anthropic } from "@anthropic-ai/sdk"
44import OpenAI from "openai"
55
6+ import { Package } from "../../shared/package"
67import {
78 type ModelInfo ,
89 openAiNativeDefaultModelId ,
@@ -83,12 +84,14 @@ export class OpenAiNativeHandler extends BaseProvider implements SingleCompletio
8384 }
8485 const apiKey = this . options . openAiNativeApiKey ?? "not-provided"
8586 // Include originator, session_id, and User-Agent headers for API tracking and debugging
87+ const userAgent = `roo-code/${ Package . version } (${ os . platform ( ) } ${ os . release ( ) } ; ${ os . arch ( ) } ) node/${ process . version . slice ( 1 ) } `
8688 this . client = new OpenAI ( {
8789 baseURL : this . options . openAiNativeBaseUrl ,
8890 apiKey,
8991 defaultHeaders : {
9092 originator : "roo-code" ,
9193 session_id : this . sessionId ,
94+ "User-Agent" : userAgent ,
9295 } ,
9396 } )
9497 }
@@ -406,9 +409,11 @@ export class OpenAiNativeHandler extends BaseProvider implements SingleCompletio
406409
407410 // Build per-request headers using taskId when available, falling back to sessionId
408411 const taskId = metadata ?. taskId
412+ const userAgent = `roo-code/${ Package . version } (${ os . platform ( ) } ${ os . release ( ) } ; ${ os . arch ( ) } ) node/${ process . version . slice ( 1 ) } `
409413 const requestHeaders : Record < string , string > = {
410414 originator : "roo-code" ,
411415 session_id : taskId || this . sessionId ,
416+ "User-Agent" : userAgent ,
412417 }
413418
414419 try {
@@ -550,6 +555,7 @@ export class OpenAiNativeHandler extends BaseProvider implements SingleCompletio
550555
551556 // Build per-request headers using taskId when available, falling back to sessionId
552557 const taskId = metadata ?. taskId
558+ const userAgent = `roo-code/${ Package . version } (${ os . platform ( ) } ${ os . release ( ) } ; ${ os . arch ( ) } ) node/${ process . version . slice ( 1 ) } `
553559
554560 try {
555561 const response = await fetch ( url , {
@@ -560,6 +566,7 @@ export class OpenAiNativeHandler extends BaseProvider implements SingleCompletio
560566 Accept : "text/event-stream" ,
561567 originator : "roo-code" ,
562568 session_id : taskId || this . sessionId ,
569+ "User-Agent" : userAgent ,
563570 } ,
564571 body : JSON . stringify ( requestBody ) ,
565572 signal : this . abortController . signal ,
0 commit comments