Skip to content

Commit 67dcd77

Browse files
committed
Update toolResult status correctly for failed bash command
1 parent fc32bfd commit 67dcd77

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

packages/core/src/codewhispererChat/controllers/chat/controller.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,14 +753,19 @@ export class ChatController {
753753
const output = await ToolUtils.invoke(tool, chatStream)
754754
ToolUtils.validateOutput(output, tool.type)
755755

756+
let status: ToolResultStatus = ToolResultStatus.SUCCESS
757+
if (output.output.success === false) {
758+
status = ToolResultStatus.ERROR
759+
}
760+
756761
toolResults.push({
757762
content: [
758763
output.output.kind === OutputKind.Text
759764
? { text: output.output.content }
760765
: { json: output.output.content },
761766
],
762767
toolUseId: toolUse.toolUseId,
763-
status: ToolResultStatus.SUCCESS,
768+
status,
764769
})
765770
} catch (e: any) {
766771
toolResults.push({

packages/core/src/codewhispererChat/tools/executeBash.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ export class ExecuteBash {
311311
const exitStatus = result.exitCode ?? 0
312312
const stdout = stdoutBuffer.join('\n')
313313
const stderr = stderrBuffer.join('\n')
314+
const success = exitStatus === 0 && !stderr
314315
const [stdoutTrunc, stdoutSuffix] = ExecuteBash.truncateSafelyWithSuffix(
315316
stdout,
316317
maxBashToolResponseSize / 3
@@ -330,6 +331,7 @@ export class ExecuteBash {
330331
output: {
331332
kind: OutputKind.Json,
332333
content: outputJson,
334+
success,
333335
},
334336
})
335337
} catch (err: any) {

packages/core/src/codewhispererChat/tools/toolShared.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export interface InvokeOutput {
1919
output: {
2020
kind: OutputKind
2121
content: string | any
22+
success?: boolean
2223
}
2324
}
2425

0 commit comments

Comments
 (0)