Skip to content

fix: include stderr in error messages for failed agent executions#89

Merged
subsy merged 1 commit intosubsy:mainfrom
sambostock:fix/prd-chat-error-messages
Jan 15, 2026
Merged

fix: include stderr in error messages for failed agent executions#89
subsy merged 1 commit intosubsy:mainfrom
sambostock:fix/prd-chat-error-messages

Conversation

@sambostock
Copy link
Contributor

@sambostock sambostock commented Jan 15, 2026

Motivation

When using ralph-tui create-prd --chat and sending a message, if the agent fails the error displayed is just "Execution failed" with no actionable information. This makes it impossible to diagnose what went wrong.

Summary

  • Include stderr content in error messages when result.error is empty
  • Fallback chain: result.error → result.stderr → generic status message

Test plan

  • Run ralph-tui create-prd --chat and trigger an agent failure
  • Verify error message now shows actual stderr content instead of generic "Execution failed"

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved error message handling for non‑completed task results: the system now prioritises explicit error text, falls back to trimmed standard error output, and otherwise uses a clear generic execution status. Emitted error events and returned error values are now aligned, providing more consistent and informative messages for users and logs.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Jan 15, 2026

@sambostock is attempting to deploy a commit to the plgeek Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 15, 2026

Walkthrough

When a task finishes with a non-'completed' status, the code now computes a single errorMessage by preferring result.error, then trimmed result.stderr, and finally a generic Execution ${result.status}. That errorMessage is used for the emitted error event and the returned error value; a clarifying comment was added.

Changes

Cohort / File(s)
Error handling logic refinement
src/chat/engine.ts
Compute unified errorMessage (prefer result.error, then trimmed result.stderr, else Execution ${result.status}); use it for both emitted error event and returned error value; added clarifying comment.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐇 I nibble logs and hunt the clue,
I choose the error, or stderr true,
If both are silent, I softly state—
"Execution status" decides its fate. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: improving error messages by including stderr in failed agent executions, which directly aligns with the code modification in ChatEngine.sendMessage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings


📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ac6c316 and cd6de55.

📒 Files selected for processing (1)
  • src/chat/engine.ts
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Start all code files with a file-level JSDoc comment section explaining the file's purpose, prefixed with 'ABOUTME: '

Files:

  • src/chat/engine.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Start all code files with a file-level JSDoc comment section explaining the file's purpose, prefixed with "ABOUTME: "

Files:

  • src/chat/engine.ts
🔇 Additional comments (1)
src/chat/engine.ts (1)

229-243: LGTM! Clean implementation of the error message fallback chain.

The fallback logic correctly handles all cases:

  • Explicit result.error takes precedence
  • Empty/missing error falls through to trimmed stderr
  • Empty/missing stderr falls through to the generic status message

The optional chaining on result.stderr?.trim() safely handles undefined values, and the explanatory comment on line 231 clearly documents the intent.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sambostock sambostock force-pushed the fix/prd-chat-error-messages branch from 3402625 to ac6c316 Compare January 15, 2026 15:38
When an agent execution fails with a non-zero exit code, the error
message was showing 'Execution failed' with no useful content. This
happened because result.error is only set for process spawn errors,
while the actual error from the agent is in result.stderr.

Now checks stderr when result.error is empty, so users see the actual
error message from the agent.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@sambostock sambostock force-pushed the fix/prd-chat-error-messages branch from ac6c316 to cd6de55 Compare January 15, 2026 15:44
@sambostock
Copy link
Contributor Author

@subsy I notice you merged main in, but Claude force pushed its rebase with main over top. Sorry about that!

@subsy subsy merged commit 5b8cdf8 into subsy:main Jan 15, 2026
4 of 5 checks passed
@subsy
Copy link
Owner

subsy commented Jan 15, 2026

thanks @sambostock nice PR

sakaman pushed a commit to sakaman/ralph-tui that referenced this pull request Feb 15, 2026
fix: include stderr in error messages for failed agent executions
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.

2 participants

Comments