fix(bot): stop stderr output from swallowing PR/MR URLs in bot responses#1709
Open
kilo-code-bot[bot] wants to merge 1 commit intomainfrom
Open
fix(bot): stop stderr output from swallowing PR/MR URLs in bot responses#1709kilo-code-bot[bot] wants to merge 1 commit intomainfrom
kilo-code-bot[bot] wants to merge 1 commit intomainfrom
Conversation
Stderr output (git warnings, npm notices, etc.) was incorrectly setting hasError=true, causing runSessionToCompletion to take the error branch which discarded the completionResult containing the PR/MR URL. Changes: - Track stderr via separate hasStderr flag instead of hasError - Include completionResult in error responses when available - Add hasStderr to RunSessionResult for diagnostics - Add tests for extractTextFromMessage and resolveStreamUrl
| // When the assistant produced a completionResult (e.g. containing a PR/MR | ||
| // URL), prefer returning it even if a fatal error also occurred — losing the | ||
| // PR link is the worse outcome for users. | ||
| if (hasError) { |
Contributor
Author
There was a problem hiding this comment.
WARNING: Non-zero agent exits still bypass this error path
This branch only runs when hasError was set earlier, but the complete handler never marks a non-zero exitCode as fatal. After changing stderr to only flip hasStderr, a session that exits with code 1 and only writes to stderr will now fall through to the success response, so users won't see that the run actually failed. Treating complete.data.exitCode !== 0 as an error would preserve the original failure signal while still allowing completionResult to be appended here.
Contributor
Author
Code Review SummaryStatus: 1 Issue Found | Recommendation: Address before merge Overview
Fix these issues in Kilo Cloud Issue Details (click to expand)WARNING
Other Observations (not in diff)None. Files Reviewed (2 files)
Reviewed by gpt-5.4-20260305 · 1,320,772 tokens |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
runSessionToCompletion(), anystderroutput event (git warnings, npm deprecation notices, linter messages) sethasError = true, causing the function to return the error response template which discarded thecompletionResultcontaining the PR/MR URL. This meant the Slack/Discord bot never relayed PR links to users when the cloud agent session produced any stderr — which is nearly every session.hasStderrflag instead ofhasError. ThehasErrorflag is reserved for actual fatal errors (stream failures, session interruptions, WebSocket errors). Additionally, even when a real error occurs, if the assistant produced acompletionResultit is now included in the response so PR/MR URLs are never silently lost.RunSessionResult.hasStderris added for diagnostic observability without affecting error semantics. No callers currently consumehasErrorso this is backwards-compatible.Verification
runSessionToCompletion(slack-bot.ts, discord-bot.ts, spawn-cloud-agent-session.ts) — none consumehasError, they only useresponseandsessionId, so the behavioral change is safe.extractTextFromMessageandresolveStreamUrlpure functions.pnpm typecheckorpnpm testin the sandbox (missingnode_modules/tsgo), but changes are minimal and type-safe — only adding a new boolean field to the result type and changing which boolean is set by stderr events.Visual Changes
N/A
Reviewer Notes
run-session.ts(commit451764ef), not a recent regression per se, but it became more impactful after the bot was switched to use Cloud Agent Next infrastructure.src/lib/cloud-agent-next/run-session.ts:320-324(stderr handler),src/lib/cloud-agent-next/run-session.ts:373-409(result builder).completionResultwhen available as a safety net for genuine errors that still produce useful output (e.g., session completed but had a non-zero exit code while the assistant already posted the PR URL).