Skip to content

Commit cda0711

Browse files
Refactor think-deeply, create-plan, and find-files to pass logger as parameter
🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
1 parent 97540cb commit cda0711

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

backend/src/tools/handlers/tool/create-plan.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { trackEvent } from '@codebuff/common/analytics'
22
import { AnalyticsEvent } from '@codebuff/common/constants/analytics-events'
33

44
import { getFileProcessingValues, postStreamProcessing } from './write-file'
5-
import { logger } from '../../../util/logger'
65

76
import type { CodebuffToolHandlerFunction } from '../handler-function-type'
7+
import type { Logger } from '@codebuff/types/logger'
88
import type {
99
FileProcessingState,
1010
OptionalFileProcessingState,
@@ -22,6 +22,7 @@ export const handleCreatePlan = ((params: {
2222
toolCall: ClientToolCall<'create_plan'>,
2323
) => Promise<CodebuffToolOutput<'create_plan'>>
2424
writeToClient: (chunk: string) => void
25+
logger: Logger
2526

2627
getLatestState: () => FileProcessingState
2728
state: {
@@ -41,6 +42,7 @@ export const handleCreatePlan = ((params: {
4142
toolCall,
4243
requestClientToolCall,
4344
writeToClient,
45+
logger,
4446
getLatestState,
4547
state,
4648
} = params

backend/src/tools/handlers/tool/find-files.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import {
66
} from '../../../find-files/request-files-prompt'
77
import { getFileReadingUpdates } from '../../../get-file-reading-updates'
88
import { getSearchSystemPrompt } from '../../../system-prompt/search-system-prompt'
9-
import { logger } from '../../../util/logger'
109
import { renderReadFilesResult } from '../../../util/parse-tool-call-xml'
1110
import { countTokens, countTokensJson } from '../../../util/token-counter'
1211
import { requestFiles } from '../../../websockets/websocket-action'
1312

1413
import type { TextBlock } from '../../../llm-apis/claude'
1514
import type { CodebuffToolHandlerFunction } from '../handler-function-type'
15+
import type { Logger } from '@codebuff/types/logger'
1616
import type { GetExpandedFileContextForTrainingBlobTrace } from '@codebuff/bigquery'
1717
import type {
1818
CodebuffToolCall,
@@ -29,6 +29,7 @@ const COLLECT_FULL_FILE_CONTEXT = false
2929
export const handleFindFiles = ((params: {
3030
previousToolCallFinished: Promise<any>
3131
toolCall: CodebuffToolCall<'find_files'>
32+
logger: Logger
3233

3334
fileContext: ProjectFileContext
3435
agentStepId: string
@@ -46,6 +47,7 @@ export const handleFindFiles = ((params: {
4647
const {
4748
previousToolCallFinished,
4849
toolCall,
50+
logger,
4951
fileContext,
5052
agentStepId,
5153
clientSessionId,
@@ -113,6 +115,7 @@ export const handleFindFiles = ((params: {
113115
userInputId,
114116
userId,
115117
repoId,
118+
logger,
116119
).catch((error) => {
117120
logger.error(
118121
{ error },
@@ -178,6 +181,7 @@ async function uploadExpandedFileContextForTraining(
178181
userInputId: string,
179182
userId: string | undefined,
180183
repoId: string | undefined,
184+
logger: Logger,
181185
) {
182186
const files = await requestRelevantFilesForTraining({
183187
messages,

backend/src/tools/handlers/tool/think-deeply.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { logger } from '../../../util/logger'
2-
31
import type { CodebuffToolHandlerFunction } from '../handler-function-type'
2+
import type { Logger } from '@codebuff/types/logger'
43
import type {
54
CodebuffToolCall,
65
CodebuffToolOutput,
@@ -9,8 +8,9 @@ import type {
98
export const handleThinkDeeply = ((params: {
109
previousToolCallFinished: Promise<any>
1110
toolCall: CodebuffToolCall<'think_deeply'>
11+
logger: Logger
1212
}): { result: Promise<CodebuffToolOutput<'think_deeply'>>; state: {} } => {
13-
const { previousToolCallFinished, toolCall } = params
13+
const { previousToolCallFinished, toolCall, logger } = params
1414
const { thought } = toolCall.input
1515

1616
logger.debug(

0 commit comments

Comments
 (0)