From 4fa6b9285c937f87f883a9c545b9a41ae91aefcc Mon Sep 17 00:00:00 2001 From: wishforge Date: Mon, 9 Nov 2026 04:13:33 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=8A=20Keep=20the=20executor=20CLI's=20?= =?UTF-8?q?last=20words,=20with=20secrets=20removed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Raw stderr never streamed into a run because it may carry credentials, but discarding it left a stalled CLI completely silent — there was no way to tell "cannot reach the gateway" from "still thinking". The tail of stderr now goes to the worker log when a run fails, is canceled or never saw a success, with both the CLI's credential values and the usual key/token shapes removed. --- packages/runtime/src/providers/codebuddy.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/runtime/src/providers/codebuddy.ts b/packages/runtime/src/providers/codebuddy.ts index 3b5b1de..75f3cda 100644 --- a/packages/runtime/src/providers/codebuddy.ts +++ b/packages/runtime/src/providers/codebuddy.ts @@ -5,6 +5,7 @@ import os from 'node:os'; import path from 'node:path'; import { StringDecoder } from 'node:string_decoder'; import type { ProviderId } from '@wishforge/contracts'; +import { redactSecrets } from '@wishforge/contracts'; import { AGENT_GIT_IDENTITY, ManagedProvider } from './base.js'; import { executeCommand, type CommandExecutor } from '../process.js'; import { PROXY_VARIABLES } from '../sandbox.js'; @@ -469,10 +470,21 @@ export class StreamJsonCliAdapter extends ManagedProvider { pending = lines.pop() ?? ''; lines.forEach(parse); }); - child.stderr.on('data', () => undefined); // Raw diagnostics may contain credentials; do not stream them. + // Raw diagnostics never stream into the run — they may hold credentials — but throwing them away + // entirely leaves a stalled CLI silent. The worker log keeps the tail with secrets removed. + let diagnostics = ''; + const diagnosticsLimit = 8 * 1024; + const reportDiagnostics = () => { + const tail = diagnostics.slice(-4_000).trim(); + if (tail) console.warn(`[${this.dialect.label}] stderr:\n${redactSecrets(redact(tail))}`); + }; + child.stderr.on('data', (chunk: Buffer) => { + if (diagnostics.length < diagnosticsLimit) diagnostics += chunk.toString('utf8'); + }); child.on('error', error => { clearTimeout(timer); reportEstimate(); + reportDiagnostics(); this.finish(run, 'failed', redact(error.message)); }); child.on('close', code => { @@ -480,6 +492,8 @@ export class StreamJsonCliAdapter extends ManagedProvider { run.controller.signal.removeEventListener('abort', abort); parse(pending + decoder.end()); reportEstimate(); + // A run that stopped on its own says why; a failed or canceled one is worth its last words. + if (run.controller.signal.aborted || code !== 0 || failed || !sawSuccess) reportDiagnostics(); if (run.controller.signal.aborted) this.finish(run, 'canceled'); else if (code === 0 && sawSuccess && !failed) this.finish(run, 'completed'); else