Skip to content

Commit bf922c6

Browse files
committed
fix: broken tests
1 parent 5468afe commit bf922c6

File tree

7 files changed

+56
-32
lines changed

7 files changed

+56
-32
lines changed

backend/src/__tests__/cost-aggregation.integration.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,10 @@ describe('Cost Aggregation Integration Tests', () => {
185185
// Simulate different responses based on call
186186
if (callCount === 1) {
187187
// Main agent spawns a subagent
188-
yield '<codebuff_tool_call>\n{"cb_tool_name": "spawn_agents", "agents": [{"agent_type": "editor", "prompt": "Write a simple hello world file"}]}\n</codebuff_tool_call>'
188+
yield { type: 'text' as const, text: '<codebuff_tool_call>\n{"cb_tool_name": "spawn_agents", "agents": [{"agent_type": "editor", "prompt": "Write a simple hello world file"}]}\n</codebuff_tool_call>' }
189189
} else {
190190
// Subagent writes a file
191-
yield '<codebuff_tool_call>\n{"cb_tool_name": "write_file", "path": "hello.txt", "instructions": "Create hello world file", "content": "Hello, World!"}\n</codebuff_tool_call>'
191+
yield { type: 'text' as const, text: '<codebuff_tool_call>\n{"cb_tool_name": "write_file", "path": "hello.txt", "instructions": "Create hello world file", "content": "Hello, World!"}\n</codebuff_tool_call>' }
192192
}
193193
if (options.resolveMessageId) {
194194
options.resolveMessageId('mock-message-id')
@@ -342,13 +342,13 @@ describe('Cost Aggregation Integration Tests', () => {
342342

343343
if (callCount === 1) {
344344
// Main agent spawns first-level subagent
345-
yield '<codebuff_tool_call>\n{"cb_tool_name": "spawn_agents", "agents": [{"agent_type": "editor", "prompt": "Create files"}]}\n</codebuff_tool_call>'
345+
yield { type: 'text' as const, text: '<codebuff_tool_call>\n{"cb_tool_name": "spawn_agents", "agents": [{"agent_type": "editor", "prompt": "Create files"}]}\n</codebuff_tool_call>' }
346346
} else if (callCount === 2) {
347347
// First-level subagent spawns second-level subagent
348-
yield '<codebuff_tool_call>\n{"cb_tool_name": "spawn_agents", "agents": [{"agent_type": "editor", "prompt": "Write specific file"}]}\n</codebuff_tool_call>'
348+
yield { type: 'text' as const, text: '<codebuff_tool_call>\n{"cb_tool_name": "spawn_agents", "agents": [{"agent_type": "editor", "prompt": "Write specific file"}]}\n</codebuff_tool_call>' }
349349
} else {
350350
// Second-level subagent does actual work
351-
yield '<codebuff_tool_call>\n{"cb_tool_name": "write_file", "path": "nested.txt", "instructions": "Create nested file", "content": "Nested content"}\n</codebuff_tool_call>'
351+
yield { type: 'text' as const, text: '<codebuff_tool_call>\n{"cb_tool_name": "write_file", "path": "nested.txt", "instructions": "Create nested file", "content": "Nested content"}\n</codebuff_tool_call>' }
352352
}
353353

354354
if (options.resolveMessageId) {
@@ -401,10 +401,10 @@ describe('Cost Aggregation Integration Tests', () => {
401401

402402
if (callCount === 1) {
403403
// Main agent spawns subagent
404-
yield '<codebuff_tool_call>\n{"cb_tool_name": "spawn_agents", "agents": [{"agent_type": "editor", "prompt": "This will fail"}]}\n</codebuff_tool_call>'
404+
yield { type: 'text' as const, text: '<codebuff_tool_call>\n{"cb_tool_name": "spawn_agents", "agents": [{"agent_type": "editor", "prompt": "This will fail"}]}\n</codebuff_tool_call>' }
405405
} else {
406406
// Subagent fails after incurring cost
407-
yield 'Some response'
407+
yield { type: 'text' as const, text: 'Some response' }
408408
throw new Error('Subagent execution failed')
409409
}
410410

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
107107
resolveMessageId,
108108
}) {
109109
llmCallCount++
110-
yield `LLM response\n\n${getToolCallString('end_turn', {})}`
110+
yield { type: 'text' as const, text: `LLM response\n\n${getToolCallString('end_turn', {})}` }
111111
if (resolveMessageId) {
112112
resolveMessageId('mock-message-id')
113113
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const mockAgentStream = (streamOutput: string) => {
3939
spyOn(aisdk, 'promptAiSdkStream').mockImplementation(async function* ({
4040
resolveMessageId,
4141
}) {
42-
yield streamOutput
42+
yield { type: 'text' as const, text: streamOutput }
4343
if (resolveMessageId) {
4444
resolveMessageId('mock-message-id')
4545
}

backend/src/__tests__/read-docs-tool.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function mockAgentStream(content: string | string[]) {
4040
content = [content]
4141
}
4242
for (const chunk of content) {
43-
yield chunk
43+
yield { type: 'text' as const, text: chunk }
4444
}
4545
if (resolveMessageId) {
4646
resolveMessageId('mock-message-id')
@@ -279,7 +279,7 @@ describe('read_docs tool with researcher agent', () => {
279279
}
280280

281281
// Should have yielded exactly one value and then completed
282-
expect(results).toEqual([mockResponse])
282+
expect(results).toEqual([{ type: 'text', text: mockResponse }])
283283

284284
// Generator should be done
285285
const { done } = await generator.next()

backend/src/__tests__/run-agent-step-tools.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ describe('runAgentStep - set_output tool', () => {
179179
spyOn(aisdk, 'promptAiSdkStream').mockImplementation(async function* ({
180180
resolveMessageId,
181181
}) {
182-
yield mockResponse
182+
yield { type: 'text' as const, text: mockResponse }
183183
if (resolveMessageId) {
184184
resolveMessageId('mock-message-id')
185185
}
@@ -225,7 +225,7 @@ describe('runAgentStep - set_output tool', () => {
225225
spyOn(aisdk, 'promptAiSdkStream').mockImplementation(async function* ({
226226
resolveMessageId,
227227
}) {
228-
yield mockResponse
228+
yield { type: 'text' as const, text: mockResponse }
229229
if (resolveMessageId) {
230230
resolveMessageId('mock-message-id')
231231
}
@@ -272,7 +272,7 @@ describe('runAgentStep - set_output tool', () => {
272272
spyOn(aisdk, 'promptAiSdkStream').mockImplementation(async function* ({
273273
resolveMessageId,
274274
}) {
275-
yield mockResponse
275+
yield { type: 'text' as const, text: mockResponse }
276276
if (resolveMessageId) {
277277
resolveMessageId('mock-message-id')
278278
}
@@ -319,7 +319,7 @@ describe('runAgentStep - set_output tool', () => {
319319
spyOn(aisdk, 'promptAiSdkStream').mockImplementation(async function* ({
320320
resolveMessageId,
321321
}) {
322-
yield mockResponse
322+
yield { type: 'text' as const, text: mockResponse }
323323
if (resolveMessageId) {
324324
resolveMessageId('mock-message-id')
325325
}
@@ -403,7 +403,7 @@ describe('runAgentStep - set_output tool', () => {
403403
spyOn(aisdk, 'promptAiSdkStream').mockImplementation(async function* ({
404404
resolveMessageId,
405405
}) {
406-
yield 'Continuing with the analysis...' // Non-empty response, no tool calls
406+
yield { type: 'text' as const, text: 'Continuing with the analysis...' } // Non-empty response, no tool calls
407407
if (resolveMessageId) {
408408
resolveMessageId('mock-message-id')
409409
}
@@ -553,10 +553,10 @@ describe('runAgentStep - set_output tool', () => {
553553
spyOn(aisdk, 'promptAiSdkStream').mockImplementation(async function* ({
554554
resolveMessageId,
555555
}) {
556-
yield getToolCallString('spawn_agent_inline', {
556+
yield { type: 'text' as const, text: getToolCallString('spawn_agent_inline', {
557557
agent_type: 'message-deleter-agent',
558558
prompt: 'Delete the last two assistant messages',
559-
})
559+
}) }
560560
if (resolveMessageId) {
561561
resolveMessageId('mock-message-id')
562562
}

backend/src/__tests__/web-search-tool.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function mockAgentStream(content: string | string[]) {
4343
content = [content]
4444
}
4545
for (const chunk of content) {
46-
yield chunk
46+
yield { type: 'text' as const, text: chunk }
4747
}
4848
if (resolveMessageId) {
4949
resolveMessageId('mock-message-id')

backend/src/__tests__/xml-stream-parser.test.ts

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { processStreamWithTags } from '../xml-stream-parser'
88
describe('processStreamWithTags', () => {
99
async function* createMockStream(chunks: string[]) {
1010
for (const chunk of chunks) {
11-
yield chunk
11+
yield { type: 'text' as const, text: chunk }
1212
}
1313
}
1414

@@ -43,7 +43,9 @@ describe('processStreamWithTags', () => {
4343
onError,
4444
() => {},
4545
)) {
46-
result.push(chunk)
46+
if (chunk.type === 'text') {
47+
result.push(chunk.text)
48+
}
4749
}
4850

4951
expect(events).toEqual([
@@ -94,7 +96,9 @@ describe('processStreamWithTags', () => {
9496
onError,
9597
() => {},
9698
)) {
97-
result.push(chunk)
99+
if (chunk.type === 'text') {
100+
result.push(chunk.text)
101+
}
98102
}
99103

100104
expect(events).toEqual([
@@ -154,7 +158,9 @@ describe('processStreamWithTags', () => {
154158
onError,
155159
() => {},
156160
)) {
157-
result.push(chunk)
161+
if (chunk.type === 'text') {
162+
result.push(chunk.text)
163+
}
158164
}
159165

160166
expect(events).toEqual([
@@ -213,7 +219,9 @@ describe('processStreamWithTags', () => {
213219
onError,
214220
() => {},
215221
)) {
216-
result.push(chunk)
222+
if (chunk.type === 'text') {
223+
result.push(chunk.text)
224+
}
217225
}
218226

219227
expect(events).toEqual([
@@ -257,7 +265,9 @@ describe('processStreamWithTags', () => {
257265
onError,
258266
() => {},
259267
)) {
260-
result.push(chunk)
268+
if (chunk.type === 'text') {
269+
result.push(chunk.text)
270+
}
261271
}
262272

263273
expect(events).toEqual([
@@ -306,7 +316,9 @@ describe('processStreamWithTags', () => {
306316
onError,
307317
() => {},
308318
)) {
309-
result.push(chunk)
319+
if (chunk.type === 'text') {
320+
result.push(chunk.text)
321+
}
310322
}
311323

312324
expect(events).toEqual([
@@ -362,7 +374,9 @@ describe('processStreamWithTags', () => {
362374
onError,
363375
() => {},
364376
)) {
365-
result.push(chunk)
377+
if (chunk.type === 'text') {
378+
result.push(chunk.text)
379+
}
366380
}
367381

368382
expect(events).toEqual([
@@ -412,7 +426,9 @@ describe('processStreamWithTags', () => {
412426
onError,
413427
() => {},
414428
)) {
415-
result.push(chunk)
429+
if (chunk.type === 'text') {
430+
result.push(chunk.text)
431+
}
416432
}
417433

418434
// Should complete the tool call with the completion suffix
@@ -452,7 +468,9 @@ describe('processStreamWithTags', () => {
452468
onError,
453469
() => {},
454470
)) {
455-
result.push(chunk)
471+
if (chunk.type === 'text') {
472+
result.push(chunk.text)
473+
}
456474
}
457475

458476
expect(events).toEqual([])
@@ -478,7 +496,9 @@ describe('processStreamWithTags', () => {
478496
onError,
479497
() => {},
480498
)) {
481-
result.push(chunk)
499+
if (chunk.type === 'text') {
500+
result.push(chunk.text)
501+
}
482502
}
483503

484504
expect(events).toEqual([])
@@ -516,7 +536,9 @@ describe('processStreamWithTags', () => {
516536
onError,
517537
() => {},
518538
)) {
519-
result.push(chunk)
539+
if (chunk.type === 'text') {
540+
result.push(chunk.text)
541+
}
520542
}
521543

522544
expect(events).toEqual([
@@ -569,7 +591,9 @@ describe('processStreamWithTags', () => {
569591
onError,
570592
() => {},
571593
)) {
572-
result.push(chunk)
594+
if (chunk.type === 'text') {
595+
result.push(chunk.text)
596+
}
573597
}
574598

575599
expect(events).toEqual([

0 commit comments

Comments
 (0)