@@ -99,6 +99,7 @@ import { getMessagesSinceLastSummary, summarizeConversation } from "../condense"
99
99
import { maybeRemoveImageBlocks } from "../../api/transform/image-cleaning"
100
100
import { restoreTodoListForTask } from "../tools/updateTodoListTool"
101
101
import { AutoApprovalHandler } from "./AutoApprovalHandler"
102
+ import { Gpt5Metadata , ClineMessageWithMetadata } from "./types"
102
103
103
104
const MAX_EXPONENTIAL_BACKOFF_SECONDS = 600 // 10 minutes
104
105
@@ -711,9 +712,8 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
711
712
this . emit ( RooCodeEventName . TaskIdle , this . taskId )
712
713
}
713
714
714
- console . log ( `[Task# ${ this . taskId } ] pWaitFor askResponse( ${ type } ) -> blocking` )
715
+ // Wait for askResponse to be set
715
716
await pWaitFor ( ( ) => this . askResponse !== undefined || this . lastMessageTs !== askTs , { interval : 100 } )
716
- console . log ( `[Task#${ this . taskId } ] pWaitFor askResponse(${ type } ) -> unblocked (${ this . askResponse } )` )
717
717
718
718
if ( this . lastMessageTs !== askTs ) {
719
719
// Could happen if we send multiple asks in a row i.e. with
@@ -1012,7 +1012,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
1012
1012
1013
1013
let imageBlocks : Anthropic . ImageBlockParam [ ] = formatResponse . imageBlocks ( images )
1014
1014
1015
- console . log ( `[subtasks] task ${ this . taskId } . ${ this . instanceId } starting` )
1015
+ // Task starting
1016
1016
1017
1017
await this . initiateTaskLoop ( [
1018
1018
{
@@ -1048,7 +1048,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
1048
1048
}
1049
1049
1050
1050
private async resumeTaskFromHistory ( ) {
1051
- console . log ( `[Task# ${ this . taskId } ] Resuming task from history` )
1051
+ // Resuming task from history
1052
1052
1053
1053
if ( this . enableTaskBridge ) {
1054
1054
try {
@@ -1068,10 +1068,13 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
1068
1068
1069
1069
// Check for any stored GPT-5 response IDs in the message history
1070
1070
const gpt5Messages = modifiedClineMessages . filter (
1071
- ( m ) => m . type === "say" && ( m as any ) . say === "text" && ( m as any ) . metadata ?. gpt5 ?. previous_response_id ,
1071
+ ( m ) =>
1072
+ m . type === "say" &&
1073
+ m . say === "text" &&
1074
+ ( m as ClineMessageWithMetadata ) . metadata ?. gpt5 ?. previous_response_id ,
1072
1075
)
1073
1076
if ( gpt5Messages . length > 0 ) {
1074
- const lastGpt5Message = gpt5Messages [ gpt5Messages . length - 1 ] as any
1077
+ const lastGpt5Message = gpt5Messages [ gpt5Messages . length - 1 ] as ClineMessage & ClineMessageWithMetadata
1075
1078
}
1076
1079
1077
1080
// Remove any resume messages that may have been added before
@@ -1303,13 +1306,13 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
1303
1306
1304
1307
await this . overwriteApiConversationHistory ( modifiedApiConversationHistory )
1305
1308
1306
- console . log ( `[subtasks] task ${ this . taskId } . ${ this . instanceId } resuming from history item` )
1309
+ // Task resuming from history item
1307
1310
1308
1311
await this . initiateTaskLoop ( newUserContent )
1309
1312
}
1310
1313
1311
1314
public dispose ( ) : void {
1312
- console . log ( `[Task] disposing task ${ this . taskId } . ${ this . instanceId } ` )
1315
+ // Disposing task
1313
1316
1314
1317
// Stop waiting for child task completion.
1315
1318
if ( this . pauseInterval ) {
@@ -1372,7 +1375,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
1372
1375
}
1373
1376
1374
1377
public async abortTask ( isAbandoned = false ) {
1375
- console . log ( `[subtasks] aborting task ${ this . taskId } . ${ this . instanceId } ` )
1378
+ // Aborting task
1376
1379
1377
1380
// Will stop any autonomously running promises.
1378
1381
if ( isAbandoned ) {
@@ -1612,7 +1615,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
1612
1615
// lastMessage.ts = Date.now() DO NOT update ts since it is used as a key for virtuoso list
1613
1616
lastMessage . partial = false
1614
1617
// instead of streaming partialMessage events, we do a save and post like normal to persist to disk
1615
- console . log ( " updating partial message" , lastMessage )
1618
+ // updating partial message
1616
1619
// await this.saveClineMessages()
1617
1620
}
1618
1621
@@ -1713,7 +1716,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
1713
1716
}
1714
1717
1715
1718
if ( this . abort ) {
1716
- console . log ( `aborting stream, this.abandoned = ${ this . abandoned } ` )
1719
+ // Aborting stream
1717
1720
1718
1721
if ( ! this . abandoned ) {
1719
1722
// Only need to gracefully abort if this instance
@@ -2140,18 +2143,16 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
2140
2143
this . clineMessages ,
2141
2144
( m ) =>
2142
2145
m . type === "say" &&
2143
- ( m as any ) . say === "text" &&
2144
- ( m as any ) . metadata ?. gpt5 ?. previous_response_id ,
2146
+ m . say === "text" &&
2147
+ ! ! ( m as ClineMessageWithMetadata ) . metadata ?. gpt5 ?. previous_response_id ,
2145
2148
)
2146
2149
if ( idx !== - 1 ) {
2147
2150
// Use the previous_response_id from the last assistant message for this request
2148
- previousResponseId = ( ( this . clineMessages [ idx ] as any ) . metadata . gpt5 . previous_response_id ||
2149
- undefined ) as string | undefined
2151
+ const message = this . clineMessages [ idx ] as ClineMessage & ClineMessageWithMetadata
2152
+ previousResponseId = message . metadata ?. gpt5 ?. previous_response_id
2150
2153
}
2151
2154
} else if ( this . skipPrevResponseIdOnce ) {
2152
- console . log (
2153
- `[Task#${ this . taskId } ] Skipping previous_response_id due to recent condense operation - will send full conversation context` ,
2154
- )
2155
+ // Skipping previous_response_id due to recent condense operation - will send full conversation context
2155
2156
}
2156
2157
} catch ( error ) {
2157
2158
console . error ( `[Task#${ this . taskId } ] Error retrieving GPT-5 response ID:` , error )
@@ -2327,17 +2328,20 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
2327
2328
const lastResponseId : string | undefined = ( this . api as any ) ?. getLastResponseId ?.( )
2328
2329
const idx = findLastIndex (
2329
2330
this . clineMessages ,
2330
- ( m ) => m . type === "say" && ( m as any ) . say === "text" && m . partial !== true ,
2331
+ ( m ) => m . type === "say" && m . say === "text" && m . partial !== true ,
2331
2332
)
2332
2333
if ( idx !== - 1 ) {
2333
- const msg = this . clineMessages [ idx ] as any
2334
- msg . metadata = msg . metadata ?? { }
2335
- msg . metadata . gpt5 = {
2334
+ const msg = this . clineMessages [ idx ] as ClineMessage & ClineMessageWithMetadata
2335
+ if ( ! msg . metadata ) {
2336
+ msg . metadata = { }
2337
+ }
2338
+ const gpt5Metadata : Gpt5Metadata = {
2336
2339
...( msg . metadata . gpt5 ?? { } ) ,
2337
2340
previous_response_id : lastResponseId ,
2338
2341
instructions : this . lastUsedInstructions ,
2339
2342
reasoning_summary : ( reasoningMessage ?? "" ) . trim ( ) || undefined ,
2340
2343
}
2344
+ msg . metadata . gpt5 = gpt5Metadata
2341
2345
}
2342
2346
} catch ( error ) {
2343
2347
console . error ( `[Task#${ this . taskId } ] Error persisting GPT-5 metadata:` , error )
0 commit comments