feat: global pass-through setting#1591
Conversation
Add a system-wide pass-through setting that mirrors the existing global user-agent pass-through and aggregates with each channel's setting. Channels with PassThroughBody unset (nil) inherit from the global value; explicit true/false on a channel still overrides. The system general settings page now groups User-Agent Pass-Through and Pass-Through into a single card to save vertical space, and the channel form switches its body pass-through control to the same three-state (inherit / enabled / disabled) selector used for User-Agent. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Greptile SummaryThis PR adds a system-wide pass-through toggle that mirrors the existing User-Agent pass-through setting. Confidence Score: 5/5Safe to merge; only P2 findings remain after the previously-raised P1 (multiple DB queries per request) was already noted in an earlier review round. All findings are P2 or below. The implementation is consistent with the existing User-Agent pass-through pattern, backwards-compatible JSON serialisation is preserved, and the GraphQL schema change is additive. internal/server/orchestrator/pass_through.go — the global DB lookup is still called up to 3× per request on the inherit path (pre-existing open issue). frontend/src/features/channels/components/channels-action-dialog.tsx — inherit state does not surface the prompt-injection warning. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Request enters orchestrator] --> B[isPassThroughEnabled called]
B --> C{channel == nil?}
C -- yes --> D[return false]
C -- no --> E{API formats match?}
E -- no --> D
E -- yes --> F{channel.Settings.PassThroughBody != nil?}
F -- yes --> G[use channel-level value]
F -- no --> H{systemService != nil?}
H -- no --> I[return false default]
H -- yes --> J[systemService.PassThrough DB lookup]
J --> K{error?}
K -- yes --> L[log warn, return false]
K -- no --> M[use global value]
G --> N[return enabled]
M --> N
Reviews (2): Last reviewed commit: "fix: lint issues from global pass-throug..." | Re-trigger Greptile |
| switch { | ||
| case channel.Settings != nil && channel.Settings.PassThroughBody != nil: | ||
| enabled = *channel.Settings.PassThroughBody | ||
| case systemService != nil: | ||
| global, err := systemService.PassThrough(ctx) | ||
| if err != nil { | ||
| log.Warn(ctx, "failed to get global pass-through setting", log.Cause(err)) | ||
|
|
||
| return false | ||
| } | ||
|
|
||
| enabled = global | ||
| } | ||
|
|
||
| return enabled |
There was a problem hiding this comment.
Multiple DB queries per request on the inherit path
isPassThroughEnabled is called from three separate middlewares per request (applyPassThroughRequestBody, captureRawProviderResponse/captureRawProviderStream, and applyPassThroughResponse/applyPassThroughStream). For channels that inherit from the global setting (PassThroughBody == nil), each call triggers a separate systemService.PassThrough(ctx) DB lookup — up to 3 queries per request. By contrast, applyUserAgentPassThrough queries the DB once.
Consider fetching the global value once per request (e.g. store it in orchestratorState or resolve it once at the top of Process and pass the resolved bool into the middleware constructors) so the hot path is not subject to repeated round-trips.
There was a problem hiding this comment.
Code Review
This pull request introduces a global system-level "Pass-Through" setting for request and response bodies, allowing individual channels to either inherit this global configuration or explicitly override it. Key changes include updating the PassThroughBody field to a pointer type in the backend to support nullability, implementing new GraphQL queries and mutations for system-wide settings, and enhancing the frontend UI with a three-state selection for channels and a global toggle in the general settings. I have no feedback to provide.
- silence gosec G101 false positive on SystemKeyPassThrough (it's a setting key, not a credential), matching the existing suppression on SystemKeySecretKey - fix misspell: behaviour -> behavior Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Summary
PassThroughBodyunset (nil) now inherit from the global value; explicit true/false still overridesTest plan
passThroughBody = inherit, enable the global setting, and confirm pass-through takes effect when inbound and outbound API formats matchenabled/disabled) and confirm the channel value wins regardless of the global settingpassThroughBody: truekeep behaving the same after upgradego test ./internal/server/orchestrator/...and./internal/server/biz/...still pass🤖 Generated with Claude Code