Skip to content

fix(exec): avoid empty update text blocks#73126

Merged
steipete merged 7 commits intoopenclaw:mainfrom
pfrederiksen:fix/exec-empty-output-block
Apr 28, 2026
Merged

fix(exec): avoid empty update text blocks#73126
steipete merged 7 commits intoopenclaw:mainfrom
pfrederiksen:fix/exec-empty-output-block

Conversation

@pfrederiksen
Copy link
Copy Markdown
Contributor

Summary

  • Render a (no output) placeholder when an exec update would otherwise emit an empty text block
  • Preserve existing non-empty output and warning text behavior
  • Add regression coverage for empty, non-empty, and warning-only exec update text

Fixes #73117

Validation

  • pnpm exec oxfmt --write --threads=1 src/agents/bash-tools.exec-runtime.ts src/agents/bash-tools.exec-runtime.test.ts
  • node scripts/run-vitest.mjs run --config test/vitest/vitest.agents.config.ts src/agents/bash-tools.exec-runtime.test.ts
  • pnpm exec oxlint src/agents/bash-tools.exec-runtime.ts src/agents/bash-tools.exec-runtime.test.ts
  • pnpm check:test-types

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Apr 28, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 28, 2026

Greptile Summary

This PR fixes a bug where an exec update could emit an empty text content block when both session.tail/session.aggregated and any accumulated warnings were empty. The fix extracts a renderExecUpdateText helper that substitutes a "(no output)" placeholder for a falsy tailText, and adds three unit tests covering the main cases.

Confidence Score: 5/5

Safe to merge — minimal, well-scoped change with correct logic and good test coverage.

The change is small, the extracted function is straightforward, and the three added tests cover the targeted fix. Only a missing test for the warnings + non-empty tailText combination was found, which is a low-risk P2 gap.

No files require special attention.

Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/agents/bash-tools.exec-runtime.test.ts
Line: 316-337

Comment:
**Missing test for warnings + non-empty output**

The current test matrix covers three of four input combinations for `renderExecUpdateText`. The case where both `tailText` is non-empty and `warnings` is non-empty is untested, leaving the concatenation path (`warningText + tailText`) without a regression guard.

```suggestion
describe("renderExecUpdateText", () => {
  it("uses a non-empty placeholder when an exec update has no output", () => {
    expect(renderExecUpdateText({ tailText: "", warnings: [] })).toBe("(no output)");
  });

  it("preserves non-empty exec output", () => {
    expect(renderExecUpdateText({ tailText: "hello", warnings: [] })).toBe("hello");
  });

  it("keeps warnings while still avoiding empty output text", () => {
    expect(renderExecUpdateText({ tailText: "", warnings: ["Warning: retrying"] })).toBe(
      "Warning: retrying\n\n(no output)",
    );
  });

  it("combines warnings with non-empty output", () => {
    expect(renderExecUpdateText({ tailText: "hello", warnings: ["Warning: retrying"] })).toBe(
      "Warning: retrying\n\nhello",
    );
  });
});
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "fix(exec): avoid empty update text block..." | Re-trigger Greptile

Comment thread src/agents/bash-tools.exec-runtime.test.ts
@pfrederiksen
Copy link
Copy Markdown
Contributor Author

Addressed the Greptile suggestion in src/agents/bash-tools.exec-runtime.test.ts by adding coverage for the missing warnings + non-empty output case.

The new assertion verifies renderExecUpdateText({ tailText: "hello", warnings: ["Warning: retrying"] }) renders Warning: retrying\n\nhello, so all four combinations are now covered:

  • no warnings + empty output
  • no warnings + non-empty output
  • warnings + empty output
  • warnings + non-empty output

Validation after the change:

  • targeted bash-tools.exec-runtime.test.ts passed
  • pnpm check:test-types passed

Resolved.

@pfrederiksen pfrederiksen force-pushed the fix/exec-empty-output-block branch from 59070fe to 92af2e1 Compare April 28, 2026 01:21
@steipete steipete force-pushed the fix/exec-empty-output-block branch from 92af2e1 to e526031 Compare April 28, 2026 02:00
@steipete steipete force-pushed the fix/exec-empty-output-block branch 2 times, most recently from fbfc035 to c51fbb9 Compare April 28, 2026 02:16
@openclaw-barnacle openclaw-barnacle Bot added the extensions: tokenjuice Changes to the bundled tokenjuice extension label Apr 28, 2026
@steipete steipete force-pushed the fix/exec-empty-output-block branch from c51fbb9 to b97440b Compare April 28, 2026 02:20
@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations and removed extensions: tokenjuice Changes to the bundled tokenjuice extension labels Apr 28, 2026
@steipete steipete force-pushed the fix/exec-empty-output-block branch 2 times, most recently from 6023abe to eff0fbc Compare April 28, 2026 02:46
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Apr 28, 2026
@steipete steipete force-pushed the fix/exec-empty-output-block branch 3 times, most recently from a2049d0 to f07a8a8 Compare April 28, 2026 02:54
@openclaw-barnacle openclaw-barnacle Bot removed the scripts Repository scripts label Apr 28, 2026
@steipete steipete force-pushed the fix/exec-empty-output-block branch 3 times, most recently from 6762d9e to c60bb50 Compare April 28, 2026 03:08
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Apr 28, 2026
@steipete steipete force-pushed the fix/exec-empty-output-block branch from c60bb50 to 1e3b938 Compare April 28, 2026 03:14
@openclaw-barnacle openclaw-barnacle Bot removed the scripts Repository scripts label Apr 28, 2026
@steipete steipete force-pushed the fix/exec-empty-output-block branch from 1e3b938 to d93150d Compare April 28, 2026 03:17
@steipete steipete merged commit 758262e into openclaw:main Apr 28, 2026
66 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] exec tool emits empty text content block when command produces no stdout

2 participants