test: add keyless model listener filter demo#957
Open
mukeshbaphna wants to merge 1 commit into
Open
Conversation
c981880 to
a535524
Compare
Contributor
Author
|
Hi @Spherrrical @salmanap, this follow-up is ready for review when you have a chance. It builds on #947 by adding a local model-listener filter demo with both input and output filters, plus an optional OpenAI config for provider-backed testing. |
7c56809 to
92e764a
Compare
mukeshbaphna
commented
May 24, 2026
| run_test "Allowed request (joke)" 200 '{ | ||
| run_test "Output filter redacts provider response" 200 '{ | ||
| "model": "gpt-4o-mini", | ||
| "messages": [{"role": "user", "content": "Tell me a joke"}], |
Contributor
Author
There was a problem hiding this comment.
... this is not to reduce coverage. I wanted to make sure the smoke test covered all three aspects: allow, block, and redact.
mukeshbaphna
commented
May 24, 2026
Contributor
Author
mukeshbaphna
left a comment
There was a problem hiding this comment.
added a comment to explain why I removed additional "safe request: joke, expects 200"
92e764a to
3aadb2d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a model-listener filter demo that exercises both input and output filters. The default path is fully local and requires no provider API keys or hosted model access. A second config lets developers run the same filter chain against the real OpenAI endpoint when they want provider-backed testing.
This follows up on #947 by proving the valid model-listener filter path end-to-end after invalid filter references now fail closed.
Changes
config.openai.yamlfor optional real OpenAI testinginput_filtersandoutput_filtersPLANO_CONFIG_FILEWhy this helps developers
Developers can validate model-listener guardrails locally before using real providers. This catches filter wiring mistakes early, supports CI without secrets, and demonstrates request blocking plus response redaction without adding a passthrough agent layer.
Local Testing
uv run --with pytest --with fastapi --with httpx --with pydantic python -m pytest demos/filter_chains/model_listener_filter/test_services.py -q # 4 passedAlso validated the updated demo config with
validate_and_render_schema.Also validated
config.openai.yamlwithvalidate_and_render_schema.Note: local pre-push
npm run lintcurrently fails on unrelated existing frontend lint issues inpackages/shared-stylesandpackages/ui; this PR only changesdemos/filter_chains/model_listener_filter.