Show full AI error output instead of generic error message
When an AI query fails (opencode exits non-zero), the bot previously sent a generic 'AI query failed (opencode exited with error)' message to IRC, discarding all useful output. Users had no way to diagnose why the query failed. Changes: - Redirect opencode's stderr into the capture pipe instead of /dev/null, so error messages that go to stderr are no longer lost. - On non-zero exit, include the actual captured output in the error message sent to IRC: 'AI error (exit N): <output>' (truncated to 4000 chars). If no output was captured, show 'AI error (exit N, no output)' instead. - Applied strip_formatting() to the error output before sending so ANSI codes and markdown don't leak into IRC. - Bumped VERSION to 0.34.3.
This commit is contained in:
parent
335d35a7b8
commit
c4d9011bdb
2 changed files with 15 additions and 4 deletions
|
|
@ -1,3 +1,9 @@
|
|||
2026.07.19 – Show full AI error output on failure.
|
||||
|
||||
- AI error messages now include the actual opencode output instead of a generic "(opencode exited with error)" message.
|
||||
- Captured stderr from opencode (previously sent to /dev/null) so error details are no longer lost.
|
||||
- Version bumped to 0.34.3.
|
||||
|
||||
2026.07.19 – Collapsed double spaces in `!forecast` and `!stock` responses
|
||||
|
||||
- Collapsed double spaces in `!forecast` and `!stock` responses (e.g., when weather condition is empty).
|
||||
|
|
|
|||
13
zynk.c
13
zynk.c
|
|
@ -29,7 +29,7 @@ int asprintf(char **, const char *, ...);
|
|||
|
||||
/* ---- constants ---- */
|
||||
|
||||
#define VERSION "0.34.2"
|
||||
#define VERSION "0.34.3"
|
||||
#define DEFAULT_SERVER "irc.libera.chat"
|
||||
#define OPENCODE_BIN "/usr/bin/opencode"
|
||||
#define CLR_RESET "\033[0m"
|
||||
|
|
@ -1621,9 +1621,8 @@ static void ai_child_task(Session *s, long long id, const char *agent) {
|
|||
if (cmd_pid == 0) {
|
||||
close(ai_pipe[0]);
|
||||
dup2(ai_pipe[1], STDOUT_FILENO);
|
||||
dup2(ai_pipe[1], STDERR_FILENO);
|
||||
close(ai_pipe[1]);
|
||||
int dn = open("/dev/null", O_WRONLY);
|
||||
if (dn >= 0) { dup2(dn, STDERR_FILENO); close(dn); }
|
||||
if (agent)
|
||||
execl(g_opencode_bin, "opencode", "run", "--dangerously-skip-permissions", "--agent", agent, combined, (char *)NULL);
|
||||
else
|
||||
|
|
@ -1649,7 +1648,13 @@ static void ai_child_task(Session *s, long long id, const char *agent) {
|
|||
out[olen] = 0;
|
||||
int rc = WIFEXITED(status) ? WEXITSTATUS(status) : -1;
|
||||
if (rc != 0) {
|
||||
ai_set_answer(id, "AI query failed (opencode exited with error)");
|
||||
char errmsg[4200];
|
||||
strip_formatting(out);
|
||||
if (olen > 0)
|
||||
snprintf(errmsg, sizeof errmsg, "AI error (exit %d): %.4000s", rc, out);
|
||||
else
|
||||
snprintf(errmsg, sizeof errmsg, "AI error (exit %d, no output)", rc);
|
||||
ai_set_answer(id, errmsg);
|
||||
} else if (olen == 0) {
|
||||
ai_set_answer(id, "AI returned an empty response");
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue