Skip to content

Commit 699684e

Browse files
Disable Agent retry to prevent looping on crash (#3617)
1 parent 4ac900f commit 699684e

File tree

3 files changed

+23
-38
lines changed

3 files changed

+23
-38
lines changed

server/utils/agents/aibitat/plugins/cli.js

+3-8
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,9 @@ const cli = {
1919
let printing = [];
2020

2121
aibitat.onError(async (error) => {
22-
console.error(chalk.red(` error: ${error?.message}`));
23-
if (error instanceof RetryError) {
24-
console.error(chalk.red(` retrying in 60 seconds...`));
25-
setTimeout(() => {
26-
aibitat.retry();
27-
}, 60000);
28-
return;
29-
}
22+
let errorMessage =
23+
error?.message || "An error occurred while running the agent.";
24+
console.error(chalk.red(` error: ${errorMessage}`), error);
3025
});
3126

3227
aibitat.onStart(() => {

server/utils/agents/aibitat/plugins/http-socket.js

+10-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const chalk = require("chalk");
2-
const { RetryError } = require("../error");
32
const { Telemetry } = require("../../../../models/telemetry");
43

54
/**
@@ -33,20 +32,16 @@ const httpSocket = {
3332
name: this.name,
3433
setup(aibitat) {
3534
aibitat.onError(async (error) => {
36-
if (!!error?.message) {
37-
console.error(chalk.red(` error: ${error.message}`), error);
38-
aibitat.introspect(
39-
`Error encountered while running: ${error.message}`
40-
);
41-
}
42-
43-
if (error instanceof RetryError) {
44-
console.error(chalk.red(` retrying in 60 seconds...`));
45-
setTimeout(() => {
46-
aibitat.retry();
47-
}, 60_000);
48-
return;
49-
}
35+
let errorMessage =
36+
error?.message || "An error occurred while running the agent.";
37+
console.error(chalk.red(` error: ${errorMessage}`), error);
38+
aibitat.introspect(
39+
`Error encountered while running: ${errorMessage}`
40+
);
41+
handler.send(
42+
JSON.stringify({ type: "wssFailure", content: errorMessage })
43+
);
44+
aibitat.terminate();
5045
});
5146

5247
aibitat.introspect = (messageText) => {

server/utils/agents/aibitat/plugins/websocket.js

+10-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const chalk = require("chalk");
2-
const { RetryError } = require("../error");
32
const { Telemetry } = require("../../../../models/telemetry");
43
const SOCKET_TIMEOUT_MS = 300 * 1_000; // 5 mins
54

@@ -49,20 +48,16 @@ const websocket = {
4948
name: this.name,
5049
setup(aibitat) {
5150
aibitat.onError(async (error) => {
52-
if (!!error?.message) {
53-
console.error(chalk.red(` error: ${error.message}`), error);
54-
aibitat.introspect(
55-
`Error encountered while running: ${error.message}`
56-
);
57-
}
58-
59-
if (error instanceof RetryError) {
60-
console.error(chalk.red(` retrying in 60 seconds...`));
61-
setTimeout(() => {
62-
aibitat.retry();
63-
}, 60000);
64-
return;
65-
}
51+
let errorMessage =
52+
error?.message || "An error occurred while running the agent.";
53+
console.error(chalk.red(` error: ${errorMessage}`), error);
54+
aibitat.introspect(
55+
`Error encountered while running: ${errorMessage}`
56+
);
57+
socket.send(
58+
JSON.stringify({ type: "wssFailure", content: errorMessage })
59+
);
60+
aibitat.terminate();
6661
});
6762

6863
aibitat.introspect = (messageText) => {

0 commit comments

Comments
 (0)