Skip to content

fix(bot): stop stderr output from swallowing PR/MR URLs in bot responses#1710

Open
kilo-code-bot[bot] wants to merge 1 commit intomainfrom
session/agent_f70dd137-fa33-4684-8bf2-c6e124b1d125
Open

fix(bot): stop stderr output from swallowing PR/MR URLs in bot responses#1710
kilo-code-bot[bot] wants to merge 1 commit intomainfrom
session/agent_f70dd137-fa33-4684-8bf2-c6e124b1d125

Conversation

@kilo-code-bot
Copy link
Copy Markdown
Contributor

@kilo-code-bot kilo-code-bot bot commented Mar 30, 2026

Summary

  • Root cause: In runSessionToCompletion(), any output event with source: 'stderr' (git warnings, npm deprecation notices, linter messages) set hasError = true, causing the function to return the error-branch response which discarded the completionResult containing the PR/MR URL. Since nearly every cloud agent session produces some stderr, this effectively broke PR/MR URL relay 100% of the time.
  • Fix: Stderr output now sets a separate hasStderr flag instead of hasError. The hasError flag is reserved for actual fatal errors (stream failures, session interruptions, WebSocket errors). Additionally, even when a real error occurs, if the assistant produced a completionResult it is now included in the response so PR/MR URLs are never silently lost.
  • New field: RunSessionResult.hasStderr added for diagnostic observability without affecting error semantics. No callers currently inspect hasError, making this backwards-compatible.

Verification

  • Reviewed all three callers of runSessionToCompletion (slack-bot.ts, discord-bot.ts, spawn-cloud-agent-session.ts) — none consume hasError, they only use response and sessionId, confirming the behavioral change is safe.
  • Added unit tests for extractTextFromMessage and resolveStreamUrl pure helper functions.
  • Verified the diff matches the identical fix on fix/bot-stderr-swallows-pr-url (PR fix(bot): stop stderr output from swallowing PR/MR URLs in bot responses #1709).

Visual Changes

N/A

Reviewer Notes

  • The bug existed since the initial run-session.ts implementation (commit db703d7d, Feb 24 2026), but became a 100% failure around March 23-26 when the cloud agent infrastructure update (ec88afba) and related changes increased the frequency/volume of stderr events during sessions.
  • Key files: src/lib/cloud-agent-next/run-session.ts:320-324 (stderr handler), src/lib/cloud-agent-next/run-session.ts:373-409 (result builder).
  • Note: PR fix(bot): stop stderr output from swallowing PR/MR URLs in bot responses #1709 on fix/bot-stderr-swallows-pr-url contains the identical fix. Consider merging either PR.

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
@kilo-code-bot
Copy link
Copy Markdown
Contributor Author

kilo-code-bot bot commented Mar 30, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • src/lib/cloud-agent-next/run-session.ts
  • src/lib/cloud-agent-next/run-session.test.ts

Reviewed by gpt-5.4-20260305 · 915,886 tokens

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants