@@ -19,7 +19,8 @@ import { hasEnterpriseUri } from './utils';
1919
2020const LEARN_MORE_URL = 'https://aka.ms/coding-agent-docs' ;
2121const PREMIUM_REQUESTS_URL = 'https://docs.github.com/en/copilot/concepts/copilot-billing/understanding-and-managing-requests-in-copilot#what-are-premium-requests' ;
22-
22+ // https://github.com/github/sweagentd/blob/59e7d9210ca3ebba029918387e525eea73cb1f4a/internal/problemstatement/problemstatement.go#L36-L53
23+ export const MAX_PROBLEM_STATEMENT_LENGTH = 30_000 - 50 ; // 50 character buffer
2324export interface RemoteAgentJobPayload {
2425 problem_statement : string ;
2526 event_type : string ;
@@ -79,10 +80,15 @@ export class CopilotApi {
7980 owner : string ,
8081 name : string ,
8182 payload : RemoteAgentJobPayload ,
83+ isTruncated : boolean ,
8284 ) : Promise < RemoteAgentJobResponse > {
8385 const repoSlug = `${ owner } /${ name } ` ;
8486 const apiUrl = `/agents/swe/v0/jobs/${ repoSlug } ` ;
8587 let status : number | undefined ;
88+
89+ const problemStatementLength = payload . problem_statement . length . toString ( ) ;
90+ const payloadJson = JSON . stringify ( payload ) ;
91+ const payloadLength = payloadJson . length . toString ( ) ;
8692 Logger . trace ( `postRemoteAgentJob: Posting job to ${ apiUrl } with payload: ${ JSON . stringify ( payload ) } ` , CopilotApi . ID ) ;
8793 try {
8894 const response = await this . makeApiCall ( apiUrl , {
@@ -93,7 +99,7 @@ export class CopilotApi {
9399 'Content-Type' : 'application/json' ,
94100 'Accept' : 'application/json'
95101 } ,
96- body : JSON . stringify ( payload )
102+ body : payloadJson
97103 } ) ;
98104
99105 status = response . status ;
@@ -106,21 +112,33 @@ export class CopilotApi {
106112 /*
107113 __GDPR__
108114 "remoteAgent.postRemoteAgentJob" : {
109- "status" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
115+ "status" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
116+ "payloadLength": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
117+ "problemStatementLength": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
118+ "isTruncated": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
110119 }
111120 */
112121 this . telemetry . sendTelemetryEvent ( 'remoteAgent.postRemoteAgentJob' , {
113122 status : status . toString ( ) ,
123+ payloadLength,
124+ problemStatementLength,
125+ isTruncated : isTruncated . toString ( ) ,
114126 } ) ;
115127 return data ;
116128 } catch ( error ) {
117129 /* __GDPR__
118130 "remoteAgent.postRemoteAgentJob" : {
119- "status" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
131+ "status" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
132+ "payloadLength": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
133+ "problemStatementLength": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
134+ "isTruncated": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
120135 }
121136 */
122137 this . telemetry . sendTelemetryErrorEvent ( 'remoteAgent.postRemoteAgentJob' , {
123138 status : status ?. toString ( ) || '999' ,
139+ payloadLength,
140+ problemStatementLength,
141+ isTruncated : isTruncated . toString ( ) ,
124142 } ) ;
125143 throw error ;
126144 }
0 commit comments