diff --git a/CHANGELOG.md b/CHANGELOG.md index c860393..11ff400 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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). diff --git a/zynk.c b/zynk.c index 9fb0144..6e712fb 100644 --- a/zynk.c +++ b/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 {