Problem
When a CLI agent runtime (Claude, Gemini, Codex, OpenCode) exits with an error (e.g., "Not logged in"), the error message printed to stderr is captured into stderrChunks but never logged or included in any event. The agent run completes with an empty done event (text: "", no error), making it impossible to diagnose why the agent produced no output.
Impact
- Messages sent via Chat UI, Slack, or any channel silently "disappear" with no reply and no error
- Gateway logs show
lifecycle phase=start → phase=end in ~1 second with no output in between
- The
chat.send handler's .catch() calls broadcastChatError() but the error message is generic — the actual CLI stderr (e.g., "Not logged in · Please run /login") is lost
- Debugging requires manually running the CLI binary to discover the real error
Root cause
In src/middleware/cli-runtime-base.ts:
// Line 62: stderr is captured...
const stderrChunks: string[] = [];
// Line 107-109: ...into this array...
diagnosticStream?.on("data", (chunk: Buffer) => {
stderrChunks.push(chunk.toString());
});
// But stderrChunks is NEVER used after this point.
// The done event at line 231-239 doesn't include stderr.
// No error event is emitted when the process exits non-zero with stderr output.
Expected behavior
When the CLI process exits with a non-zero exit code (or exits with zero but produces no NDJSON output) and stderr contains content, the runtime should:
- Emit an
error event with the stderr content before the done event
- Include stderr in the
done event result (e.g., result.error or result.stderr)
- Log the stderr content at
warn level so it appears in gateway logs
Reproduction
- Install RemoteClaw with
agents.defaults.runtime: "claude"
- Ensure
claude CLI is installed but NOT authenticated (claude /login not run)
- Send a message via Chat UI
- Observe: no reply, no error in logs, message "disappears"
- Manually run
claude -p "hello" → shows "Not logged in · Please run /login"
Affected file
src/middleware/cli-runtime-base.ts — execute() method
🤖 Generated with Claude Code
Problem
When a CLI agent runtime (Claude, Gemini, Codex, OpenCode) exits with an error (e.g., "Not logged in"), the error message printed to stderr is captured into
stderrChunksbut never logged or included in any event. The agent run completes with an emptydoneevent (text: "", no error), making it impossible to diagnose why the agent produced no output.Impact
lifecycle phase=start→phase=endin ~1 second with no output in betweenchat.sendhandler's.catch()callsbroadcastChatError()but the error message is generic — the actual CLI stderr (e.g., "Not logged in · Please run /login") is lostRoot cause
In
src/middleware/cli-runtime-base.ts:Expected behavior
When the CLI process exits with a non-zero exit code (or exits with zero but produces no NDJSON output) and stderr contains content, the runtime should:
errorevent with the stderr content before thedoneeventdoneevent result (e.g.,result.errororresult.stderr)warnlevel so it appears in gateway logsReproduction
agents.defaults.runtime: "claude"claudeCLI is installed but NOT authenticated (claude /loginnot run)claude -p "hello"→ shows "Not logged in · Please run /login"Affected file
src/middleware/cli-runtime-base.ts—execute()method🤖 Generated with Claude Code