Skip to content

Commit d6160f1

Browse files
committed
fix(executor): improve error messages with contextual information
Add more context to error messages for better troubleshooting: - Include model name in retry attempt error messages - Add model and title to process termination errors - Include cycle number and retry count in evaluation failures - Show error type in retry messages using @Errorname() This makes it easier to identify what failed during autonomous execution and helps with debugging when issues occur. Signed-off-by: leocavalcante <[email protected]>
1 parent 167fe58 commit d6160f1

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/executor.zig

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ pub const Executor = struct {
134134
}
135135

136136
// Default to NEEDS_WORK if we couldn't determine
137-
self.log.logError("Failed to get evaluation result, defaulting to NEEDS_WORK");
137+
self.log.logErrorFmt("Failed to get evaluation result after {d} attempts (cycle {d}), defaulting to NEEDS_WORK", .{ self.cfg.max_retries, cycle });
138138
return "NEEDS_WORK";
139139
}
140140

@@ -159,8 +159,8 @@ pub const Executor = struct {
159159
if (result) |output| {
160160
self.allocator.free(output);
161161
return .success;
162-
} else |_| {
163-
self.log.logErrorFmt("opencode failed (attempt {d})", .{attempt + 1});
162+
} else |err| {
163+
self.log.logErrorFmt("opencode failed (attempt {d}/{d}): {s} with model '{s}'", .{ attempt + 1, self.cfg.max_retries, @errorName(err), model });
164164
}
165165

166166
// Backoff before retry
@@ -228,16 +228,16 @@ pub const Executor = struct {
228228
if (code == 0) {
229229
return stdout_list.toOwnedSlice(self.allocator);
230230
}
231-
self.log.logErrorFmt("opencode exited with code {d}", .{code});
231+
self.log.logErrorFmt("opencode exited with code {d} (model: {s}, title: {s})", .{ code, model, title });
232232
},
233233
.Signal => |sig| {
234-
self.log.logErrorFmt("opencode terminated by signal {d}", .{sig});
234+
self.log.logErrorFmt("opencode terminated by signal {d} (model: {s}, title: {s})", .{ sig, model, title });
235235
},
236236
.Stopped => |sig| {
237-
self.log.logErrorFmt("opencode stopped by signal {d}", .{sig});
237+
self.log.logErrorFmt("opencode stopped by signal {d} (model: {s}, title: {s})", .{ sig, model, title });
238238
},
239239
.Unknown => |status| {
240-
self.log.logErrorFmt("opencode terminated with unknown status {d}", .{status});
240+
self.log.logErrorFmt("opencode terminated with unknown status {d} (model: {s}, title: {s})", .{ status, model, title });
241241
},
242242
}
243243

0 commit comments

Comments
 (0)