Skip to content

Commit 82d380a

Browse files
authored
1 parent 3efe31b commit 82d380a

File tree

5 files changed

+33
-3
lines changed

5 files changed

+33
-3
lines changed

agent/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ class TestDriverAgent extends EventEmitter2 {
196196
}
197197

198198
await this.summarize(error.message);
199-
return await this.exit(true);
199+
// Always run postrun lifecycle script, even for fatal errors
200+
return await this.exit(true, false, true);
200201
}
201202

202203
// creates a new "thread" in which the AI is given an error

interfaces/cli/lib/base.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,14 @@ class BaseCommand extends Command {
101101
logger.createMarkdownLogger(this.agent.emitter);
102102

103103
// Handle exit events
104-
this.agent.emitter.on("error:fatal", (error) => {
104+
this.agent.emitter.on("error:fatal", async (error) => {
105105
console.error("Fatal error:", error);
106-
process.exit(1);
106+
// Call the agent's exit method to ensure postrun lifecycle script is executed
107+
if (this.agent) {
108+
await this.agent.exit(true, false, true);
109+
} else {
110+
process.exit(1);
111+
}
107112
});
108113

109114
this.agent.emitter.on("exit", (exitCode) => {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 6.0.1-canary.4f31816.0
2+
session: 68767e31eb9cc3d8f639b8e0
3+
steps:
4+
- prompt: "run"
5+
commands:
6+
- command: exec
7+
lang: pwsh
8+
code: Write-Output "postrun.yaml"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 6.0.1-canary.4f31816.0
2+
session: 68767e31eb9cc3d8f639b8e0
3+
steps:
4+
- prompt: "run"
5+
commands:
6+
- command: exec
7+
lang: pwsh
8+
code: Write-Output "prerun.yaml"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 6.0.1-canary.4f31816.0
2+
session: 68767e31eb9cc3d8f639b8e0
3+
steps:
4+
- prompt: "run"
5+
commands:
6+
- command: exec
7+
lang: pwsh
8+
code: Write-Output "provision.yaml"

0 commit comments

Comments
 (0)