Skip to content

Commit 4aabf24

Browse files
committed
sdk: combine write_file and str_replace
1 parent e3c563e commit 4aabf24

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

sdk/src/client.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { PrintModeEvent } from '../../common/src/types/print-mode'
1919
export type ClientToolName =
2020
| 'read_files'
2121
| 'write_file'
22-
| 'str_replace'
2322
| 'run_terminal_command'
2423

2524
export type CodebuffClientOptions = {
@@ -216,7 +215,11 @@ export class CodebuffClient {
216215
const args = action.args
217216
let result: string
218217
try {
219-
const override = this.overrideTools[toolName as ClientToolName]
218+
let override = this.overrideTools[toolName as ClientToolName]
219+
if (!override && toolName === 'str_replace') {
220+
// Note: write_file and str_replace have the same implementation, so reuse their write_file override.
221+
override = this.overrideTools['write_file']
222+
}
220223
if (override) {
221224
const overrideResult = await override(args)
222225
result = overrideResult.toolResultMessage
@@ -231,7 +234,7 @@ export class CodebuffClient {
231234
)
232235
} else {
233236
throw new Error(
234-
`Tool not implemented in sdk. Please provide an override or modify your agent to not use this tool: ${toolName}`,
237+
`Tool not implemented in SDK. Please provide an override or modify your agent to not use this tool: ${toolName}`,
235238
)
236239
}
237240
} catch (error) {

0 commit comments

Comments
 (0)