Skip to content

Commit fd64ac8

Browse files
committed
Delete some dead code (too call parse error)
1 parent 68a447f commit fd64ac8

File tree

2 files changed

+5
-44
lines changed

2 files changed

+5
-44
lines changed

packages/agent-runtime/src/tools/stream-parser.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ import type {
3030
import type { PrintModeEvent } from '@codebuff/common/types/print-mode'
3131
import type { Subgoal } from '@codebuff/common/types/session-state'
3232
import type { ProjectFileContext } from '@codebuff/common/util/file'
33-
import type { ToolCallPart } from 'ai'
34-
35-
export type ToolCallError = {
36-
toolName?: string
37-
args: Record<string, unknown>
38-
error: string
39-
} & Omit<ToolCallPart, 'type'>
4033

4134
export async function processStream(
4235
params: {

packages/agent-runtime/src/tools/tool-executor.ts

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -54,51 +54,21 @@ export function parseRawToolCall<T extends ToolName = ToolName>(params: {
5454
toolCallId: string
5555
input: Record<string, unknown>
5656
}
57-
autoInsertEndStepParam?: boolean
5857
}): CodebuffToolCall<T> | ToolCallError {
59-
const { rawToolCall, autoInsertEndStepParam = false } = params
58+
const { rawToolCall } = params
6059
const toolName = rawToolCall.toolName
6160

62-
if (!(toolName in toolParams)) {
63-
return {
64-
toolName,
65-
toolCallId: rawToolCall.toolCallId,
66-
input: rawToolCall.input,
67-
error: `Tool ${toolName} not found`,
68-
}
69-
}
70-
const validName = toolName as T
71-
72-
// const processedParameters: Record<string, any> = {}
73-
// for (const [param, val] of Object.entries(rawToolCall.input ?? {})) {
74-
// processedParameters[param] = val
75-
// }
76-
77-
// Add the required codebuff_end_step parameter with the correct value for this tool if requested
78-
// if (autoInsertEndStepParam) {
79-
// processedParameters[endsAgentStepParam] =
80-
// toolParams[validName].endsAgentStep
81-
// }
82-
83-
// const paramsSchema = toolParams[validName].endsAgentStep
84-
// ? (
85-
// toolParams[validName].inputSchema satisfies z.ZodObject as z.ZodObject
86-
// ).extend({
87-
// [endsAgentStepParam]: z.literal(toolParams[validName].endsAgentStep),
88-
// })
89-
// : toolParams[validName].inputSchema
90-
9161
const processedParameters = rawToolCall.input
92-
const paramsSchema = toolParams[validName].inputSchema
62+
const paramsSchema = toolParams[toolName].inputSchema
9363

9464
const result = paramsSchema.safeParse(processedParameters)
9565

9666
if (!result.success) {
9767
return {
98-
toolName: validName,
68+
toolName,
9969
toolCallId: rawToolCall.toolCallId,
10070
input: rawToolCall.input,
101-
error: `Invalid parameters for ${validName}: ${JSON.stringify(
71+
error: `Invalid parameters for ${toolName}: ${JSON.stringify(
10272
result.error.issues,
10373
null,
10474
2,
@@ -111,7 +81,7 @@ export function parseRawToolCall<T extends ToolName = ToolName>(params: {
11181
}
11282

11383
return {
114-
toolName: validName,
84+
toolName,
11585
input: result.data,
11686
toolCallId: rawToolCall.toolCallId,
11787
} as CodebuffToolCall<T>
@@ -163,7 +133,6 @@ export function executeToolCall<T extends ToolName>(
163133
const {
164134
toolName,
165135
input,
166-
autoInsertEndStepParam = false,
167136
excludeToolFromMessageHistory = false,
168137
fromHandleSteps = false,
169138

@@ -188,7 +157,6 @@ export function executeToolCall<T extends ToolName>(
188157
toolCallId,
189158
input,
190159
},
191-
autoInsertEndStepParam,
192160
})
193161

194162
// Filter out restricted tools - emit error instead of tool call/result

0 commit comments

Comments
 (0)