Skip to content

Commit 034d049

Browse files
committed
debugging opencode failures on gpt-5-codex
1 parent c855571 commit 034d049

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

agents/opencode.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ const opencode = await createOpencode({
6969
},
7070
});
7171

72-
process.once("beforeExit", () => opencode.server.close());
73-
7472
const sessionCache = new Map<string, string>();
7573

7674
export const models: string[] = [
@@ -261,6 +259,9 @@ const opencodeAgent: AgentDefinition = {
261259

262260
return { command: displayCommand, actions, usage };
263261
},
262+
cleanup() {
263+
opencode.server.close();
264+
},
264265
};
265266

266267
export default opencodeAgent;

cli.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,16 @@ main()
595595
}
596596
process.exitCode = 1;
597597
})
598-
.finally(process.exit);
598+
.finally(async () => {
599+
// Cleanup all loaded agents
600+
const agents = await listAgents();
601+
for (const agent of agents) {
602+
if (agent.definition.cleanup) {
603+
await agent.definition.cleanup();
604+
}
605+
}
606+
process.exit();
607+
});
599608

600609
function cleanupRepository(tempDir: string, entry: DatasetEval): void {
601610
try {

lib/createAgent.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export interface AgentDefinition {
2020
cwd: string,
2121
options?: AgentRunOptions,
2222
) => Promise<AgentRunResult>;
23+
cleanup?: () => void | Promise<void>;
2324
}
2425

2526
export interface AgentRunResult {

0 commit comments

Comments
 (0)