fix: dropped instructions and content_filter status on responses->chat fallback - #5223
Shaik-Sirajuddin wants to merge 4 commits into
Conversation
📝 WalkthroughWalkthroughResponses-to-Chat fallback conversion now preserves instructions, logs dropped unsupported fields, and receives provider loggers across fallback paths. Finish-reason mapping and tests now cover content-filter incomplete responses and streams. ChangesResponses fallback behavior
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant ResponsesProvider
participant ToChatRequest
participant Logger
participant ChatCompletion
Client->>ResponsesProvider: submit Responses request
ResponsesProvider->>ToChatRequest: convert with provider logger
ToChatRequest->>Logger: warn about dropped unsupported fields
ToChatRequest-->>ChatCompletion: return Chat request
ChatCompletion-->>ResponsesProvider: return response or stream
ResponsesProvider-->>Client: return Responses result
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
## Summary Briefly explain the purpose of this PR and the problem it solves. ## Changes - What was changed and why - Any notable design decisions or trade-offs ## Type of change - [ ] Bug fix - [ ] Feature - [ ] Refactor - [ ] Documentation - [ ] Chore/CI ## Affected areas - [ ] Core (Go) - [ ] Transports (HTTP) - [ ] Providers/Integrations - [ ] Plugins - [ ] UI (React) - [ ] Docs ## How to test Describe the steps to validate this change. Include commands and expected outcomes. ```sh # Core/Transports go version go test ./... # UI cd ui pnpm i || npm i pnpm test || npm test pnpm build || npm run build ``` If adding new configs or environment variables, document them here. ## Screenshots/Recordings If UI changes, add before/after screenshots or short clips. ## Breaking changes - [ ] Yes - [ ] No If yes, describe impact and migration instructions. ## Related issues Link related issues and discussions. Example: Closes maximhq#123 ## Security considerations Note any security implications (auth, secrets, PII, sandboxing, etc.). ## Checklist - [ ] I read `docs/contributing/README.md` and followed the guidelines - [ ] I added/updated tests where appropriate - [ ] I updated documentation where needed - [ ] I verified builds succeed (Go and UI) - [ ] I verified the CI pipeline passes locally if applicable
c49b7cb to
973fc3a
Compare
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (3): Last reviewed commit: "fix: dropped instructions and content_fi..." | Re-trigger Greptile |
973fc3a to
a8811dc
Compare
…t fallback Every provider without native Responses API support (Ollama, vLLM, DeepSeek, Groq, Mistral, and others) converts v1/responses requests to Chat Completions via ToChatRequest. That conversion silently discarded the caller's `instructions` field and never mapped a `content_filter` finish reason to an `incomplete` status, so responses came back well-formed but semantically wrong with no signal that anything was lost. - Prepend `instructions` as a leading system message in ToChatRequest, mirroring LiteLLM's equivalent chat-completions bridge. - Map `content_filter` finish reason to `status: incomplete`, reusing the previously-declared-but-unused ResponsesResponseIncompleteReasonContentFilter constant; fixes both streaming and non-streaming paths since they share one mapping function. - Log a warning whenever a tool or tool_choice value is dropped for having no Chat Completions equivalent, via each provider's own instance-bound logger (not a process-global — avoids cross-instance/ tenant log attribution bugs when multiple Bifrost instances run with different loggers). - ToChatRequest's new logger parameter is variadic and optional, so the exported zero-argument call shape still compiles for existing Go SDK consumers. Verified live against a real Ollama backend; before/after evidence in memory/gen/responses-chat-fallback/reports/.
a8811dc to
4ae75d4
Compare
Before/after evidence for the Greptile P1 fixAddressing the review comment with logs, not just a claim. Before (commit
|
44564de to
493bff0
Compare
244a01d to
ce1b2a6
Compare
Summary
Every provider without native Responses API support (Ollama, vLLM, DeepSeek, Groq, Mistral, and others) converts
v1/responsesrequests to Chat Completions viaToChatRequest. That conversion silently discarded the caller'sinstructionsfield and never mapped acontent_filterfinish reason to anincompletestatus — responses came back well-formed but semantically wrong, with no signal anything was lost.Changes
instructionsas a leading system message inToChatRequest(mirrors LiteLLM's equivalent chat-completions bridge).content_filterfinish reason tostatus: incomplete, reusing the previously-declared-but-unusedResponsesResponseIncompleteReasonContentFilterconstant — fixes both streaming and non-streaming paths since they share one mapping function.tool_choicevalue is dropped for having no Chat Completions equivalent, via a newFallbackWarningHook(thread-safeatomic.Pointer, following the existingproviderUtils.SetLogger/getLoggerconvention).Type of change
How to test
Also verified live end-to-end against a real Ollama backend (
qwen3:0.6b) via theopenaiPython SDK — before/after request/response transcripts, server logs, and terminal screenshots are inmemory/gen/responses-chat-fallback/reports/.Breaking changes