@@ -109,7 +109,17 @@ export async function executeBatchStrReplaces({
109
109
state : Record < string , any >
110
110
userId : string | undefined
111
111
} ) {
112
+ logger . debug (
113
+ {
114
+ deferredStrReplacesCount : deferredStrReplaces . length ,
115
+ agentStepId,
116
+ userInputId,
117
+ } ,
118
+ 'executeBatchStrReplaces: Starting batch processing' ,
119
+ )
120
+
112
121
if ( deferredStrReplaces . length === 0 ) {
122
+ logger . debug ( 'executeBatchStrReplaces: No deferred replacements to process' )
113
123
return
114
124
}
115
125
@@ -123,6 +133,15 @@ export async function executeBatchStrReplaces({
123
133
operationsByPath . get ( path ) ! . push ( operation )
124
134
}
125
135
136
+ logger . debug (
137
+ {
138
+ uniquePaths : operationsByPath . size ,
139
+ pathsList : Array . from ( operationsByPath . keys ( ) ) ,
140
+ agentStepId,
141
+ } ,
142
+ 'executeBatchStrReplaces: Grouped operations by path' ,
143
+ )
144
+
126
145
// Initialize batch context
127
146
const batchContext : BatchContext = {
128
147
ws,
@@ -156,9 +175,25 @@ export async function executeBatchStrReplaces({
156
175
}
157
176
158
177
// Wait for all path-based operations to complete
178
+ logger . debug (
179
+ { pathCount : pathPromises . size , agentStepId } ,
180
+ 'executeBatchStrReplaces: Waiting for all path operations to complete' ,
181
+ )
159
182
await Promise . all ( pathPromises . values ( ) )
183
+ logger . debug (
184
+ { agentStepId } ,
185
+ 'executeBatchStrReplaces: All path operations completed' ,
186
+ )
160
187
161
188
// Apply benchify if we have intended changes
189
+ logger . debug (
190
+ {
191
+ intendedChangesCount : batchContext . intendedChanges . size ,
192
+ editedFilesCount : batchContext . editedFiles . size ,
193
+ agentStepId,
194
+ } ,
195
+ 'executeBatchStrReplaces: About to apply Benchify if needed' ,
196
+ )
162
197
await applyBenchifyIfNeeded ( batchContext , {
163
198
agentStepId,
164
199
clientSessionId,
@@ -167,6 +202,10 @@ export async function executeBatchStrReplaces({
167
202
toolResults,
168
203
toolCalls : deferredStrReplaces . map ( ( d ) => d . toolCall ) ,
169
204
} )
205
+ logger . debug (
206
+ { agentStepId } ,
207
+ 'executeBatchStrReplaces: Completed batch processing' ,
208
+ )
170
209
}
171
210
172
211
/**
@@ -453,18 +492,18 @@ async function applyBenchifyIfNeeded(
453
492
toolCalls : CodebuffToolCall < 'str_replace' > [ ]
454
493
} ,
455
494
) {
495
+ // Early exit conditions - fail gracefully without blocking user edits
456
496
logger . debug (
457
497
{
458
- state : batchContext . state ,
459
- originalContents : batchContext . originalContents ,
460
- editedFiles : batchContext . editedFiles ,
461
- intendedChanges : batchContext . intendedChanges ,
498
+ intendedChanges : Array . from ( batchContext . intendedChanges . entries ( ) ) . map (
499
+ ( [ path , contents ] ) => ( { path , contents } ) ,
500
+ ) ,
501
+ size : batchContext . intendedChanges . size ,
462
502
} ,
463
- 'called applyBenchifyIfNeeded ' ,
503
+ 'changes to apply? ' ,
464
504
)
465
-
466
- // Early exit conditions - fail gracefully without blocking user edits
467
505
if ( batchContext . intendedChanges . size === 0 ) {
506
+ logger . debug ( 'no changes, returning early...' )
468
507
return
469
508
}
470
509
0 commit comments