Skip to content

feat(sgl): SGLang as base provider with rerank + error translation (#3131 part 1) - #3793

Open
Metbcy wants to merge 4 commits into
maximhq:devfrom
Metbcy:feat/sgl-base-provider-rerank-errors
Open

feat(sgl): SGLang as base provider with rerank + error translation (#3131 part 1)#3793
Metbcy wants to merge 4 commits into
maximhq:devfrom
Metbcy:feat/sgl-base-provider-rerank-errors

Conversation

@Metbcy

@Metbcy Metbcy commented May 27, 2026

Copy link
Copy Markdown

Implements part 1 of #3131: adds SGLang as a first-class base provider for custom providers, with rerank and error translation. Composite "custom base provider" (bundling sglang + vLLM + ollama + openai-compat) is intentionally deferred to a follow-up per the discussion on the issue.

What's in

Base provider wiring

  • SGL added to SupportedBaseProviders
  • UI: sgl in PROVIDER_SUPPORTED_REQUESTS, base-provider dropdowns, allowed-requests fragment (incl. Rerank), and SGL key-URL field threaded through ApiKeyFormFragment

Rerank (core/providers/sgl/rerank.go)

  • POSTs to /v1/rerank (no /rerank fallback; sglang only serves /v1/rerank)
  • Outgoing body intentionally omits model: sglang's V1RerankReqInput rejects unknown fields and 400s on it
  • Parses sglang's bare JSON array response ([{score, document, index}, ...]), not a wrapped {"results": [...]} envelope, and reads score (not relevance_score)
  • Guards against duplicate and out-of-range indices
  • Sets BifrostContextKeyPassthroughExtraParams=true so caller-supplied request.Params.ExtraParams are merged into the outgoing body (mirrors the vLLM rerank pattern)

Error translation (core/providers/sgl/errors.go)

  • ParseSGLError delegates to openai.ParseOpenAIError first, which already handles the wrapped envelope, gzip decoding, and status-code fallbacks
  • Falls back to sglang's flat envelope: {"object":"error","message":"...","type":"...","code":...}
  • Reads from bifrostErr.ExtraFields.RawResponse (the already-decoded body) rather than re-snapshotting resp.Body(), so gzipped 4xx/5xx responses parse correctly instead of yielding empty messages
  • Substring mappings to OpenAI codes:
    • "longer than the model's context length"context_length_exceeded / invalid_request_error
    • "out of memory"out_of_memory / server_error
    • "model is not loaded"model_not_found / invalid_request_error
  • Wired into all four chat/text completion call sites in sgl.go (sync + stream). Embedding and list-models continue to pass nil (out of scope for this PR).

Tests

  • errors_test.go (6 funcs): flat envelope, wrapped envelope, substring mappings, fallthrough preserves message, empty body delegates to fallback, gzipped flat envelope (regression test for the resp.Body() vs RawResponse fix)
  • rerank_test.go (9 funcs): nil input, no-model-field on the wire, optional-field omission, bare-array decode, document-return toggle, duplicate-index guard, out-of-range index guard, missing-score guard, nil/empty inputs
  • rerank_live_test.go (2 funcs): drives the full provider.Rerank() path against an httptest server mimicking sglang's wire shape
    • happy path: confirms Authorization, content-type, POST /v1/rerank, no model field on the wire, ExtraParams actually arrive in the outgoing body, bare-array response decodes and sorts by score desc, return_documents=true populates Document on results
    • error path: returns a gzip-encoded flat error envelope with Content-Encoding: gzip and HTTP 400, confirms the message survives decoding and the substring map resolves to context_length_exceeded
ok  github.com/maximhq/bifrost/core/providers/sgl  0.066s
go vet: clean
gofmt: clean

Out of scope

Notes for maintainers

  • No changes to existing providers (openai/, vllm/) or framework/configstore/migrations.go
  • UI changes are additive: new dropdown entries and one new conditional form field; existing flows untouched
  • Branch: feat/sgl-base-provider-rerank-errors

Summary by CodeRabbit

  • New Features

    • Added SGLang (SGL) as a supported base provider and enabled rerank support (requests and UI).
    • UI: "SGLang" option in provider forms, rerank toggle in allowed requests, and base-provider-aware API key form behavior.
    • Improved SGL error handling, including gzip-compressed error payload decoding and normalized error mapping.
  • Tests

    • Added comprehensive unit and live tests for SGL error parsing and rerank request/response behavior.

akshaydeo added 2 commits May 27, 2026 04:49
## Summary

Adds missing allowed endpoints to the release pipeline's network egress policy to unblock CI steps that require access to Google's download servers and Ubuntu's MOTD service.

## Changes

- Added `_https._tcp.dl.google.com:443` to the allowed egress endpoints to permit downloads from Google (e.g., toolchain or dependency fetches)
- Added `motd.ubuntu.com:443` (non-prefixed form) alongside the existing `_https._tcp.motd.ubuntu.com:443` entry to ensure the Ubuntu MOTD endpoint is reachable regardless of how it is resolved

## Type of change

- [ ] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Documentation
- [x] Chore/CI

## Affected areas

- [ ] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [ ] UI (React)
- [ ] Docs

## How to test

Trigger the release pipeline and verify that no network egress policy violations occur for `dl.google.com` or `motd.ubuntu.com`.

## Breaking changes

- [ ] Yes
- [x] No

## Related issues

N/A

## Security considerations

The egress allowlist is being expanded minimally and only to well-known, trusted endpoints (`dl.google.com` and `motd.ubuntu.com`). No secrets or PII are involved.

## 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)
- [x] I verified the CI pipeline passes locally if applicable
@Metbcy
Metbcy requested a review from a team as a code owner May 27, 2026 05:11
@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds SGL error parsing (flat/wrapped envelopes and substring normalization), implements /v1/rerank end-to-end (conversions, HTTP call, provider wiring), updates completion handlers to use ParseSGLError, adds unit and live tests, and registers SGL/rerank in backend and UI configuration.

Changes

SGL Provider Implementation

Layer / File(s) Summary
Rerank request wire and conversion helpers
core/providers/sgl/rerank.go
Defines sglRerankRequest and ToSGLRerankRequest, exposing passthrough ExtraParams and omitting model from outgoing SGL payloads.
Rerank response conversion and validation
core/providers/sgl/rerank.go, core/providers/sgl/rerank_test.go
ToBifrostRerankResponse parses SGL bare-array results, enforces index/score, rejects duplicates/out-of-range indices, optionally attaches documents, and sorts by descending score with index tie-breaking; unit tests cover happy and error paths.
Rerank HTTP endpoint and provider method
core/providers/sgl/rerank.go, core/providers/sgl/rerank_live_test.go
callSGLRerankEndpoint posts JSON to /v1/rerank with headers/auth, handles large bodies and gzip, decodes responses and returns structured provider errors; SGLProvider.Rerank resolves path, forwards extra params, converts results, records model/latency, and may attach raw payloads. Live tests verify request shape, extra-param forwarding, and gzip error decoding.
Completion handlers error integration
core/providers/sgl/sgl.go
Text and chat completion unary/streaming handlers now pass ParseSGLError into shared OpenAI-compatible handlers (instead of nil), and the rerank method was moved to rerank.go.
Error parsing with flat envelope and substring mapping
core/providers/sgl/errors.go, core/providers/sgl/errors_test.go
ParseSGLError delegates to openai.ParseOpenAIError, extracts SGL flat envelopes from ExtraFields.RawResponse (JSON string or decoded map), overwrites Message/Type/Code when present, and maps known message substrings (context-length exceeded, out-of-memory, model-not-loaded) to normalized OpenAI-style code/type. Unit tests cover flat/wrapped envelopes, substring mappings, fallthrough, empty body, gzip, and guard cases.

Backend and UI Registration

Layer / File(s) Summary
Backend schema and UI configuration
core/schemas/bifrost.go, ui/app/workspace/providers/dialogs/addNewCustomProviderSheet.tsx, ui/app/workspace/providers/fragments/allowedRequestsFields.tsx, ui/app/workspace/providers/fragments/apiKeysFormFragment.tsx, ui/app/workspace/providers/fragments/apiStructureFormFragment.tsx, ui/app/workspace/providers/views/providerKeyForm.tsx, ui/lib/constants/config.ts, ui/lib/types/config.ts
Adds SGL to supported base providers and BaseProvider type, registers sgl entry in PROVIDER_SUPPORTED_REQUESTS (including rerank), adds rerank to RequestTypes, exposes SGLang option in base-provider dropdowns, and passes baseProviderType into API key form fragments.

Sequence Diagram(s)

sequenceDiagram
  participant Bifrost as BifrostRerankRequest
  participant Converter as ToSGLRerankRequest
  participant SGLAPI as SGL /v1/rerank
  participant Endpoint as callSGLRerankEndpoint
  participant Parser as ToBifrostRerankResponse
  participant Provider as SGLProvider.Rerank

  Provider->>Converter: build payload (query, docs, extra params)
  Converter->>Endpoint: POST JSON (no model)
  Endpoint->>SGLAPI: send request
  SGLAPI-->>Endpoint: bare array or error body (maybe gzip)
  Endpoint->>Parser: decode/unmarshal items
  Parser-->>Provider: validated, sorted BifrostRerankResponse
  Endpoint-->>Provider: structured BifrostError on non-200 or decode failure
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Suggested reviewers

  • akshaydeo
  • danpiths
  • roroghost17

Poem

A rabbit hops through SGL's gate,
Reads errors, maps each subtle state 🐇
Reranks pages, keeps order neat,
Merges params and sorts by beat,
Now SGL sings in provider fleet. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 41.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes: adding SGLang as a base provider with rerank support and error translation.
Description check ✅ Passed The description comprehensively covers all required template sections: summary, changes, type of change, affected areas, testing instructions, breaking changes, and related issues.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@CLAassistant

CLAassistant commented May 27, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@Metbcy
Metbcy changed the base branch from main to dev May 27, 2026 05:12
@Metbcy
Metbcy force-pushed the feat/sgl-base-provider-rerank-errors branch from 6eef782 to 5ed40b0 Compare May 27, 2026 05:14

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
ui/app/workspace/providers/fragments/apiKeysFormFragment.tsx (1)

49-49: ⚡ Quick win

Tighten baseProviderType to BaseProvider instead of string.

This keeps the SGL branching strictly typed and prevents invalid values from leaking into key-form behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ui/app/workspace/providers/fragments/apiKeysFormFragment.tsx` at line 49,
Change the declared type of the prop/field baseProviderType from string to the
tighter BaseProvider union so SGL branching uses strict types; locate the
prop/interface/typing where baseProviderType is declared (e.g., in the
ApiKeysFormFragment component's props or related interface) and replace its type
annotation with BaseProvider, updating any imports if necessary and fixing any
call sites that pass non-BaseProvider values.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ui/app/workspace/providers/fragments/allowedRequestsFields.tsx`:
- Line 74: The RequestTypes entry for { key: "rerank", label: "Rerank" } must be
hidden in the "Add Custom Provider" flow: update allowedRequestsFields.tsx to
gate advanced request types (including rerank) behind a prop or mode flag (e.g.,
showAdvanced or mode !== "add") and ensure AddCustomProviderSheet passes the
flag to hide advanced types; do not remove the rerank default from form initial
state—keep it in the form values but exclude it from the UI by filtering
RequestTypes (or conditionally rendering entries) when in add-mode so defaults
remain preserved while the field is not shown.

---

Nitpick comments:
In `@ui/app/workspace/providers/fragments/apiKeysFormFragment.tsx`:
- Line 49: Change the declared type of the prop/field baseProviderType from
string to the tighter BaseProvider union so SGL branching uses strict types;
locate the prop/interface/typing where baseProviderType is declared (e.g., in
the ApiKeysFormFragment component's props or related interface) and replace its
type annotation with BaseProvider, updating any imports if necessary and fixing
any call sites that pass non-BaseProvider values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e4a37bc5-395b-437c-bdb0-4152d098237f

📥 Commits

Reviewing files that changed from the base of the PR and between 80b5e4f and 5ed40b0.

📒 Files selected for processing (14)
  • core/providers/sgl/errors.go
  • core/providers/sgl/errors_test.go
  • core/providers/sgl/rerank.go
  • core/providers/sgl/rerank_live_test.go
  • core/providers/sgl/rerank_test.go
  • core/providers/sgl/sgl.go
  • core/schemas/bifrost.go
  • ui/app/workspace/providers/dialogs/addNewCustomProviderSheet.tsx
  • ui/app/workspace/providers/fragments/allowedRequestsFields.tsx
  • ui/app/workspace/providers/fragments/apiKeysFormFragment.tsx
  • ui/app/workspace/providers/fragments/apiStructureFormFragment.tsx
  • ui/app/workspace/providers/views/providerKeyForm.tsx
  • ui/lib/constants/config.ts
  • ui/lib/types/config.ts

@greptile-apps

greptile-apps Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The change is additive: new files only, four nil→ParseSGLError wires in existing call sites, and one enum entry in bifrost.go. No existing provider logic is altered.

All core paths—request conversion, bare-array response parsing, error envelope cascading, gzip decoding—are verified by unit and live httptest tests that pass. The one edge case (raw gzip bytes surfacing in sendBackRawResponse error enrichment) affects only a debug field and does not corrupt the operation result or the decoded error message.

core/providers/sgl/rerank.go — the rawErrBody capture on the error path.

Important Files Changed

Filename Overview
core/providers/sgl/errors.go New SGLang error parser: delegates to OpenAI parser, falls back to flat envelope, applies substring mappings. Guard for flat.Object == "error" added in this revision. Logic is correct.
core/providers/sgl/rerank.go New rerank implementation targeting sglang's /v1/rerank with bare-array response parsing, index/duplicate guards, and score-desc sort. On gzip-compressed error responses, rawErrBody passed to EnrichError contains compressed bytes rather than the decoded body, so callers with sendBackRawResponse=true receive binary data instead of JSON in the error's RawResponse field.
core/providers/sgl/rerank_live_test.go Live integration tests using httptest server covering happy path and gzip error path end-to-end; good coverage of ExtraParams forwarding and error decoding.
core/providers/sgl/rerank_test.go Unit tests for request conversion and response parsing; covers nil input, no-model-field enforcement, optional fields, bare-array decode, document return toggle, duplicate/out-of-range index guards.
core/providers/sgl/errors_test.go Comprehensive error-parsing tests including gzip flat envelope, wrapped envelope, substring mappings, fallthrough, empty body, and the non-error-object regression test added in this revision.
core/providers/sgl/sgl.go ParseSGLError wired into all four chat/text completion call sites; stub Rerank removed in favor of implementation in rerank.go. Clean change with no regressions.
core/schemas/bifrost.go SGL added to SupportedBaseProviders list; additive, no regressions.
ui/lib/constants/config.ts SGL entry added to PROVIDER_SUPPORTED_REQUESTS with the full set of supported request types including rerank.
ui/lib/types/config.ts BaseProvider union type extended with "sgl"; straightforward type-level addition.
ui/app/workspace/providers/fragments/allowedRequestsFields.tsx SGL added to ProviderEndpoints with correct paths including /v1/rerank; hideAdvancedTypes prop and AdvancedRequestTypes set added; useMemo already imported; useEffect still iterates full RequestTypes for form-state consistency.
ui/app/workspace/providers/fragments/apiKeysFormFragment.tsx isSGL now also checks baseProviderType so custom providers backed by SGL inherit the keyless/URL-only key form field.
ui/app/workspace/providers/dialogs/addNewCustomProviderSheet.tsx SGLang added to base-format dropdown; hideAdvancedTypes passed to AllowedRequestsFields to hide rerank checkbox in the creation dialog (intentional deferral per PR description).
ui/app/workspace/providers/fragments/apiStructureFormFragment.tsx SGLang option added to the base-provider dropdown in the provider structure form; additive only.
ui/app/workspace/providers/views/providerKeyForm.tsx baseProviderType now threaded into ApiKeyFormFragment so the key-form renders the correct URL field for custom SGL providers.

Reviews (3): Last reviewed commit: "Address CodeRabbit & Greptile bot feedba..." | Re-trigger Greptile

Comment thread core/providers/sgl/errors.go
@akshaydeo
akshaydeo force-pushed the dev branch 3 times, most recently from 8c3e42e to b95e8e7 Compare May 31, 2026 08:03
Comment thread .github/workflows/release-pipeline.yml Outdated
@akshaydeo

Copy link
Copy Markdown
Contributor

@Metbcy are you planning to add support for completions as well - cause merging a provider with just rerank support would be tricy

@Metbcy

Metbcy commented Jun 2, 2026

Copy link
Copy Markdown
Author

@Metbcy are you planning to add support for completions as well - cause merging a provider with just rerank support would be tricy

Yes, I was planning a follow-up PR with this, should I just add it to this one?

Implements maximhq#3131 (part 1 of 2).

- Add SGL to SupportedBaseProviders, wire UI dropdowns and key-URL field
- core/providers/sgl/rerank.go: POST /v1/rerank, omit `model` field
  (sglang's V1RerankReqInput rejects unknowns), parse bare-array
  response with `score` (not `relevance_score`), guard against
  duplicate and out-of-range indices
- core/providers/sgl/errors.go: ParseSGLError delegates to OpenAI
  parser first (handles wrapped envelope + gzip + status fallbacks),
  falls back to sglang's flat `{object:error,message,type,code}`
  envelope. Substring mappings: context_length_exceeded,
  out_of_memory, model_not_found
- Wire ParseSGLError into chat/text completion sync + stream paths
- Rerank opts into BifrostContextKeyPassthroughExtraParams=true so
  caller-supplied ExtraParams are merged into the outgoing body
  (mirrors vLLM pattern)
- ParseSGLError reads from bifrostErr.ExtraFields.RawResponse (the
  already-decoded body) instead of re-snapshotting resp.Body(), so
  gzipped 4xx/5xx from sglang parse correctly
- Tests: errors_test.go (6 funcs incl. gzip flat envelope),
  rerank_test.go (9 funcs), rerank_live_test.go (full Rerank() path
  through httptest server: ExtraParams forwarded, gzipped 400 decoded)
@Metbcy
Metbcy force-pushed the feat/sgl-base-provider-rerank-errors branch from 5ed40b0 to 92123d8 Compare June 2, 2026 21:30

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@core/providers/sgl/errors.go`:
- Around line 84-89: The setSGLErrorCode function currently creates pointers by
taking addresses of local copies (c := code; t := typ; field.Code = &c;
field.Type = &t); update it to use the repository helper bifrost.Ptr(...)
instead (set field.Code = bifrost.Ptr(code) and field.Type = bifrost.Ptr(typ))
to follow project conventions and avoid local address-of usage while keeping the
function name setSGLErrorCode unchanged.

In `@ui/app/workspace/providers/fragments/allowedRequestsFields.tsx`:
- Line 74: The current mount logic overwrites all keys in RequestTypes
(including allowed_requests.rerank) with provider defaults, causing saved false
values to be reset; change the update so it only applies provider-support
defaults for keys that are undefined or when the base provider actually changes.
Specifically, in the code that merges provider support defaults into
RequestTypes (referencing RequestTypes, allowed_requests, rerank and the "base
provider" variable), preserve existing explicit saved values on initial render
by checking for undefined before assigning defaults, and only force-coerce
fields when the base provider identity changes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1a454661-8355-4b82-add1-490eb1786fd8

📥 Commits

Reviewing files that changed from the base of the PR and between 5ed40b0 and 92123d8.

📒 Files selected for processing (14)
  • core/providers/sgl/errors.go
  • core/providers/sgl/errors_test.go
  • core/providers/sgl/rerank.go
  • core/providers/sgl/rerank_live_test.go
  • core/providers/sgl/rerank_test.go
  • core/providers/sgl/sgl.go
  • core/schemas/bifrost.go
  • ui/app/workspace/providers/dialogs/addNewCustomProviderSheet.tsx
  • ui/app/workspace/providers/fragments/allowedRequestsFields.tsx
  • ui/app/workspace/providers/fragments/apiKeysFormFragment.tsx
  • ui/app/workspace/providers/fragments/apiStructureFormFragment.tsx
  • ui/app/workspace/providers/views/providerKeyForm.tsx
  • ui/lib/constants/config.ts
  • ui/lib/types/config.ts

Comment thread core/providers/sgl/errors.go
Comment thread ui/app/workspace/providers/fragments/allowedRequestsFields.tsx
@Metbcy

Metbcy commented Jun 2, 2026

Copy link
Copy Markdown
Author

Bot feedback addressed in 19ef565:

  • CodeRabbit (rerank in Add Custom Provider): Added a hideAdvancedTypes prop to AllowedRequestsFields that filters rerank out of the UI when used in the Add Custom Provider dialog. Form defaults still seed all RequestTypes, so behavior is preserved.
  • Greptile P2 (object == "error" guard): Added the guard at the call-site and a regression test (TestParseSGLError_NonErrorObjectIgnored).
  • Also added an sgl entry to ProviderEndpoints with /v1/rerank so the path-override placeholder matches.

- Hide rerank from Add Custom Provider dialog via hideAdvancedTypes
  prop; keeps default in form state but removes from UI to satisfy
  the scoped-fields requirement (CodeRabbit)
- Guard flat sglang error envelope detection on object=="error"
  so a non-sglang JSON proxy response with a top-level message can't
  hijack the error mapping (Greptile P2) + regression test
- Add sgl entry to ProviderEndpoints with /v1/rerank so the path
  override placeholder matches the provider (Greptile P2)
@Metbcy
Metbcy force-pushed the feat/sgl-base-provider-rerank-errors branch from 19ef565 to 0240a97 Compare June 2, 2026 21:49

@coderabbitai coderabbitai Bot left a comment

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.

♻️ Duplicate comments (1)
ui/app/workspace/providers/fragments/allowedRequestsFields.tsx (1)

122-130: ⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Reset effect still re-defaults saved rerank (and other) values on mount.

hideAdvancedTypes only affects which toggles render; the effect still iterates the full RequestTypes and unconditionally calls setValue(..., !isRequestTypeDisabled(providerType, key), { shouldDirty: true }) whenever providerType changes (including initial mount). In the edit flow a stored allowed_requests.rerank = false is flipped back to the support default. Consider only coercing keys when the base provider identity actually changes, preserving explicit saved values on first render.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ui/app/workspace/providers/fragments/allowedRequestsFields.tsx` around lines
122 - 130, The effect that resets RequestTypes unconditionally is overwriting
saved values on mount; change it so it only coerces fields when the provider
identity actually changes rather than on initial render. Implement a
previous-provider check (e.g., prevProviderRef) or an initial-mount guard inside
the useEffect that compares prevProviderRef.current to providerType and only
runs the RequestTypes.forEach/setValue loop when they differ (skip when prev is
undefined), or alternatively only call setValue when getValues(fieldName) is
undefined to preserve explicit saved values; update prevProviderRef.current =
providerType after the check. Ensure you reference the existing useEffect,
RequestTypes, setValue, isRequestTypeDisabled, providerType, namePrefix and
getValues symbols when applying the fix.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@ui/app/workspace/providers/fragments/allowedRequestsFields.tsx`:
- Around line 122-130: The effect that resets RequestTypes unconditionally is
overwriting saved values on mount; change it so it only coerces fields when the
provider identity actually changes rather than on initial render. Implement a
previous-provider check (e.g., prevProviderRef) or an initial-mount guard inside
the useEffect that compares prevProviderRef.current to providerType and only
runs the RequestTypes.forEach/setValue loop when they differ (skip when prev is
undefined), or alternatively only call setValue when getValues(fieldName) is
undefined to preserve explicit saved values; update prevProviderRef.current =
providerType after the check. Ensure you reference the existing useEffect,
RequestTypes, setValue, isRequestTypeDisabled, providerType, namePrefix and
getValues symbols when applying the fix.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 46dc25aa-b118-4644-8f8c-a17d8a097737

📥 Commits

Reviewing files that changed from the base of the PR and between 92123d8 and 0240a97.

📒 Files selected for processing (4)
  • core/providers/sgl/errors.go
  • core/providers/sgl/errors_test.go
  • ui/app/workspace/providers/dialogs/addNewCustomProviderSheet.tsx
  • ui/app/workspace/providers/fragments/allowedRequestsFields.tsx

@akshaydeo
akshaydeo force-pushed the dev branch 4 times, most recently from e389df7 to a65fce4 Compare June 8, 2026 11:25
@akshaydeo
akshaydeo force-pushed the dev branch 4 times, most recently from fa15f50 to ca190fc Compare June 21, 2026 11:44
@akshaydeo
akshaydeo force-pushed the dev branch 2 times, most recently from ac30a53 to 7c66b20 Compare July 1, 2026 12:24
@akshaydeo
akshaydeo force-pushed the dev branch 2 times, most recently from 44564de to 493bff0 Compare July 18, 2026 01:10
@akshaydeo

Copy link
Copy Markdown
Contributor

Hi @Metbcy — thanks for the contribution! This PR is currently blocked because our CLA bot shows the Contributor License Agreement as not yet signed. Could you sign it here so we can move this forward: https://cla-assistant.io/maximhq/bifrost?pullRequest=3793

Let us know if you run into any issues signing.

@Metbcy

Metbcy commented Jul 31, 2026

Copy link
Copy Markdown
Author

Hi @Metbcy — thanks for the contribution! This PR is currently blocked because our CLA bot shows the Contributor License Agreement as not yet signed. Could you sign it here so we can move this forward: https://cla-assistant.io/maximhq/bifrost?pullRequest=3793

Let us know if you run into any issues signing.

Hi @akshaydeo, I've signed it!

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.

3 participants