Skip to content

feat(call_runner): send raw bytes as the request body - #79

Draft
rickstaa wants to merge 6 commits into
mainfrom
rs/call-runner-request-bytes
Draft

rickstaa wants to merge 6 commits into
mainfrom
rs/call-runner-request-bytes

Conversation

@rickstaa

@rickstaa rickstaa commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

call_runner can already return raw bytes (result.content and result.content_type), but the request body was always JSON. Apps that take an image or audio needed a base64 shim on both sides.

This adds content (bytes) and content_type (default application/octet-stream) as an alternative to payload, mirroring result.content and result.content_type on the way back. The bytes are sent as is. Passing both payload and content raises an error. It works with the paid retry and with stream=True. JSON calls are unchanged, since the new arguments are only passed down when content is set.

timeout is the total time for each buffered request attempt, so large bodies need a larger value. It restarts on every payment retry and is not applied when stream=True. Streaming a body from an iterator is not included.

Tests: the request-side cases are in tests/test_call_runner_raw.py, in a new "Requests" section beside the existing "Responses" ones (bytes sent unchanged with the given content type, default content type, empty body, JSON unchanged, streaming, and the mutual exclusion). tests/test_live_runner.py has a paid-retry test showing the 402 retry re-sends the raw body.

The response side already returns raw bytes. The request side only took
a JSON payload, so apps taking an image or audio needed a base64 shim.
`data` and `content_type` send the bytes as is, exclusive with `payload`.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@rickstaa
rickstaa requested a review from j0sh as a code owner October 15, 2026 13:53
Copilot AI balanced review requested due to automatic review settings October 15, 2026 13:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No blocking correctness issues were found; remaining documentation and regression-coverage suggestions are non-blocking.

2 open findings
What changed in this PR

Adds raw-byte request bodies to call_runner, allowing binary inputs without base64 encoding while preserving JSON behavior.

Changes:

  • Adds mutually exclusive data and payload arguments with configurable content type.
  • Forwards raw bodies through buffered, streaming, and payment-retry paths.
  • Adds request-body tests and a changelog entry.
File Description
tests/​test_call_runner_request_bytes.py Tests binary bodies, JSON compatibility, streaming, and argument validation.
src/​livepeer_gateway/​live_runner.py Exposes and forwards raw-body arguments.
src/​livepeer_gateway/​http.py Supports bytes and content types in HTTP helpers.
CHANGELOG.md Documents binary request support.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/livepeer_gateway/live_runner.py Outdated
Comment on lines +817 to +818
for apps that take an image, audio or any other binary body. Raise ``timeout`` for
large bodies, since it bounds the whole request.
Comment thread src/livepeer_gateway/live_runner.py Outdated
Comment on lines +829 to +830
body_kwargs: dict[str, Any] = (
{"data": data, "content_type": content_type} if data is not None else {}
@rickstaa
rickstaa marked this pull request as draft October 15, 2026 13:58
rickstaa and others added 5 commits October 15, 2026 16:00
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Matches `result.content` on the response side, and stops `data` meaning
the JSON dict on the result but raw bytes on the request.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Also cover that a paid retry re-sends the raw body unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@j0sh

j0sh commented Oct 17, 2026

Copy link
Copy Markdown
Collaborator

Thanks for this. I extended things to also support streamable request bodies - the change turned out to be larger than I anticipated but I think it's a pretty good example of a tidy API that hides a lot of complexity. #80

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants