Skip to content

[Feat]: Mirror request plugins execution to the response path#2369

Merged
k8s-ci-robot merged 1 commit intokubernetes-sigs:mainfrom
abdallahsamabd:feat/2354
Mar 3, 2026
Merged

[Feat]: Mirror request plugins execution to the response path#2369
k8s-ci-robot merged 1 commit intokubernetes-sigs:mainfrom
abdallahsamabd:feat/2354

Conversation

@abdallahsamabd
Copy link
Copy Markdown
Contributor

@abdallahsamabd abdallahsamabd commented Feb 18, 2026

Add response plugin execution support to the BBR (Body-Based Router) system, mirroring the existing request plugin path. This enables use cases like response guardrails and content filtering before returning responses to the user.

Changes:

  • Add responsePlugins field to BBR Server struct and NewServer constructor
  • Implement HandleResponseBody to execute response plugins on the response body
  • Add processResponseBody for streaming response body buffering (mirrors processRequestBody)
  • Thread ResponsePlugins through ExtProcServerRunner
  • Update integration test harness to accept response plugins
  • Add unit tests (6) and gRPC integration tests (2) for response plugin execution

Note: Plugins are executed for validation, logging, and side effects, but mutated body/headers are not yet applied to the ext_proc response. Applying mutations (including updating dependent headers like content-length) is deferred to a follow-up to avoid inconsistencies

Note: Configuration of response plugins (CLI flags, Helm chart values) is intentionally left out of scope, as the project is converging on file-based configuration.

What type of PR is this?

/kind feature

What this PR does / why we need it:
The BBR plugin system currently only supports executing plugins on the request path. This PR mirrors that execution to the response path, allowing plugins implementing the PayloadProcessor interface to inspect and mutate response bodies before they are returned to the client. This is useful for response guardrails, content filtering, auditing, and other post-processing use cases.

Which issue(s) this PR fixes:
Ref #2354

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot k8s-ci-robot added the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Feb 18, 2026
@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 18, 2026

Deploy Preview for gateway-api-inference-extension ready!

Name Link
🔨 Latest commit 26471c5
🔍 Latest deploy log https://app.netlify.com/projects/gateway-api-inference-extension/deploys/69a6f5fbb33130000756b471
😎 Deploy Preview https://deploy-preview-2369--gateway-api-inference-extension.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented Feb 18, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: abdallahsamabd / name: abdallahsamabd (26471c5)

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 18, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Welcome @abdallahsamabd!

It looks like this is your first PR to kubernetes-sigs/gateway-api-inference-extension 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/gateway-api-inference-extension has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Feb 18, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @abdallahsamabd. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Feb 18, 2026
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 18, 2026
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Feb 18, 2026
@abdallahsamabd
Copy link
Copy Markdown
Contributor Author

/retest

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

@abdallahsamabd: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Comment thread pkg/bbr/README.md Outdated
This extension works by parsing the request body. If it finds a `model` parameter in the
request body, it will copy the value of that parameter into a request header.

## Pluggable BBR Plugins
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.

can we revert the change in the README.md?
on the one hand, yes we're starting the add the pluging support.
but on the other hand, this is still not wired properly, so we still don't want to expose it to users (we don't want a user to try and don't understand why it is still not working).

Copy link
Copy Markdown
Contributor Author

@abdallahsamabd abdallahsamabd Feb 19, 2026

Choose a reason for hiding this comment

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

ok sure
done

@nirrozenbaum
Copy link
Copy Markdown
Contributor

@abdallahsamabd a general comment that spreads across multiple files:
can we keep this PR focused on response plugins execution while keeping how we set them plugins out of scope?

more concretely - if we can leave the --response plugins out of runner, as well as the helm chart updates.
the main reason is that, we should converge on configuration from file. so these are going to be removed soon.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 19, 2026
@nirrozenbaum
Copy link
Copy Markdown
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 19, 2026
@abdallahsamabd
Copy link
Copy Markdown
Contributor Author

@nirrozenbaum
both review comments were fixed
thanks

Add response plugin support to the pluggable BBR system, enabling use
cases like response guardrails and content filtering.

Changes:
- Add responsePlugins to BBR Server struct
- Implement response plugin execution loop in HandleResponseBody
- Add processResponseBody for streaming response body buffering
- Add --response-plugin CLI flag (mirrors --plugin)
- Thread response plugins through ExtProcServerRunner
- Update Helm chart templates and values for responsePlugins
- Add unit tests (6) and gRPC integration tests (2)
- Update pkg/bbr/README.md and chart README with plugin docs

Signed-off-by: abdallahsamabd <abdallahsamabd@gmail.com>
Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com>
Comment on lines +175 to +180
noopPlugin := &fakeResponsePlugin{
name: "noop",
mutateFn: func(_ context.Context, headers map[string]string, body map[string]any) (map[string]string, map[string]any, error) {
return headers, body, nil
},
}
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.

can you explain what is this text with noop plugin? why is it needed?

Copy link
Copy Markdown
Contributor Author

@abdallahsamabd abdallahsamabd Mar 3, 2026

Choose a reason for hiding this comment

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

The noop plugin is needed to bypass the len(s.responsePlugins) == 0 early return in HandleResponseBody. Without it, the test would only exercise the no-plugins shortcut path. The noop ensures we go through the full code path (JSON unmarshal → plugin execution → response construction) in streaming mode, validating it completes without errors.

"Noop" stands for no operation — it's a plugin that does nothing. It receives the headers and body, and returns them unchanged. It exists purely to satisfy the "has plugins" condition so the code doesn't take the early-return shortcut.

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.

got it. maybe it would be good to reuse the mutating plugin, so we can check that plugin is actually executed correctly in streaming mode.

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.

since mutations are not yet applied to the response in this PR, we can't verify the plugin's effect from the returned response. Once we add mutation in the follow-up we'll update this test to use a mutating plugin

Copy link
Copy Markdown
Contributor

@nirrozenbaum nirrozenbaum left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

Thanks!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 3, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abdallahsamabd, nirrozenbaum

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 3, 2026
@k8s-ci-robot k8s-ci-robot merged commit cefd0d9 into kubernetes-sigs:main Mar 3, 2026
11 checks passed
abdallahsamabd added a commit to abdallahsamabd/gateway-api-inference-extension that referenced this pull request Mar 9, 2026
Follow-up to kubernetes-sigs#2354 / PR kubernetes-sigs#2369. Exercises the full Process loop
(request body -> response headers -> response body) to validate that
response plugins can mutate the response body over a real gRPC
ext_proc stream.

Covers:
- Unary mode: response plugin mutates the response body
- Unary mode: no response plugins results in passthrough behavior

Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com>
RyanRosario pushed a commit to RyanRosario/gateway-api-inference-extension that referenced this pull request Mar 9, 2026
…s#2369)

Add response plugin support to the pluggable BBR system, enabling use
cases like response guardrails and content filtering.

Changes:
- Add responsePlugins to BBR Server struct
- Implement response plugin execution loop in HandleResponseBody
- Add processResponseBody for streaming response body buffering
- Add --response-plugin CLI flag (mirrors --plugin)
- Thread response plugins through ExtProcServerRunner
- Update Helm chart templates and values for responsePlugins
- Add unit tests (6) and gRPC integration tests (2)
- Update pkg/bbr/README.md and chart README with plugin docs

Signed-off-by: abdallahsamabd <abdallahsamabd@gmail.com>
Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com>
abdallahsamabd added a commit to abdallahsamabd/gateway-api-inference-extension that referenced this pull request Mar 12, 2026
Follow-up to kubernetes-sigs#2354 / PR kubernetes-sigs#2369. Exercises the full Process loop
(request body -> response headers -> response body) to validate that
response plugins can mutate the response body over a real gRPC
ext_proc stream.

Covers:
- Unary mode: response plugin mutates the response body
- Unary mode: no response plugins results in passthrough behavior

Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com>
abdallahsamabd added a commit to abdallahsamabd/gateway-api-inference-extension that referenced this pull request Mar 15, 2026
Follow-up to kubernetes-sigs#2354 / PR kubernetes-sigs#2369. Exercises the full Process loop
(request body -> response headers -> response body) to validate that
response plugins can mutate the response body over a real gRPC
ext_proc stream.

Covers:
- Unary mode: response plugin mutates the response body
- Unary mode: no response plugins results in passthrough behavior

Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com>
abdallahsamabd added a commit to abdallahsamabd/gateway-api-inference-extension that referenced this pull request Mar 18, 2026
Follow-up to kubernetes-sigs#2354 / PR kubernetes-sigs#2369. Exercises the full Process loop
(request body -> response headers -> response body) to validate that
response plugins can mutate the response body over a real gRPC
ext_proc stream.

Covers:
- Unary mode: response plugin mutates the response body
- Unary mode: no response plugins results in passthrough behavior

Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com>
abdallahsamabd added a commit to abdallahsamabd/gateway-api-inference-extension that referenced this pull request Mar 18, 2026
Follow-up to kubernetes-sigs#2354 / PR kubernetes-sigs#2369. Exercises the full Process loop
(request body -> response headers -> response body) to validate that
response plugins can mutate the response body over a real gRPC
ext_proc stream.

Covers:
- Unary mode: response plugin mutates the response body
- Unary mode: no response plugins results in passthrough behavior

Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com>
Made-with: Cursor
abdallahsamabd added a commit to abdallahsamabd/gateway-api-inference-extension that referenced this pull request Mar 24, 2026
Follow-up to kubernetes-sigs#2354 / PR kubernetes-sigs#2369. Exercises the full Process loop
(request body -> response headers -> response body) to validate that
response plugins can mutate the response body over a real gRPC
ext_proc stream.

Covers:
- Unary mode: response plugin mutates the response body
- Unary mode: no response plugins results in passthrough behavior

Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com>
Made-with: Cursor
abdallahsamabd added a commit to abdallahsamabd/gateway-api-inference-extension that referenced this pull request Mar 29, 2026
Follow-up to kubernetes-sigs#2354 / PR kubernetes-sigs#2369. Exercises the full Process loop
(request body -> response headers -> response body) to validate that
response plugins can mutate the response body over a real gRPC
ext_proc stream.

Covers:
- Unary mode: response plugin mutates the response body
- Unary mode: no response plugins results in passthrough behavior

Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com>
Made-with: Cursor
abdallahsamabd added a commit to abdallahsamabd/gateway-api-inference-extension that referenced this pull request Mar 29, 2026
Follow-up to kubernetes-sigs#2354 / PR kubernetes-sigs#2369. Exercises the full Process loop
(request body -> response headers -> response body) to validate that
response plugins can mutate the response body over a real gRPC
ext_proc stream.

Covers:
- Unary mode: response plugin mutates the response body
- Unary mode: no response plugins results in passthrough behavior

Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com>
Made-with: Cursor
abdallahsamabd added a commit to abdallahsamabd/gateway-api-inference-extension that referenced this pull request Mar 30, 2026
Follow-up to kubernetes-sigs#2354 / PR kubernetes-sigs#2369. Exercises the full Process loop
(request body -> response headers -> response body) to validate that
response plugins can mutate the response body over a real gRPC
ext_proc stream.

Covers:
- Unary mode: response plugin mutates the response body
- Unary mode: no response plugins results in passthrough behavior

Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com>
Made-with: Cursor
abdallahsamabd added a commit to abdallahsamabd/gateway-api-inference-extension that referenced this pull request Mar 30, 2026
Follow-up to kubernetes-sigs#2354 / PR kubernetes-sigs#2369. Exercises the full Process loop
(request body -> response headers -> response body) to validate that
response plugins can mutate the response body over a real gRPC
ext_proc stream.

Covers:
- Unary mode: response plugin mutates the response body
- Unary mode: no response plugins results in passthrough behavior

Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com>
Made-with: Cursor
abdallahsamabd added a commit to abdallahsamabd/gateway-api-inference-extension that referenced this pull request Mar 30, 2026
Follow-up to kubernetes-sigs#2354 / PR kubernetes-sigs#2369. Exercises the full Process loop
(request body -> response headers -> response body) to validate that
response plugins can mutate the response body over a real gRPC
ext_proc stream.

Covers:
- Unary mode: response plugin mutates the response body
- Unary mode: no response plugins results in passthrough behavior

Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com>
Made-with: Cursor
abdallahsamabd added a commit to abdallahsamabd/gateway-api-inference-extension that referenced this pull request Mar 30, 2026
Follow-up to kubernetes-sigs#2354 / PR kubernetes-sigs#2369. Exercises the full Process loop
(request body -> response headers -> response body) to validate that
response plugins can mutate the response body over a real gRPC
ext_proc stream.

Covers:
- Unary mode: response plugin mutates the response body
- Unary mode: no response plugins results in passthrough behavior

Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com>
Made-with: Cursor
abdallahsamabd added a commit to abdallahsamabd/gateway-api-inference-extension that referenced this pull request Mar 30, 2026
Follow-up to kubernetes-sigs#2354 / PR kubernetes-sigs#2369. Exercises the full Process loop
(request body -> response headers -> response body) to validate that
response plugins can mutate the response body over a real gRPC
ext_proc stream.

Covers:
- Unary mode: response plugin mutates the response body
- Unary mode: no response plugins results in passthrough behavior

Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com>
Made-with: Cursor
k8s-ci-robot pushed a commit that referenced this pull request Mar 31, 2026
Follow-up to #2354 / PR #2369. Exercises the full Process loop
(request body -> response headers -> response body) to validate that
response plugins can mutate the response body over a real gRPC
ext_proc stream.

Covers:
- Unary mode: response plugin mutates the response body
- Unary mode: no response plugins results in passthrough behavior


Made-with: Cursor

Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com>
nirrozenbaum pushed a commit to llm-d/llm-d-inference-payload-processor that referenced this pull request Apr 28, 2026
…s/gateway-api-inference-extension#2369)

Add response plugin support to the pluggable BBR system, enabling use
cases like response guardrails and content filtering.

Changes:
- Add responsePlugins to BBR Server struct
- Implement response plugin execution loop in HandleResponseBody
- Add processResponseBody for streaming response body buffering
- Add --response-plugin CLI flag (mirrors --plugin)
- Thread response plugins through ExtProcServerRunner
- Update Helm chart templates and values for responsePlugins
- Add unit tests (6) and gRPC integration tests (2)
- Update pkg/bbr/README.md and chart README with plugin docs

Signed-off-by: abdallahsamabd <abdallahsamabd@gmail.com>
Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com>
nirrozenbaum pushed a commit to llm-d/llm-d-inference-payload-processor that referenced this pull request Apr 28, 2026
…gateway-api-inference-extension#2450)

Follow-up to kubernetes-sigs/gateway-api-inference-extension#2354 / PR kubernetes-sigs/gateway-api-inference-extension#2369. Exercises the full Process loop
(request body -> response headers -> response body) to validate that
response plugins can mutate the response body over a real gRPC
ext_proc stream.

Covers:
- Unary mode: response plugin mutates the response body
- Unary mode: no response plugins results in passthrough behavior


Made-with: Cursor

Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants