@@ -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 ;
@@ -45,14 +46,6 @@ export interface ChatSessionWithPR extends vscode.ChatSessionItem {
4546 pullRequest : PullRequestModel ;
4647}
4748
48- export interface ChatSessionFromSummarizedChat extends vscode . ChatSessionItem {
49- prompt : string ;
50- summary ?: string ;
51- // Cache
52- pullRequest ?: PullRequestModel ;
53- sessionInfo ?: SessionInfo ;
54- }
55-
5649export class CopilotApi {
5750 protected static readonly ID = 'copilotApi' ;
5851
@@ -79,10 +72,15 @@ export class CopilotApi {
7972 owner : string ,
8073 name : string ,
8174 payload : RemoteAgentJobPayload ,
75+ isTruncated : boolean ,
8276 ) : Promise < RemoteAgentJobResponse > {
8377 const repoSlug = `${ owner } /${ name } ` ;
8478 const apiUrl = `/agents/swe/v0/jobs/${ repoSlug } ` ;
8579 let status : number | undefined ;
80+
81+ const problemStatementLength = payload . problem_statement . length . toString ( ) ;
82+ const payloadJson = JSON . stringify ( payload ) ;
83+ const payloadLength = payloadJson . length . toString ( ) ;
8684 Logger . trace ( `postRemoteAgentJob: Posting job to ${ apiUrl } with payload: ${ JSON . stringify ( payload ) } ` , CopilotApi . ID ) ;
8785 try {
8886 const response = await this . makeApiCall ( apiUrl , {
@@ -93,7 +91,7 @@ export class CopilotApi {
9391 'Content-Type' : 'application/json' ,
9492 'Accept' : 'application/json'
9593 } ,
96- body : JSON . stringify ( payload )
94+ body : payloadJson
9795 } ) ;
9896
9997 status = response . status ;
@@ -106,21 +104,33 @@ export class CopilotApi {
106104 /*
107105 __GDPR__
108106 "remoteAgent.postRemoteAgentJob" : {
109- "status" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
107+ "status" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
108+ "payloadLength": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
109+ "problemStatementLength": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
110+ "isTruncated": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
110111 }
111112 */
112113 this . telemetry . sendTelemetryEvent ( 'remoteAgent.postRemoteAgentJob' , {
113114 status : status . toString ( ) ,
115+ payloadLength,
116+ problemStatementLength,
117+ isTruncated : isTruncated . toString ( ) ,
114118 } ) ;
115119 return data ;
116120 } catch ( error ) {
117121 /* __GDPR__
118122 "remoteAgent.postRemoteAgentJob" : {
119- "status" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
123+ "status" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
124+ "payloadLength": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
125+ "problemStatementLength": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
126+ "isTruncated": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
120127 }
121128 */
122129 this . telemetry . sendTelemetryErrorEvent ( 'remoteAgent.postRemoteAgentJob' , {
123130 status : status ?. toString ( ) || '999' ,
131+ payloadLength,
132+ problemStatementLength,
133+ isTruncated : isTruncated . toString ( ) ,
124134 } ) ;
125135 throw error ;
126136 }
0 commit comments