Skip to content

Commit fbd8a72

Browse files
committed
Remove bigquery tracing from agent-runtime
1 parent 11031ab commit fbd8a72

File tree

8 files changed

+5
-61
lines changed

8 files changed

+5
-61
lines changed

packages/agent-runtime/src/__tests__/loop-agent-steps.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
3737
let loopAgentStepsBaseParams: any
3838

3939
beforeAll(async () => {
40-
// Mock bigquery
41-
await mockModule('@codebuff/bigquery', () => ({
42-
insertTrace: () => {},
43-
}))
40+
// Set up mocks.
4441
})
4542

4643
beforeEach(() => {

packages/agent-runtime/src/__tests__/main-prompt.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as bigquery from '@codebuff/bigquery'
21
import * as analytics from '@codebuff/common/analytics'
32
import { TEST_USER_ID } from '@codebuff/common/old-constants'
43
import { createTestAgentRuntimeParams } from '@codebuff/common/testing/fixtures/agent-runtime'
@@ -101,11 +100,8 @@ describe('mainPrompt', () => {
101100
}) as Response,
102101
}
103102

104-
// Mock analytics and tracing
103+
// Mock analytics
105104
spyOn(analytics, 'trackEvent').mockImplementation(() => {})
106-
spyOn(bigquery, 'insertTrace').mockImplementation(() =>
107-
Promise.resolve(true),
108-
) // Return Promise<boolean>
109105

110106
// Mock processFileBlock
111107
spyOn(processFileBlockModule, 'processFileBlock').mockImplementation(

packages/agent-runtime/src/__tests__/read-docs-tool.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as bigquery from '@codebuff/bigquery'
21
import * as analytics from '@codebuff/common/analytics'
32
import { TEST_USER_ID } from '@codebuff/common/old-constants'
43
import { TEST_AGENT_RUNTIME_IMPL } from '@codebuff/common/testing/impl/agent-runtime'
@@ -53,9 +52,6 @@ describe('read_docs tool with researcher agent (via web API facade)', () => {
5352
spyOn(analytics, 'flushAnalytics').mockImplementation(() =>
5453
Promise.resolve(),
5554
)
56-
spyOn(bigquery, 'insertTrace').mockImplementation(() =>
57-
Promise.resolve(true),
58-
)
5955

6056
agentRuntimeImpl.requestFiles = async () => ({})
6157
agentRuntimeImpl.requestOptionalFile = async () => null

packages/agent-runtime/src/__tests__/run-agent-step-tools.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as bigquery from '@codebuff/bigquery'
21
import * as analytics from '@codebuff/common/analytics'
32
import { TEST_USER_ID } from '@codebuff/common/old-constants'
43
import { TEST_AGENT_RUNTIME_IMPL } from '@codebuff/common/testing/impl/agent-runtime'
@@ -70,11 +69,8 @@ describe('runAgentStep - set_output tool', () => {
7069
})),
7170
} as any)
7271

73-
// Mock analytics and tracing
72+
// Mock analytics
7473
spyOn(analytics, 'trackEvent').mockImplementation(() => {})
75-
spyOn(bigquery, 'insertTrace').mockImplementation(() =>
76-
Promise.resolve(true),
77-
)
7874

7975
agentRuntimeImpl.requestFiles = async ({ filePaths }) => {
8076
const results: Record<string, string | null> = {}

packages/agent-runtime/src/__tests__/web-search-tool.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as bigquery from '@codebuff/bigquery'
21
import * as analytics from '@codebuff/common/analytics'
32
import { TEST_USER_ID } from '@codebuff/common/old-constants'
43
import { TEST_AGENT_RUNTIME_IMPL } from '@codebuff/common/testing/impl/agent-runtime'
@@ -72,11 +71,8 @@ describe('web_search tool with researcher agent (via web API facade)', () => {
7271
userInputId: 'test-input',
7372
}
7473

75-
// Mock analytics and tracing
74+
// Mock analytics
7675
spyOn(analytics, 'trackEvent').mockImplementation(() => {})
77-
spyOn(bigquery, 'insertTrace').mockImplementation(() =>
78-
Promise.resolve(true),
79-
)
8076

8177
// Mock websocket actions
8278
runAgentStepBaseParams.requestFiles = async () => ({})

packages/agent-runtime/src/run-agent-step.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { insertTrace } from '@codebuff/bigquery'
21
import { AnalyticsEvent } from '@codebuff/common/constants/analytics-events'
32
import { supportsCacheControl } from '@codebuff/common/old-constants'
43
import { TOOLS_WHICH_WONT_FORCE_NEXT_STEP } from '@codebuff/common/tools/constants'
@@ -26,7 +25,6 @@ import {
2625
} from './util/messages'
2726
import { countTokensJson } from './util/token-counter'
2827

29-
import type { AgentResponseTrace } from '@codebuff/bigquery'
3028
import type { AgentTemplate } from '@codebuff/common/types/agent-template'
3129
import type { TrackEventFn } from '@codebuff/common/types/contracts/analytics'
3230
import type {
@@ -352,22 +350,6 @@ export const runAgentStep = async (
352350

353351
fullResponse = fullResponseAfterStream
354352

355-
const agentResponseTrace: AgentResponseTrace = {
356-
type: 'agent-response',
357-
created_at: new Date(),
358-
agent_step_id: agentStepId,
359-
user_id: userId ?? '',
360-
id: crypto.randomUUID(),
361-
payload: {
362-
output: fullResponse,
363-
user_input_id: userInputId,
364-
client_session_id: clientSessionId,
365-
fingerprint_id: fingerprintId,
366-
},
367-
}
368-
369-
insertTrace({ trace: agentResponseTrace, logger })
370-
371353
agentState.messageHistory = expireMessages(
372354
agentState.messageHistory,
373355
'agentStep',

packages/agent-runtime/src/system-prompt/search-system-prompt.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { countTokens, countTokensJson } from '../util/token-counter'
2-
import { insertTrace } from '@codebuff/bigquery'
32
import { buildArray } from '@codebuff/common/util/array'
43

54
import {
@@ -63,24 +62,6 @@ export function getSearchSystemPrompt(params: {
6362
},
6463
{} as Record<number, string>,
6564
)
66-
67-
const trace = {
68-
id: crypto.randomUUID(),
69-
agent_step_id: options.agentStepId,
70-
created_at: new Date(),
71-
type: 'file-trees' as const,
72-
user_id: options.userId ?? '',
73-
payload: {
74-
filetrees: truncatedTrees,
75-
user_input_id: options.userInputId,
76-
client_session_id: options.clientSessionId,
77-
fingerprint_id: options.fingerprintId,
78-
},
79-
}
80-
81-
insertTrace({ trace, logger }).catch((error: Error) => {
82-
logger.error({ error }, 'Failed to insert file trees trace')
83-
})
8465
const fileTreeTokens = countTokensJson(projectFileTreePrompt)
8566

8667
const systemInfoPrompt = getSystemInfoPrompt(fileContext)

packages/bigquery/src/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export async function insertTrace({
162162
return true
163163
} catch (error) {
164164
logger.warn(
165-
{ error, traceId: trace.id },
165+
{ error: getErrorObject(error), traceId: trace.id },
166166
'Failed to insert trace into BigQuery',
167167
)
168168
return false

0 commit comments

Comments
 (0)