Skip to content

Conversation

@jptaylor
Copy link
Contributor

@jptaylor jptaylor commented Oct 20, 2025

  • Adds: Support for passing custom request data through when using SmallWebRTC via runner
  • Fixes: client request data casing mismatches

The SmallWebRTCRequest dataclass expected Python snake_case field names (request_data), but the Pipecat JavaScript SDK passes a camelCase property (requestData) due to it's natural APIRequest typing. This caused custom request data from JS clients to be silently ignored during deserialization.

  • Added a from_dict() classmethod to SmallWebRTCRequest that maps requestData (camelCase) to request_data (snake_case) when present, enabling proper deserialization from both naming conventions.
  • Pass request data through to the bot module in the runner, which we were not currently doing.
  • Updated the RunnerArguments base class to support body which should be support by all current and future transport types.

@codecov
Copy link

codecov bot commented Oct 20, 2025

Codecov Report

❌ Patch coverage is 0% with 16 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/pipecat/services/aws/nova_sonic/llm.py 0.00% 8 Missing ⚠️
.../pipecat/transports/smallwebrtc/request_handler.py 0.00% 5 Missing ⚠️
src/pipecat/runner/types.py 0.00% 2 Missing ⚠️
src/pipecat/runner/run.py 0.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/pipecat/runner/run.py 0.00% <0.00%> (ø)
src/pipecat/runner/types.py 0.00% <0.00%> (ø)
.../pipecat/transports/smallwebrtc/request_handler.py 0.00% <0.00%> (ø)
src/pipecat/services/aws/nova_sonic/llm.py 0.00% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

self.handle_sigint = False
self.handle_sigterm = False
self.pipeline_idle_timeout_secs = 300
self.body = self.body or {}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it makes sense to move the "body" here, since it seems it will be common to all transports and will allow receiving any custom data from the user.

And we will need to do the same inside the base image.

Tagging @mark for a second opinion on this, since he’s worked a lot more with the runners.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

➕ . Also, inconsistency in transport params for common properties like this can make building multi-transport bot files tricky. For me at least, this makes sense to have as a default.

Copy link
Contributor

Choose a reason for hiding this comment

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

This creates an inheritance issue, resulting in a TypeError.

The new body parameter is initialized in the RunnerArguments while the the subclass has a non-default required parameter room_url. To solve this, we would need to either:

  • defer initializing body (e.g. init=False) (this is breaking, I think)
  • Make body kw_only=True (Potentially breaking if args provided positionally)
  • Initialize body in the SmallWebRTCRunnerArguments (not breaking)

Maybe this is the best outcome?

@dataclass
class RunnerArguments:
    handle_sigint: bool = field(init=False)
    handle_sigterm: bool = field(init=False)
    pipeline_idle_timeout_secs: int = field(init=False)
    body: dict[str, Any] = field(default_factory=dict, kw_only=True)

    def __post_init__(self):
        self.handle_sigint = False
        self.handle_sigterm = False
        self.pipeline_idle_timeout_secs = 300

This makes body a keyword-arg, but that eliminates ambiguity across transports. (It is semi-breaking though..)

Any changes made here need to be made to pipecatcloud types, as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

The least breaking option is to just add to SmallWebRTCRunnerArguments, but you keep the transport inconsistency (for positional args only).

@jptaylor what do you mean by:

Also, inconsistency in transport params for common properties like this can make building multi-transport bot files tricky.

Is it if you're using positional args?

Copy link
Contributor

Choose a reason for hiding this comment

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

FYI: @aconchillo just proposed this change, coincidentally.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@markbackman I can see how this is breaking. I will wait for @aconchillo to input.

Is it if you're using positional args?

Perhaps best to ignore input here as I'm clearly missing important context based on your comment (I didn't consider the positional args case, for example!) My point about multi-transport was that some bot methods can receive args that are either Daily or SmallWebRTC, so having a tight base class definition for request data seems like a good idea. If body was on RunnerArguments, for example, I would not have had to update the definition for SmallWebRTCRunnerArguments as part of this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it. In the case of multi-transport, you can just use the RunnerArguments type. This already works well and is employed in a number of our examples. Two different ways this is done:

You would only use the specific type if you have a single transport type.

@jptaylor jptaylor changed the title draft patch: pass request data through to bot module Support arbitrary request data when using SmallWebRTC with bot runner Oct 20, 2025
@jptaylor jptaylor marked this pull request as ready for review October 20, 2025 22:34
@aconchillo
Copy link
Contributor

The body argument to RunnerArguments is now added here: #2891, it also makes all other fiels in RunnerArguments keyword-only.

From this PR, we still have:

  • from_dict()
  • linting
  • Pass request data through to the bot module in the runner, which we were not currently doing.

"""Accept both snake_case and camelCase for the request_data field."""
if "requestData" in data and "request_data" not in data:
data["request_data"] = data.pop("requestData")
return cls(**data)
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason for allowing both options?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the main reason is not break our webSDK, which is currently sending it as "requestData".

@markbackman
Copy link
Contributor

The majority of this functionality was added in: #2891.

Adding the last part in #2977.

Closing.

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.

5 participants