Skip to content

fix(payload-filter): resolve parameter filtering bugs for OpenAI-comp…#1

Merged
zhchang merged 1 commit intomainfrom
fix/openai-compat-parameter-filtering
Apr 14, 2026
Merged

fix(payload-filter): resolve parameter filtering bugs for OpenAI-comp…#1
zhchang merged 1 commit intomainfrom
fix/openai-compat-parameter-filtering

Conversation

@zhchang
Copy link
Copy Markdown
Owner

@zhchang zhchang commented Apr 14, 2026

…atible providers

Fix three critical bugs preventing parameter filtering from working correctly with OpenAI-compatible providers like Grok and DeepSeek:

Bug #1: Executor ordering - ApplyThinking re-adds filtered parameters

  • Move ApplyPayloadConfigWithRoot() to run AFTER ApplyThinking() in openai_compat_executor
  • Ensures filter has final authority over parameters sent to upstream provider
  • Fixes: reasoning_effort re-injected after filter removes it for suffix models (e.g., grok-3(medium))

Bug router-for-me#2: Protocol mismatch - Responses API not recognized by filter rules

  • Normalize "openai-response" protocol to "openai" in payloadModelRulesMatch()
  • Filter rules with protocol: "openai" now match both Chat Completions and Responses API
  • Fixes: Silent filter failures for Responses API requests

Bug router-for-me#3: Case-sensitive model matching

  • Make matchModelPattern() case-insensitive by lowercasing both pattern and model
  • Pattern "grok-*" now correctly matches "Grok-3", "GROK-3", etc.
  • Improves robustness for real-world model name variations

Testing

  • Added 19 comprehensive unit tests in payload_helpers_test.go
  • Added 9 QA reproduction tests in test/reasoning_effort_filter_test.go
  • All tests passing (28/28), zero regressions
  • Verified end-to-end with real provider scenarios

Documentation

  • Added FILTER_ARCHITECTURE.md documenting filter system design
  • Provides reference for future maintenance and extensibility

…atible providers

Fix three critical bugs preventing parameter filtering from working correctly with OpenAI-compatible providers like Grok and DeepSeek:

## Bug #1: Executor ordering - ApplyThinking re-adds filtered parameters
- Move ApplyPayloadConfigWithRoot() to run AFTER ApplyThinking() in openai_compat_executor
- Ensures filter has final authority over parameters sent to upstream provider
- Fixes: reasoning_effort re-injected after filter removes it for suffix models (e.g., grok-3(medium))

## Bug router-for-me#2: Protocol mismatch - Responses API not recognized by filter rules
- Normalize "openai-response" protocol to "openai" in payloadModelRulesMatch()
- Filter rules with protocol: "openai" now match both Chat Completions and Responses API
- Fixes: Silent filter failures for Responses API requests

## Bug router-for-me#3: Case-sensitive model matching
- Make matchModelPattern() case-insensitive by lowercasing both pattern and model
- Pattern "grok-*" now correctly matches "Grok-3", "GROK-3", etc.
- Improves robustness for real-world model name variations

## Testing
- Added 19 comprehensive unit tests in payload_helpers_test.go
- Added 9 QA reproduction tests in test/reasoning_effort_filter_test.go
- All tests passing (28/28), zero regressions
- Verified end-to-end with real provider scenarios

## Documentation
- Added FILTER_ARCHITECTURE.md documenting filter system design
- Provides reference for future maintenance and extensibility

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@zhchang zhchang merged commit 4fefbbc into main Apr 14, 2026
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.

1 participant