-
Notifications
You must be signed in to change notification settings - Fork 519
Expand file tree
/
Copy pathloop-agent-steps.test.ts
More file actions
736 lines (632 loc) · 23 KB
/
loop-agent-steps.test.ts
File metadata and controls
736 lines (632 loc) · 23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
import * as analytics from '@codebuff/common/analytics'
import { TEST_USER_ID } from '@codebuff/common/constants'
import {
clearMockedModules,
mockModule,
} from '@codebuff/common/testing/mock-modules'
import { getInitialSessionState } from '@codebuff/common/types/session-state'
import {
afterAll,
afterEach,
beforeAll,
beforeEach,
describe,
expect,
it,
mock,
spyOn,
} from 'bun:test'
import { loopAgentSteps, clearAgentGeneratorCache } from '@codebuff/agent-runtime'
import { mockFileContext, MockWebSocket } from './test-utils'
import { createMockAgentRuntimeEnvironment } from './test-env-mocks'
import type { AgentTemplate } from '../templates/types'
import type { StepGenerator } from '@codebuff/common/types/agent-template'
import type { AgentState } from '@codebuff/common/types/session-state'
import type { WebSocket } from 'ws'
describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () => {
let mockTemplate: AgentTemplate
let mockAgentState: AgentState
let llmCallCount: number
beforeAll(() => {
// Mock logger
mockModule('@codebuff/backend/util/logger', () => ({
logger: {
debug: () => {},
error: () => {},
info: () => {},
warn: () => {},
},
withLoggerContext: async (context: any, fn: () => Promise<any>) => fn(),
}))
// Mock bigquery
mockModule('@codebuff/bigquery', () => ({
insertTrace: () => {},
}))
// Mock agent registry
mockModule('@codebuff/backend/templates/agent-registry', () => ({
getAgentTemplate: async (agentType: string, localTemplates: any) => {
return localTemplates[agentType] || mockTemplate
},
}))
// Mock template strings
mockModule('@codebuff/backend/templates/strings', () => ({
getAgentPrompt: async () => 'Mock prompt',
}))
// Mock live user inputs - will be overridden in individual tests
mockModule('@codebuff/backend/live-user-inputs', () => ({
checkLiveUserInput: () => false, // Default to false, override in tests
}))
// Mock file reading updates
mockModule('@codebuff/backend/get-file-reading-updates', () => ({
getFileReadingUpdates: async () => ({
addedFiles: [],
updatedFilePaths: [],
clearReadFileToolResults: false,
}),
}))
// Mock async agent manager
mockModule('@codebuff/backend/async-agent-manager', () => ({
asyncAgentManager: {
getAgent: () => null,
registerAgent: () => {},
updateAgentState: () => {},
getAndClearMessages: () => [],
getMessages: () => [],
},
}))
// Mock stream parser
mockModule('@codebuff/backend/tools/stream-parser', () => ({
processStreamWithTools: async (options: any) => {
llmCallCount++ // Count LLM calls here since this is where the stream is processed
return {
toolCalls: [],
toolResults: [],
state: {
agentState: options.agentState || mockAgentState,
agentContext: {},
messages: options.messages || [],
},
fullResponse: 'LLM response',
fullResponseChunks: ['LLM response'],
}
},
}))
})
beforeEach(() => {
llmCallCount = 0
// Mock analytics
spyOn(analytics, 'initAnalytics').mockImplementation(() => {})
analytics.initAnalytics()
spyOn(analytics, 'trackEvent').mockImplementation(() => {})
// Mock crypto.randomUUID
spyOn(crypto, 'randomUUID').mockImplementation(
() =>
'mock-uuid-0000-0000-0000-000000000000' as `${string}-${string}-${string}-${string}-${string}`,
)
// Create mock template with programmatic agent
mockTemplate = {
id: 'test-agent',
displayName: 'Test Agent',
spawnerPrompt: 'Testing',
model: 'claude-3-5-sonnet-20241022',
inputSchema: {},
outputMode: 'structured_output',
includeMessageHistory: true,
toolNames: ['read_files', 'write_file', 'end_turn'],
spawnableAgents: [],
systemPrompt: 'Test system prompt',
instructionsPrompt: 'Test user prompt',
stepPrompt: 'Test agent step prompt',
handleSteps: undefined, // Will be set in individual tests
} as AgentTemplate
// Create mock agent state
const sessionState = getInitialSessionState(mockFileContext)
mockAgentState = {
...sessionState.mainAgentState,
agentId: 'test-agent-id',
messageHistory: [
{ role: 'user', content: 'Initial message' },
{ role: 'assistant', content: 'Initial response' },
],
output: undefined,
stepsRemaining: 10, // Ensure we don't hit the limit
}
})
afterEach(() => {
mock.restore()
clearAgentGeneratorCache()
})
llmCallCount = 0 // Reset LLM call count
afterAll(() => {
clearMockedModules()
})
it('should verify correct STEP behavior - LLM called once after STEP', async () => {
// This test verifies that programmatic agents don't call the LLM,
// and that STEP yielding works correctly without LLM involvement
let stepCount = 0
const mockGeneratorFunction = function* () {
stepCount++
// Execute a tool, then STEP
yield { toolName: 'read_files', input: { paths: ['file1.txt'] } }
yield 'STEP' // Should pause here
// Continue after LLM runs
yield {
toolName: 'write_file',
input: { path: 'output.txt', content: 'test' },
}
yield { toolName: 'end_turn', input: {} }
} as () => StepGenerator
mockTemplate.handleSteps = mockGeneratorFunction
const localAgentTemplates = {
'test-agent': mockTemplate,
}
// Mock checkLiveUserInput to return true for multiple iterations
let checkCallCount = 0
const mockCheckLiveUserInput = require('@codebuff/backend/live-user-inputs')
spyOn(mockCheckLiveUserInput, 'checkLiveUserInput').mockImplementation(
() => {
checkCallCount++
return true
},
)
const env = createMockAgentRuntimeEnvironment()
const result = await loopAgentSteps(
{
userInputId: 'test-user-input',
agentType: 'test-agent',
agentState: mockAgentState,
prompt: 'Test prompt',
params: undefined,
fingerprintId: 'test-fingerprint',
fileContext: mockFileContext,
toolResults: [],
localAgentTemplates,
userId: TEST_USER_ID,
clientSessionId: 'test-session',
onResponseChunk: () => {},
},
env,
)
console.log(`LLM calls made: ${llmCallCount}`)
console.log(`Step count: ${stepCount}`)
// CORRECT BEHAVIOR: After STEP, LLM should be called once, then no more
// The programmatic agent yields STEP, then LLM runs once
expect(llmCallCount).toBe(1) // LLM called once after STEP
// The programmatic agent should have been called once (yielded STEP)
expect(stepCount).toBe(1)
// After STEP, the LLM should run once, then the loop should continue correctly
})
it('should demonstrate correct behavior when programmatic agent completes without STEP', async () => {
// This test shows that when a programmatic agent doesn't yield STEP,
// it should complete without calling the LLM at all (since it ends with end_turn)
const mockGeneratorFunction = function* () {
yield { toolName: 'read_files', input: { paths: ['file1.txt'] } }
yield {
toolName: 'write_file',
input: { path: 'output.txt', content: 'test' },
}
yield { toolName: 'end_turn', input: {} }
} as () => StepGenerator
mockTemplate.handleSteps = mockGeneratorFunction
const localAgentTemplates = {
'test-agent': mockTemplate,
}
const env = createMockAgentRuntimeEnvironment()
const result = await loopAgentSteps(
{
userInputId: 'test-user-input',
agentType: 'test-agent',
agentState: mockAgentState,
prompt: 'Test prompt',
params: undefined,
fingerprintId: 'test-fingerprint',
fileContext: mockFileContext,
toolResults: [],
localAgentTemplates,
userId: TEST_USER_ID,
clientSessionId: 'test-session',
onResponseChunk: () => {},
},
env,
)
// Should NOT call LLM since the programmatic agent ended with end_turn
expect(llmCallCount).toBe(0)
// The result should have agentState
expect(result.agentState).toBeDefined()
})
it('should run programmatic step first, then LLM step, then continue', async () => {
// This test verifies the correct execution order in loopAgentSteps:
// 1. Programmatic step runs first and yields STEP
// 2. LLM step runs once
// 3. Loop continues but generator is complete after first STEP
let stepCount = 0
const mockGeneratorFunction = function* () {
stepCount++
// First execution: do some work, then STEP
yield { toolName: 'read_files', input: { paths: ['file1.txt'] } }
yield 'STEP' // Hand control to LLM
// After LLM runs, continue (this happens in the same generator instance)
yield {
toolName: 'write_file',
input: { path: 'output.txt', content: 'updated by LLM' },
}
yield { toolName: 'end_turn', input: {} }
} as () => StepGenerator
mockTemplate.handleSteps = mockGeneratorFunction
const localAgentTemplates = {
'test-agent': mockTemplate,
}
// Mock checkLiveUserInput to allow multiple iterations
let checkCallCount = 0
const mockCheckLiveUserInput = require('@codebuff/backend/live-user-inputs')
spyOn(mockCheckLiveUserInput, 'checkLiveUserInput').mockImplementation(
() => {
checkCallCount++
return checkCallCount <= 5 // Allow enough iterations
},
)
const env = createMockAgentRuntimeEnvironment()
const result = await loopAgentSteps(
{
userInputId: 'test-user-input',
agentType: 'test-agent',
agentState: mockAgentState,
prompt: 'Test execution order',
params: undefined,
fingerprintId: 'test-fingerprint',
fileContext: mockFileContext,
toolResults: [],
localAgentTemplates,
userId: TEST_USER_ID,
clientSessionId: 'test-session',
onResponseChunk: () => {},
},
env,
)
// Verify execution order:
// 1. Programmatic step function was called once (creates generator)
// 2. LLM was called once after STEP
// 3. Generator continued after LLM step
expect(stepCount).toBe(1) // Generator function called once
expect(llmCallCount).toBe(1) // LLM called once after first STEP
expect(result.agentState).toBeDefined()
})
it('should handle programmatic agent that yields STEP_ALL', async () => {
// Test STEP_ALL behavior - should run LLM then continue with programmatic step
let stepCount = 0
const mockGeneratorFunction = function* () {
stepCount++
yield { toolName: 'read_files', input: { paths: ['file1.txt'] } }
yield 'STEP_ALL' // Hand all remaining control to LLM
// Should continue after LLM completes all its steps
yield {
toolName: 'write_file',
input: { path: 'final.txt', content: 'done' },
}
yield { toolName: 'end_turn', input: {} }
} as () => StepGenerator
mockTemplate.handleSteps = mockGeneratorFunction
const localAgentTemplates = {
'test-agent': mockTemplate,
}
let checkCallCount = 0
const mockCheckLiveUserInput = require('@codebuff/backend/live-user-inputs')
spyOn(mockCheckLiveUserInput, 'checkLiveUserInput').mockImplementation(
() => {
checkCallCount++
return checkCallCount <= 5
},
)
const env = createMockAgentRuntimeEnvironment()
const result = await loopAgentSteps(
{
userInputId: 'test-user-input',
agentType: 'test-agent',
agentState: mockAgentState,
prompt: 'Test STEP_ALL behavior',
params: undefined,
fingerprintId: 'test-fingerprint',
fileContext: mockFileContext,
toolResults: [],
localAgentTemplates,
userId: TEST_USER_ID,
clientSessionId: 'test-session',
onResponseChunk: () => {},
},
env,
)
expect(stepCount).toBe(1) // Generator function called once
expect(llmCallCount).toBe(1) // LLM should be called once
expect(result.agentState).toBeDefined()
})
it('should not call LLM when programmatic agent returns without STEP', async () => {
// Test that programmatic agents that don't yield STEP don't trigger LLM
const mockGeneratorFunction = function* () {
yield { toolName: 'read_files', input: { paths: ['test.txt'] } }
yield {
toolName: 'write_file',
input: { path: 'result.txt', content: 'processed' },
}
// No STEP - agent completes without LLM involvement
yield { toolName: 'end_turn', input: {} }
} as () => StepGenerator
mockTemplate.handleSteps = mockGeneratorFunction
const localAgentTemplates = {
'test-agent': mockTemplate,
}
const env = createMockAgentRuntimeEnvironment()
const result = await loopAgentSteps(
{
userInputId: 'test-user-input',
agentType: 'test-agent',
agentState: mockAgentState,
prompt: 'Test no LLM call',
params: undefined,
fingerprintId: 'test-fingerprint',
fileContext: mockFileContext,
toolResults: [],
localAgentTemplates,
userId: TEST_USER_ID,
clientSessionId: 'test-session',
onResponseChunk: () => {},
},
env,
)
expect(llmCallCount).toBe(0) // No LLM calls should be made
expect(result.agentState).toBeDefined()
})
it('should handle LLM-only agent (no handleSteps)', async () => {
// Test traditional LLM-based agents that don't have handleSteps
const llmOnlyTemplate = {
...mockTemplate,
handleSteps: undefined, // No programmatic step function
}
const localAgentTemplates = {
'test-agent': llmOnlyTemplate,
}
let checkCallCount = 0
const mockCheckLiveUserInput = require('@codebuff/backend/live-user-inputs')
spyOn(mockCheckLiveUserInput, 'checkLiveUserInput').mockImplementation(
() => {
checkCallCount++
return checkCallCount <= 2 // Allow 2 iterations
},
)
const env = createMockAgentRuntimeEnvironment()
const result = await loopAgentSteps(
{
userInputId: 'test-user-input',
agentType: 'test-agent',
agentState: mockAgentState,
prompt: 'Test LLM-only agent',
params: undefined,
fingerprintId: 'test-fingerprint',
fileContext: mockFileContext,
toolResults: [],
localAgentTemplates,
userId: TEST_USER_ID,
clientSessionId: 'test-session',
onResponseChunk: () => {},
},
env,
)
expect(llmCallCount).toBe(1) // LLM should be called once
expect(result.agentState).toBeDefined()
})
it('should handle programmatic agent error and still call LLM', async () => {
// Test error handling in programmatic step - should still allow LLM to run
const mockGeneratorFunction = function* () {
yield { toolName: 'read_files', input: { paths: ['file1.txt'] } }
throw new Error('Programmatic step failed')
} as () => StepGenerator
mockTemplate.handleSteps = mockGeneratorFunction
const localAgentTemplates = {
'test-agent': mockTemplate,
}
let checkCallCount = 0
const mockCheckLiveUserInput = require('@codebuff/backend/live-user-inputs')
spyOn(mockCheckLiveUserInput, 'checkLiveUserInput').mockImplementation(
() => {
checkCallCount++
return checkCallCount <= 2
},
)
const env = createMockAgentRuntimeEnvironment()
const result = await loopAgentSteps(
{
userInputId: 'test-user-input',
agentType: 'test-agent',
agentState: mockAgentState,
prompt: 'Test error handling',
params: undefined,
fingerprintId: 'test-fingerprint',
fileContext: mockFileContext,
toolResults: [],
localAgentTemplates,
userId: TEST_USER_ID,
clientSessionId: 'test-session',
onResponseChunk: () => {},
},
env,
)
// After programmatic step error, should end turn and not call LLM
expect(llmCallCount).toBe(0)
expect(result.agentState).toBeDefined()
expect(result.agentState.output?.error).toContain(
'Programmatic step failed',
)
})
it('should handle mixed execution with multiple STEP yields', async () => {
// Test complex scenario with multiple STEP yields and LLM interactions
// Note: In current implementation, LLM typically ends turn after running,
// so this tests the first STEP interaction
let stepCount = 0
const mockGeneratorFunction = function* () {
stepCount++
yield { toolName: 'read_files', input: { paths: ['input.txt'] } }
yield 'STEP' // First LLM interaction
yield {
toolName: 'write_file',
input: { path: 'temp.txt', content: 'intermediate' },
}
yield {
toolName: 'write_file',
input: { path: 'final.txt', content: 'complete' },
}
yield { toolName: 'end_turn', input: {} }
} as () => StepGenerator
mockTemplate.handleSteps = mockGeneratorFunction
const localAgentTemplates = {
'test-agent': mockTemplate,
}
let checkCallCount = 0
const mockCheckLiveUserInput = require('@codebuff/backend/live-user-inputs')
spyOn(mockCheckLiveUserInput, 'checkLiveUserInput').mockImplementation(
() => {
checkCallCount++
return checkCallCount <= 10 // Allow many iterations
},
)
const env = createMockAgentRuntimeEnvironment()
const result = await loopAgentSteps(
{
userInputId: 'test-user-input',
agentType: 'test-agent',
agentState: mockAgentState,
prompt: 'Test multiple STEP interactions',
params: undefined,
fingerprintId: 'test-fingerprint',
fileContext: mockFileContext,
toolResults: [],
localAgentTemplates,
userId: TEST_USER_ID,
clientSessionId: 'test-session',
onResponseChunk: () => {},
},
env,
)
expect(stepCount).toBe(1) // Generator function called once
expect(llmCallCount).toBe(1) // LLM called once after STEP
expect(result.agentState).toBeDefined()
})
it('should respect async agent messages and continue appropriately', async () => {
// Test async agent message handling during loopAgentSteps
const mockGeneratorFunction = function* () {
yield { toolName: 'read_files', input: { paths: ['async-test.txt'] } }
yield 'STEP'
} as () => StepGenerator
mockTemplate.handleSteps = mockGeneratorFunction
const localAgentTemplates = {
'test-agent': mockTemplate,
}
// Mock async agent manager to simulate pending messages
const mockAsyncAgentManager = require('@codebuff/backend/async-agent-manager')
let getMessagesCallCount = 0
spyOn(
mockAsyncAgentManager.asyncAgentManager,
'getMessages',
).mockImplementation(() => {
getMessagesCallCount++
// Return messages on second call to simulate async agent activity
return getMessagesCallCount === 2 ? ['async message'] : []
})
let checkCallCount = 0
const mockCheckLiveUserInput = require('@codebuff/backend/live-user-inputs')
spyOn(mockCheckLiveUserInput, 'checkLiveUserInput').mockImplementation(
() => {
checkCallCount++
return checkCallCount <= 5
},
)
const env = createMockAgentRuntimeEnvironment()
const result = await loopAgentSteps(
{
userInputId: 'test-user-input',
agentType: 'test-agent',
agentState: mockAgentState,
prompt: 'Test async agent messages',
params: undefined,
fingerprintId: 'test-fingerprint',
fileContext: mockFileContext,
toolResults: [],
localAgentTemplates,
userId: TEST_USER_ID,
clientSessionId: 'test-session',
onResponseChunk: () => {},
},
env,
)
// Should continue when async messages are present
expect(result.agentState).toBeDefined()
expect(getMessagesCallCount).toBeGreaterThan(0)
})
it('should pass shouldEndTurn: true as stepsComplete when end_turn tool is called', async () => {
// Test that when LLM calls end_turn, shouldEndTurn is correctly passed to runProgrammaticStep
let runProgrammaticStepCalls: any[] = []
// Mock runProgrammaticStep module to capture calls and verify stepsComplete parameter
mockModule('@codebuff/agent-runtime', () => ({
runProgrammaticStep: async (agentState: any, options: any) => {
runProgrammaticStepCalls.push({ agentState, options })
// Return default behavior
return { agentState, endTurn: false }
},
clearAgentGeneratorCache: () => {},
loopAgentSteps: require('@codebuff/agent-runtime').loopAgentSteps,
runAgentStep: require('@codebuff/agent-runtime').runAgentStep,
}))
const mockGeneratorFunction = function* () {
yield 'STEP' // Hand control to LLM
} as () => StepGenerator
mockTemplate.handleSteps = mockGeneratorFunction
const localAgentTemplates = {
'test-agent': mockTemplate,
}
// Mock the stream parser to simulate LLM calling end_turn tool
mockModule('@codebuff/backend/tools/stream-parser', () => ({
processStreamWithTools: async (options: any) => {
llmCallCount++
return {
toolCalls: [
{ toolName: 'end_turn', input: {}, toolCallId: 'test-id' },
],
toolResults: [],
state: {
agentState: options.agentState,
agentContext: {},
messages: options.messages,
},
fullResponse: 'LLM response with end_turn',
fullResponseChunks: ['LLM response with end_turn'],
}
},
}))
// Mock checkLiveUserInput to allow the loop to run
const mockCheckLiveUserInput = require('@codebuff/backend/live-user-inputs')
spyOn(mockCheckLiveUserInput, 'checkLiveUserInput').mockImplementation(
() => true,
)
const env = createMockAgentRuntimeEnvironment()
await loopAgentSteps({
userInputId: 'test-user-input',
agentType: 'test-agent',
agentState: mockAgentState,
prompt: 'Test shouldEndTurn to stepsComplete flow',
params: undefined,
fingerprintId: 'test-fingerprint',
fileContext: mockFileContext,
toolResults: [],
localAgentTemplates,
userId: TEST_USER_ID,
clientSessionId: 'test-session',
onResponseChunk: () => {},
}, env)
// Verify that runProgrammaticStep was called twice:
// 1. First with stepsComplete: false (initial call)
// 2. Second with stepsComplete: true (after LLM called end_turn)
expect(runProgrammaticStepCalls).toHaveLength(2)
// First call should have stepsComplete: false
expect(runProgrammaticStepCalls[0].options.stepsComplete).toBe(false)
// Second call should have stepsComplete: true (after end_turn tool was called)
expect(runProgrammaticStepCalls[1].options.stepsComplete).toBe(true)
})
})