Skip to content

Commit 41e0346

Browse files
committed
remove instances of spyon for promptAiSdk
1 parent 3a13732 commit 41e0346

File tree

3 files changed

+18
-24
lines changed

3 files changed

+18
-24
lines changed

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

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
} from 'bun:test'
1313

1414
import * as messageCostTracker from '../llm-apis/message-cost-tracker'
15-
import * as aisdk from '../llm-apis/vercel-ai-sdk/ai-sdk'
1615
import { mainPrompt } from '../main-prompt'
1716
import * as agentRegistry from '../templates/agent-registry'
1817
import * as websocketAction from '../websockets/websocket-action'
@@ -372,29 +371,27 @@ describe('Cost Aggregation Integration Tests', () => {
372371
it('should maintain cost integrity when subagents fail', async () => {
373372
// Mock scenario where subagent fails after incurring partial costs
374373
let callCount = 0
375-
spyOn(aisdk, 'promptAiSdkStream').mockImplementation(
376-
async function* (options) {
377-
callCount++
374+
agentRuntimeImpl.promptAiSdkStream = async function* (options) {
375+
callCount++
378376

379-
if (options.onCostCalculated) {
380-
await options.onCostCalculated(6) // Each call costs 6 credits
381-
}
377+
if (options.onCostCalculated) {
378+
await options.onCostCalculated(6) // Each call costs 6 credits
379+
}
382380

383-
if (callCount === 1) {
384-
// Main agent spawns subagent
385-
yield {
386-
type: 'text' as const,
387-
text: '<codebuff_tool_call>\n{"cb_tool_name": "spawn_agents", "agents": [{"agent_type": "editor", "prompt": "This will fail"}]}\n</codebuff_tool_call>',
388-
}
389-
} else {
390-
// Subagent fails after incurring cost
391-
yield { type: 'text' as const, text: 'Some response' }
392-
throw new Error('Subagent execution failed')
381+
if (callCount === 1) {
382+
// Main agent spawns subagent
383+
yield {
384+
type: 'text' as const,
385+
text: '<codebuff_tool_call>\n{"cb_tool_name": "spawn_agents", "agents": [{"agent_type": "editor", "prompt": "This will fail"}]}\n</codebuff_tool_call>',
393386
}
387+
} else {
388+
// Subagent fails after incurring cost
389+
yield { type: 'text' as const, text: 'Some response' }
390+
throw new Error('Subagent execution failed')
391+
}
394392

395-
return 'mock-message-id'
396-
},
397-
)
393+
return 'mock-message-id'
394+
}
398395

399396
const sessionState = getInitialSessionState(mockFileContext)
400397
sessionState.mainAgentState.agentType = 'base'

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import type { WebSocket } from 'ws'
3333

3434
let agentRuntimeImpl: AgentRuntimeDeps = { ...TEST_AGENT_RUNTIME_IMPL }
3535
function mockAgentStream(content: string | string[]) {
36-
agentRuntimeImpl['promptAiSdkStream'] = async function* ({}) {
36+
agentRuntimeImpl.promptAiSdkStream = async function* ({}) {
3737
if (typeof content === 'string') {
3838
content = [content]
3939
}

knowledge.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,6 @@ afterEach(() => {
152152
spyOn(aisdk, 'promptAiSdk').mockImplementation(() =>
153153
Promise.resolve('Test response'),
154154
)
155-
spyOn(aisdk, 'promptAiSdkStream').mockImplementation(async function* () {
156-
yield 'Test response'
157-
})
158155

159156
// From rage-detector.test.ts - Mocking Date
160157
spyOn(Date, 'now').mockImplementation(() => currentTime)

0 commit comments

Comments
 (0)