Skip to content

Commit aef3f32

Browse files
committed
logs: even moar benchify debugging logs
1 parent 26613d9 commit aef3f32

File tree

1 file changed

+46
-7
lines changed

1 file changed

+46
-7
lines changed

backend/src/tools/batch-str-replace.ts

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,17 @@ export async function executeBatchStrReplaces({
109109
state: Record<string, any>
110110
userId: string | undefined
111111
}) {
112+
logger.debug(
113+
{
114+
deferredStrReplacesCount: deferredStrReplaces.length,
115+
agentStepId,
116+
userInputId,
117+
},
118+
'executeBatchStrReplaces: Starting batch processing',
119+
)
120+
112121
if (deferredStrReplaces.length === 0) {
122+
logger.debug('executeBatchStrReplaces: No deferred replacements to process')
113123
return
114124
}
115125

@@ -123,6 +133,15 @@ export async function executeBatchStrReplaces({
123133
operationsByPath.get(path)!.push(operation)
124134
}
125135

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+
126145
// Initialize batch context
127146
const batchContext: BatchContext = {
128147
ws,
@@ -156,9 +175,25 @@ export async function executeBatchStrReplaces({
156175
}
157176

158177
// 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+
)
159182
await Promise.all(pathPromises.values())
183+
logger.debug(
184+
{ agentStepId },
185+
'executeBatchStrReplaces: All path operations completed',
186+
)
160187

161188
// 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+
)
162197
await applyBenchifyIfNeeded(batchContext, {
163198
agentStepId,
164199
clientSessionId,
@@ -167,6 +202,10 @@ export async function executeBatchStrReplaces({
167202
toolResults,
168203
toolCalls: deferredStrReplaces.map((d) => d.toolCall),
169204
})
205+
logger.debug(
206+
{ agentStepId },
207+
'executeBatchStrReplaces: Completed batch processing',
208+
)
170209
}
171210

172211
/**
@@ -453,18 +492,18 @@ async function applyBenchifyIfNeeded(
453492
toolCalls: CodebuffToolCall<'str_replace'>[]
454493
},
455494
) {
495+
// Early exit conditions - fail gracefully without blocking user edits
456496
logger.debug(
457497
{
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,
462502
},
463-
'called applyBenchifyIfNeeded',
503+
'changes to apply?',
464504
)
465-
466-
// Early exit conditions - fail gracefully without blocking user edits
467505
if (batchContext.intendedChanges.size === 0) {
506+
logger.debug('no changes, returning early...')
468507
return
469508
}
470509

0 commit comments

Comments
 (0)