Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(dream): show retained phase warning details in human output (#5238)

time-attacke720659ccf34
diff --git a/src/commands/dream.ts b/src/commands/dream.ts
index f938da986b..fb9a05a13b 100644
--- a/src/commands/dream.ts
+++ b/src/commands/dream.ts
@@ -38,6 +38,7 @@ import { opError, type OperationError } from '../core/ops/contract.ts';
import { usageError, writeCliError, writeCliRefusal } from '../cli/cli-error.ts';
import { fetchSource } from '../core/sources-load.ts';
import { existsSync } from 'fs';
+import { truncateUtf8 } from '../core/text-safe.ts';
import { resolve } from 'node:path';
interface DreamArgs {
@@ -542,6 +543,15 @@ function printHuman(report: CycleReport) {
console.log(` ✗ ${source ?? concept ?? '?'}: ${error ?? 'unknown error'}`);
}
}
+ const warnings = Array.isArray(details?.warnings)
+ ? details.warnings.filter((warning): warning is string => typeof warning === 'string')
+ : [];
+ for (const warning of warnings.slice(0, 5)) {
+ console.log(` ! ${warning.length > 300 ? `${truncateUtf8(warning, 300)}…` : warning}`);
+ }
+ if (warnings.length > 5) {
+ console.log(` … ${warnings.length - 5} more warning(s); use --json for all details.`);
+ }
if (p.error) {
const hint = p.error.hint ? ` (${p.error.hint})` : '';
console.log(` [${p.error.class}/${p.error.code}] ${p.error.message}${hint}`);
diff --git a/test/dream-clean-status-skip-visibility.test.ts b/test/dream-clean-status-skip-visibility.test.ts
index 1b87294e59..9116cbbdd4 100644
--- a/test/dream-clean-status-skip-visibility.test.ts
+++ b/test/dream-clean-status-skip-visibility.test.ts
@@ -205,3 +205,62 @@ describe('printHuman — synthesize_concepts failures are named', () => {
expect(failLine!).toContain('wiki');
});
});
+
+describe('printHuman — phase warning details', () => {
+ function warningPhase(details: Record<string, unknown> = {}): PhaseResult {
+ return {
+ phase: 'propose_takes',
+ status: 'fail',
+ duration_ms: 100,
+ summary: 'aborted on auth error after 1 page(s) (1 warning(s))',
+ details,
+ };
+ }
+
+ test('a partial cycle prints the extractor error behind the auth summary', () => {
+ const warning = 'aborting phase at page 1/10: auth error (extractor failed on notes/example: provider credentials not configured)';
+ const r = report([synthesizePhase({}, 'no transcripts to process'), warningPhase({ warnings: [warning] })], emptyTotals());
+ expect(r.status).toBe('partial');
+ const lines = captureLog(() => printHuman(r));
+ expect(lines).toContain(` ! ${warning}`);
+ expect(lines.some(line => line.includes('aborted on auth error'))).toBe(true);
+ });
+
+ test('large warning lists show five details and direct operators to the complete JSON', () => {
+ const warnings = Array.from({ length: 7 }, (_, i) => `extractor failure ${i + 1}`);
+ const lines = captureLog(() => printHuman(report([warningPhase({ warnings })], emptyTotals())));
+ for (const warning of warnings.slice(0, 5)) expect(lines).toContain(` ! ${warning}`);
+ expect(lines.join('\n')).not.toContain('extractor failure 6');
+ expect(lines.join('\n')).not.toContain('extractor failure 7');
+ expect(lines).toContain(' … 2 more warning(s); use --json for all details.');
+ });
+
+ test('exactly five warnings print without an omitted-count line; six print one omitted', () => {
+ const five = Array.from({ length: 5 }, (_, i) => `warning ${i + 1}`);
+ const fiveLines = captureLog(() => printHuman(report([warningPhase({ warnings: five })], emptyTotals())));
+ expect(fiveLines.filter(line => line.startsWith(' ! '))).toHaveLength(5);
+ expect(fiveLines.join('\n')).not.toContain('more warning(s)');
+ const sixLines = captureLog(() => printHuman(report([warningPhase({ warnings: [...five, 'warning 6'] })], emptyTotals())));
+ expect(sixLines).toContain(' … 1 more warning(s); use --json for all details.');
+ });
+
+ test('non-string entries are skipped and do not count toward the limit', () => {
+ const lines = captureLog(() => printHuman(report([warningPhase({ warnings: [null, 'kept warning', 7, { text: 'x' }] })], emptyTotals())));
+ expect(lines.filter(line => line.startsWith(' ! '))).toEqual([' ! kept warning']);
+ expect(lines.join('\n')).not.toContain('more warning(s)');
+ });
+
+ test('a long warning is bounded to 300 characters on human stdout', () => {
+ const long = `extractor failed on notes/example: ${'x'.repeat(1000)}`;
+ const lines = captureLog(() => printHuman(report([warningPhase({ warnings: [long] })], emptyTotals())));
+ const shown = lines.find(line => line.startsWith(' ! '))!;
+ expect(shown).toBe(` ! ${long.slice(0, 300)}…`);
+ });
+
+ test('absent, empty, or non-string warning details do not add output', () => {
+ for (const details of [{}, { warnings: [] }, { warnings: 'not an array' }, { warnings: [null, {}] }]) {
+ const lines = captureLog(() => printHuman(report([warningPhase(details)], emptyTotals())));
+ expect(lines).toHaveLength(2);
+ }
+ });
+});