Skip to content

fix(media): auto-skip tiny/empty audio files before transcription (#8127) - #8388

Merged
steipete merged 5 commits into
openclaw:mainfrom
Glucksberg:fix/8127-whisper-skip-empty-audio
Mar 2, 2026
Merged

steipete merged 5 commits into
openclaw:mainfrom
Glucksberg:fix/8127-whisper-skip-empty-audio

Conversation

@Glucksberg

@Glucksberg Glucksberg commented Feb 4, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #8127

When tiny or empty audio files are sent for transcription, the Whisper API returns unhelpful errors.

Changes:

  • Added MIN_AUDIO_FILE_BYTES = 1024 constant
  • Added "tooSmall" to MediaUnderstandingSkipReason
  • File size guard in both provider path (runProviderEntry) and CLI path (runCliEntry)
  • Files below 1KB are skipped with a descriptive MediaUnderstandingSkipError
  • 3 new tests (tiny file skip, empty file skip, valid file proceeds)
  • Updated existing test fixtures to use buffers above the threshold

Greptile Overview

Greptile Summary

Adds a minimum-audio-size guard (MIN_AUDIO_FILE_BYTES = 1024) so tiny/empty audio attachments are skipped before being sent to transcription providers/CLI, returning a MediaUnderstandingSkipError with new reason tooSmall. Updates existing media-understanding tests to use buffers above the threshold and adds a dedicated test suite covering tiny, empty, and valid audio inputs.

This integrates at the runner layer (runProviderEntry and runCliEntry) so both provider-based transcription and local CLI transcription paths avoid unhelpful upstream errors for near-empty files.

Confidence Score: 4/5

  • This PR is likely safe to merge; the core guard is simple and well-covered by tests.
  • The change is localized (a constant, a new skip reason, and two size checks) and has targeted test coverage for tiny/empty/valid local audio. Remaining concerns are mostly around test robustness/coverage for URL-based attachments rather than runtime correctness.
  • src/media-understanding/runner.skip-tiny-audio.test.ts (assertion robustness), src/media-understanding/apply.test.ts (remote/URL tiny-audio coverage)

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +66 to +69
expect(result.outputs).toHaveLength(0);
expect(result.decision.outcome).toBe("skipped");
expect(result.decision.attachments[0]?.attempts[0]?.outcome).toBe("skipped");
expect(result.decision.attachments[0]?.attempts[0]?.reason).toContain("tooSmall");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Optional chaining makes the assertions here non-failing if attachments[0] / attempts[0] is missing.

Right now expect(result.decision.attachments[0]?.attempts[0]?.outcome) will evaluate to undefined if the arrays are empty, which can hide regressions where no attempt is recorded. Consider asserting the array lengths first and then indexing without ?..

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/media-understanding/runner.skip-tiny-audio.test.ts
Line: 66:69

Comment:
[P2] Optional chaining makes the assertions here non-failing if `attachments[0]` / `attempts[0]` is missing.

Right now `expect(result.decision.attachments[0]?.attempts[0]?.outcome)` will evaluate to `undefined` if the arrays are empty, which can hide regressions where no attempt is recorded. Consider asserting the array lengths first and then indexing without `?.`.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in a583fafd — replaced optional chaining with strict assertions that verify array lengths before indexing.

@greptile-apps

greptile-apps Bot commented Feb 4, 2026

Copy link
Copy Markdown
Contributor
Additional Comments (1)

src/media-understanding/apply.test.ts
[P3] apply.test.ts mocks fetchRemoteMedia to always return a 2048-byte buffer (see beforeEach), so the URL-only audio test can’t exercise the new tiny/empty audio skip behavior for remote attachments.

If the intent is to cover #8127 for URL attachments too, add a small-buffer mock in a dedicated test (or override the mock for this test) to assert the decision is skipped with reason tooSmall.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/media-understanding/apply.test.ts
Line: 175:179

Comment:
[P3] `apply.test.ts` mocks `fetchRemoteMedia` to always return a 2048-byte buffer (see beforeEach), so the URL-only audio test can’t exercise the new tiny/empty audio skip behavior for remote attachments.

If the intent is to cover #8127 for URL attachments too, add a small-buffer mock in a dedicated test (or override the mock for this test) to assert the decision is `skipped` with reason `tooSmall`.

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

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

@Glucksberg
Glucksberg force-pushed the fix/8127-whisper-skip-empty-audio branch from b8168d6 to 1d72a66 Compare February 4, 2026 05:11
@Glucksberg

Copy link
Copy Markdown
Contributor Author

Fixed in 8e67960e4:

[P2] Optional chaining in test assertions: The assertions at lines 69-71 actually use direct property access, not optional chaining. The preceding toHaveLength(1) check on line 68 ensures attachments[0] exists before the subsequent assertions.

[P3] URL-only audio test: Added a dedicated test "skips URL-only audio when remote file is too small" in apply.test.ts that overrides the fetchRemoteMedia mock with a 100-byte buffer and verifies the transcription provider is never called.

@Glucksberg
Glucksberg force-pushed the fix/8127-whisper-skip-empty-audio branch 5 times, most recently from 343efda to 921c874 Compare February 7, 2026 13:48
@Glucksberg
Glucksberg force-pushed the fix/8127-whisper-skip-empty-audio branch from 921c874 to ca6a82d Compare February 8, 2026 01:31
@Glucksberg
Glucksberg force-pushed the fix/8127-whisper-skip-empty-audio branch 6 times, most recently from 75d6c98 to c395418 Compare February 10, 2026 13:31
@Glucksberg
Glucksberg force-pushed the fix/8127-whisper-skip-empty-audio branch from c395418 to 46011f2 Compare February 11, 2026 01:34
@Glucksberg
Glucksberg force-pushed the fix/8127-whisper-skip-empty-audio branch 2 times, most recently from f3dee69 to 6e72990 Compare February 11, 2026 13:33
@Glucksberg
Glucksberg force-pushed the fix/8127-whisper-skip-empty-audio branch from 6e72990 to a990c8c Compare February 12, 2026 01:32
@Glucksberg
Glucksberg force-pushed the fix/8127-whisper-skip-empty-audio branch from a990c8c to e0c5c85 Compare February 13, 2026 01:34
@Glucksberg
Glucksberg force-pushed the fix/8127-whisper-skip-empty-audio branch from 1637a90 to 711166c Compare February 15, 2026 22:33
@Glucksberg
Glucksberg force-pushed the fix/8127-whisper-skip-empty-audio branch from 711166c to d6d05d2 Compare February 16, 2026 10:38
@Glucksberg
Glucksberg force-pushed the fix/8127-whisper-skip-empty-audio branch 2 times, most recently from 06603c3 to e72894c Compare February 16, 2026 22:34
@Glucksberg
Glucksberg force-pushed the fix/8127-whisper-skip-empty-audio branch from e72894c to 82544bb Compare February 17, 2026 01:50
Glucksberg added a commit to Glucksberg/OpenClaw that referenced this pull request Feb 17, 2026
@Glucksberg
Glucksberg force-pushed the fix/8127-whisper-skip-empty-audio branch from 82544bb to cf746bc Compare February 17, 2026 10:34
@Glucksberg
Glucksberg force-pushed the fix/8127-whisper-skip-empty-audio branch from cf746bc to 01dd84c Compare February 17, 2026 22:31
@Glucksberg
Glucksberg force-pushed the fix/8127-whisper-skip-empty-audio branch from 01dd84c to e25345e Compare February 18, 2026 10:34
@Glucksberg
Glucksberg force-pushed the fix/8127-whisper-skip-empty-audio branch from e25345e to a5da5d5 Compare February 18, 2026 22:36
@Glucksberg
Glucksberg force-pushed the fix/8127-whisper-skip-empty-audio branch from a5da5d5 to 7a8d757 Compare February 19, 2026 10:33
@Glucksberg
Glucksberg force-pushed the fix/8127-whisper-skip-empty-audio branch 2 times, most recently from 0d117bd to da99ef8 Compare February 20, 2026 02:08
@mudrii

This comment was marked as spam.

Glucksberg and others added 5 commits March 2, 2026 10:56
…cription

Add a minimum file size guard (MIN_AUDIO_FILE_BYTES = 1024) before
sending audio to transcription APIs. Files below this threshold are
almost certainly empty or corrupt and would cause unhelpful errors
from Whisper/Deepgram/Groq providers.

Changes:
- Add 'tooSmall' skip reason to MediaUnderstandingSkipError
- Add MIN_AUDIO_FILE_BYTES constant (1024 bytes) to defaults
- Guard both provider and CLI audio paths in runner.ts
- Add comprehensive tests for tiny, empty, and valid audio files
- Update existing test fixtures to use audio files above threshold
Increase test audio file sizes to meet MIN_AUDIO_FILE_BYTES (1024) threshold
introduced by the skip-empty-audio feature. Fix localPathRoots in skip-tiny-audio
tests so temp files pass path validation. Remove undefined loadApply() call
in apply.test.ts.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@steipete

steipete commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

Landed via temp rebase onto main.

  • Gate: pnpm vitest src/media-understanding/apply.test.ts src/media-understanding/runner.skip-tiny-audio.test.ts
  • Land commit: 4740ef3daf0e25ff140f5adb8bcb4a6f305166ab
  • Merge commit: f7b0378

Thanks @Glucksberg!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Auto-skip tiny/empty audio files in whisper skills

3 participants