---
type: email
from: Copilot <notifications@github.com>
subject: Re: [openai/openai-agents-python] fix: handle odd-length audio chunks

 in voice streaming (fixes #1824) (PR #1928)
received: 2026-03-06 08:08:12
date_header: Sat, 18 Oct 2025 10:51:40 -0700
priority: normal
status: awaiting_approval
uid: 32923
---

## Email Content

**From:** Copilot <notifications@github.com>
**Subject:** Re: [openai/openai-agents-python] fix: handle odd-length audio chunks

 in voice streaming (fixes #1824) (PR #1928)
**Date:** Sat, 18 Oct 2025 10:51:40 -0700

### Body (preview)

@Copilot commented on this pull request.



## Pull Request Overview



This PR fixes a crash when transforming streamed audio buffers that occasionally have odd byte lengths by padding a zero byte so the buffer can be safely parsed as int16 PCM.

- Add zero-byte padding when the combined buffer length is odd before np.frombuffer with dtype=np.int16

- Add inline comments explaining the rationale for padding











---



<sub>**Tip:** Customize your code reviews with copilot-instructions.md. <a href="/openai/openai-agents-python/new/main/.github?filename=copilot-instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Create the file</a> or <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">learn how to get started</a>.</sub>



> +        # Combine all chunks

+        combined_buffer = b"".join(buffer)

+

+        # Pad with a zero byte if the buffer length is odd

+        # This is needed because np.frombuffer with dtype=np.int16 requires

+        # the buffer size to be a multiple of 2 bytes

+        if len(combined_buffer) % 2 != 0:

+            combined_buffer += b"\x00"

+



[nitpick] This builds combined_buffer (size N) and then, on odd lengths, allocates and copies again to append one byte, resulting in two large allocations. You can avoid the extra copy by appending the padding byte to the list of chunks and performing a single join, e.g.:

total_len = sum(len(c) for c in buffer)

if total_len % 2 != 0:

buffer = [*buffer, b\"\\x00\"]

np_array = np.frombuffer(b\"\".join(buffer), dtype=np.int16).

```suggestion

        # Combine all chunks, padding with a zero byte if the total length is odd

        total_len = sum(len(c) for c in buffer)

        if total_len % 2 != 0:

            buffer = [*buffer, b"\x00"]

        combined_buffer = b"".join(buffer)

```



> +        # Pad w

---

## Suggested Actions
- [ ] Reply
- [ ] Archive
- [ ] Escalate
