Skip to content

Commit 759aec8

Browse files
committed
Delete file_updates!! We don't need it
1 parent 6373bfd commit 759aec8

File tree

13 files changed

+28
-474
lines changed

13 files changed

+28
-474
lines changed

backend/src/__tests__/loop-agent-steps.test.ts

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,7 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
7070

7171
// Mock file reading updates
7272
mockModule('@codebuff/backend/get-file-reading-updates', () => ({
73-
getFileReadingUpdates: async () => ({
74-
addedFiles: [],
75-
updatedFilePaths: [],
76-
clearReadFileToolResults: false,
77-
}),
73+
getFileReadingUpdates: async () => [],
7874
}))
7975

8076
// Mock async agent manager
@@ -167,16 +163,16 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
167163
})
168164

169165
it('should verify correct STEP behavior - LLM called once after STEP', async () => {
170-
// This test verifies that programmatic agents don't call the LLM,
171-
// and that STEP yielding works correctly without LLM involvement
166+
// This test verifies that when a programmatic agent yields STEP,
167+
// the LLM should be called once in the next iteration
172168

173169
let stepCount = 0
174170
const mockGeneratorFunction = function* () {
175171
stepCount++
176172
// Execute a tool, then STEP
177173
yield { toolName: 'read_files', input: { paths: ['file1.txt'] } }
178-
yield 'STEP' // Should pause here
179-
// Continue after LLM runs
174+
yield 'STEP' // Should pause here and let LLM run
175+
// Continue after LLM runs (this won't be reached in this test since LLM ends turn)
180176
yield {
181177
toolName: 'write_file',
182178
input: { path: 'output.txt', content: 'test' },
@@ -190,14 +186,10 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
190186
'test-agent': mockTemplate,
191187
}
192188

193-
// Mock checkLiveUserInput to return true for multiple iterations
194-
let checkCallCount = 0
189+
// Mock checkLiveUserInput to allow the loop to continue
195190
const mockCheckLiveUserInput = require('@codebuff/backend/live-user-inputs')
196191
spyOn(mockCheckLiveUserInput, 'checkLiveUserInput').mockImplementation(
197-
() => {
198-
checkCallCount++
199-
return true
200-
},
192+
() => true, // Always return true to allow loop to continue
201193
)
202194

203195
const result = await loopAgentSteps(
@@ -210,7 +202,6 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
210202
params: undefined,
211203
fingerprintId: 'test-fingerprint',
212204
fileContext: mockFileContext,
213-
toolResults: [],
214205
localAgentTemplates,
215206
userId: TEST_USER_ID,
216207
clientSessionId: 'test-session',
@@ -221,14 +212,12 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
221212
console.log(`LLM calls made: ${llmCallCount}`)
222213
console.log(`Step count: ${stepCount}`)
223214

224-
// CORRECT BEHAVIOR: After STEP, LLM should be called once, then no more
225-
// The programmatic agent yields STEP, then LLM runs once
215+
// CORRECT BEHAVIOR: After STEP, LLM should be called once
216+
// The programmatic agent yields STEP, then LLM runs once and ends turn
226217
expect(llmCallCount).toBe(1) // LLM called once after STEP
227218

228219
// The programmatic agent should have been called once (yielded STEP)
229220
expect(stepCount).toBe(1)
230-
231-
// After STEP, the LLM should run once, then the loop should continue correctly
232221
})
233222

234223
it('should demonstrate correct behavior when programmatic agent completes without STEP', async () => {
@@ -260,7 +249,6 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
260249
params: undefined,
261250
fingerprintId: 'test-fingerprint',
262251
fileContext: mockFileContext,
263-
toolResults: [],
264252
localAgentTemplates,
265253
userId: TEST_USER_ID,
266254
clientSessionId: 'test-session',
@@ -301,13 +289,9 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
301289
}
302290

303291
// Mock checkLiveUserInput to allow multiple iterations
304-
let checkCallCount = 0
305292
const mockCheckLiveUserInput = require('@codebuff/backend/live-user-inputs')
306293
spyOn(mockCheckLiveUserInput, 'checkLiveUserInput').mockImplementation(
307-
() => {
308-
checkCallCount++
309-
return checkCallCount <= 5 // Allow enough iterations
310-
},
294+
() => true, // Always return true to allow loop to continue
311295
)
312296

313297
const result = await loopAgentSteps(
@@ -320,7 +304,6 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
320304
params: undefined,
321305
fingerprintId: 'test-fingerprint',
322306
fileContext: mockFileContext,
323-
toolResults: [],
324307
localAgentTemplates,
325308
userId: TEST_USER_ID,
326309
clientSessionId: 'test-session',
@@ -378,7 +361,6 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
378361
params: undefined,
379362
fingerprintId: 'test-fingerprint',
380363
fileContext: mockFileContext,
381-
toolResults: [],
382364
localAgentTemplates,
383365
userId: TEST_USER_ID,
384366
clientSessionId: 'test-session',
@@ -420,7 +402,6 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
420402
params: undefined,
421403
fingerprintId: 'test-fingerprint',
422404
fileContext: mockFileContext,
423-
toolResults: [],
424405
localAgentTemplates,
425406
userId: TEST_USER_ID,
426407
clientSessionId: 'test-session',
@@ -463,7 +444,6 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
463444
params: undefined,
464445
fingerprintId: 'test-fingerprint',
465446
fileContext: mockFileContext,
466-
toolResults: [],
467447
localAgentTemplates,
468448
userId: TEST_USER_ID,
469449
clientSessionId: 'test-session',
@@ -508,7 +488,6 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
508488
params: undefined,
509489
fingerprintId: 'test-fingerprint',
510490
fileContext: mockFileContext,
511-
toolResults: [],
512491
localAgentTemplates,
513492
userId: TEST_USER_ID,
514493
clientSessionId: 'test-session',
@@ -520,7 +499,7 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
520499
expect(llmCallCount).toBe(0)
521500
expect(result.agentState).toBeDefined()
522501
expect(result.agentState.output?.error).toContain(
523-
'Programmatic step failed',
502+
'Error executing handleSteps for agent test-agent',
524503
)
525504
})
526505

@@ -570,7 +549,6 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
570549
params: undefined,
571550
fingerprintId: 'test-fingerprint',
572551
fileContext: mockFileContext,
573-
toolResults: [],
574552
localAgentTemplates,
575553
userId: TEST_USER_ID,
576554
clientSessionId: 'test-session',
@@ -628,7 +606,6 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
628606
params: undefined,
629607
fingerprintId: 'test-fingerprint',
630608
fileContext: mockFileContext,
631-
toolResults: [],
632609
localAgentTemplates,
633610
userId: TEST_USER_ID,
634611
clientSessionId: 'test-session',
@@ -684,7 +661,6 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
684661
params: undefined,
685662
fingerprintId: 'test-fingerprint',
686663
fileContext: mockFileContext,
687-
toolResults: [],
688664
localAgentTemplates,
689665
userId: TEST_USER_ID,
690666
clientSessionId: 'test-session',

backend/src/__tests__/main-prompt.test.ts

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -228,97 +228,6 @@ describe('mainPrompt', () => {
228228
},
229229
}
230230

231-
it('should add file updates to tool results in message history', async () => {
232-
const sessionState = getInitialSessionState(mockFileContext)
233-
// Simulate a previous read_files result being in the history
234-
sessionState.mainAgentState.messageHistory.push({
235-
role: 'tool',
236-
content: {
237-
type: 'tool-result',
238-
toolCallId: 'prev-read',
239-
toolName: 'read_files',
240-
output: [
241-
{
242-
type: 'json',
243-
value: {
244-
path: 'test.txt',
245-
content: 'old content',
246-
},
247-
},
248-
],
249-
},
250-
})
251-
252-
const action = {
253-
type: 'prompt' as const,
254-
prompt: 'Test prompt causing file update check',
255-
sessionState,
256-
fingerprintId: 'test',
257-
costMode: 'max' as const,
258-
promptId: 'test',
259-
toolResults: [], // No *new* tool results for this specific turn
260-
}
261-
262-
// Capture the state *after* the prompt call
263-
const { sessionState: newSessionState } = await mainPrompt(
264-
new MockWebSocket() as unknown as WebSocket,
265-
action,
266-
{
267-
userId: TEST_USER_ID,
268-
clientSessionId: 'test-session',
269-
onResponseChunk: () => {},
270-
localAgentTemplates: {
271-
[AgentTemplateTypes.base]: {
272-
id: 'base',
273-
displayName: 'Base Agent',
274-
outputMode: 'last_message',
275-
inputSchema: {},
276-
spawnerPrompt: '',
277-
model: 'gpt-4o-mini',
278-
includeMessageHistory: true,
279-
toolNames: ['write_file', 'run_terminal_command'],
280-
spawnableAgents: [],
281-
systemPrompt: '',
282-
instructionsPrompt: '',
283-
stepPrompt: '',
284-
},
285-
[AgentTemplateTypes.base_max]: {
286-
id: 'base_max',
287-
displayName: 'Base Max Agent',
288-
outputMode: 'last_message',
289-
inputSchema: {},
290-
spawnerPrompt: '',
291-
model: 'gpt-4o',
292-
includeMessageHistory: true,
293-
toolNames: ['write_file', 'run_terminal_command'],
294-
spawnableAgents: [],
295-
systemPrompt: '',
296-
instructionsPrompt: '',
297-
stepPrompt: '',
298-
},
299-
},
300-
},
301-
)
302-
303-
// Find the user message containing tool results added *during* the mainPrompt execution
304-
// This message should contain the 'file_updates' result.
305-
// It's usually the message right before the final assistant response.
306-
const toolResultMessages =
307-
newSessionState.mainAgentState.messageHistory.filter(
308-
(m) => m.role === 'tool',
309-
)
310-
311-
// Find the specific tool result message that contains file_updates
312-
const fileUpdateMessage = toolResultMessages.find(
313-
(m) => m.content.toolName === 'read_files',
314-
)
315-
316-
expect(fileUpdateMessage).toBeDefined()
317-
expect(JSON.stringify(fileUpdateMessage?.content)).toContain('test.txt')
318-
// Check that the content reflects the *new* mock content within the file_updates result
319-
expect(JSON.stringify(fileUpdateMessage?.content)).toContain('old content')
320-
})
321-
322231
it('should handle direct terminal command', async () => {
323232
// Override the mock to return a terminal command
324233
spyOn(

backend/src/async-agent-manager.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ export class AsyncAgentManager {
192192
fingerprintId: agent.fingerprintId,
193193
fileContext: agent.fileContext,
194194
localAgentTemplates,
195-
toolResults: [],
196195
userId: agent.userId,
197196
clientSessionId: sessionId,
198197
onResponseChunk: () => {}, // Async agents don't stream to parent

0 commit comments

Comments
 (0)