Repository navigation
refactor(providers): centralize request attribution policy - #59433
Conversation
Greptile SummaryThis PR centralizes provider attribution and endpoint classification into a single
Confidence Score: 5/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/agents/provider-attribution.ts
Line: 334-335
Comment:
**OpenRouter silently removed from proxy-like classification**
`usesExplicitProxyLikeEndpoint` explicitly excludes `endpointClass !== "openrouter"`, but the old `isDirectOpenAIBaseUrl` treated openrouter.ai as proxy-like (it only whitelisted `api.openai.com`, `chatgpt.com`, and `*.openai.azure.com`). `shouldStripResponsesPromptCache` relied on that flag, so OpenRouter-hosted models with `api: "openai-responses"` will no longer have `prompt_cache_key`/`prompt_cache_retention` stripped — a subtle reversal from prior behavior. The PR description says "OpenRouter behavior is intentionally unchanged in this pass," so this is worth confirming is deliberate.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: src/agents/provider-attribution.ts
Line: 338-344
Comment:
**`capability === "audio"` bypasses the API allowlist entirely**
When `input.capability === "audio"`, the `api` value is completely ignored — any API string (or no API at all) will satisfy the condition and trigger OpenAI attribution headers. If a caller mistakenly sets `provider: "openai"`, `capability: "audio"`, and an unrelated API string (e.g. `"openai-completions"`) with `api.openai.com` as the base URL, hidden attribution headers would still be injected. Tightening the OR to a dedicated capability branch (i.e. checking for both `api === "openai-audio-transcriptions"` and `capability === "audio"`) would make the gate explicit.
```typescript
if (
provider === "openai" &&
(api === "openai-completions" ||
api === "openai-responses" ||
(input.capability === "audio" && api === "openai-audio-transcriptions")) &&
usesOpenAIPublicAttributionHost
) {
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: src/agents/pi-embedded-runner/proxy-stream-wrappers.ts
Line: 114-120
Comment:
**OpenRouter attribution applies on non-OpenRouter base URLs**
Because `resolveProviderRequestPolicy` sets `attributionProvider = "openrouter"` solely based on `provider === "openrouter" && policy?.enabledByDefault` — with no endpoint-class check — the OpenRouter attribution headers (`HTTP-Referer`, `X-OpenRouter-Title`, `X-OpenRouter-Categories`) are also injected when a user configures `provider: "openrouter"` with a custom proxy `baseUrl`. The PR notes this is intentionally deferred, but it's worth a comment in the code since a user routing through `provider: "openrouter"` against their own proxy will silently receive OpenRouter-branded headers on every request.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "Merge branch 'main' into fix/provider-re..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 28aa1693b4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…59433) * refactor(providers): centralize request attribution policy * style(providers): normalize request policy formatting * style(providers): normalize request policy formatting * style(providers): normalize request policy formatting * docs(changelog): note provider request policy fix * fix(providers): tighten request policy gates
…59433) * refactor(providers): centralize request attribution policy * style(providers): normalize request policy formatting * style(providers): normalize request policy formatting * style(providers): normalize request policy formatting * docs(changelog): note provider request policy fix * fix(providers): tighten request policy gates
…59433) * refactor(providers): centralize request attribution policy * style(providers): normalize request policy formatting * style(providers): normalize request policy formatting * style(providers): normalize request policy formatting * docs(changelog): note provider request policy fix * fix(providers): tighten request policy gates
…59433) * refactor(providers): centralize request attribution policy * style(providers): normalize request policy formatting * style(providers): normalize request policy formatting * style(providers): normalize request policy formatting * docs(changelog): note provider request policy fix * fix(providers): tighten request policy gates
…59433) * refactor(providers): centralize request attribution policy * style(providers): normalize request policy formatting * style(providers): normalize request policy formatting * style(providers): normalize request policy formatting * docs(changelog): note provider request policy fix * fix(providers): tighten request policy gates
…59433) * refactor(providers): centralize request attribution policy * style(providers): normalize request policy formatting * style(providers): normalize request policy formatting * style(providers): normalize request policy formatting * docs(changelog): note provider request policy fix * fix(providers): tighten request policy gates
…59433) * refactor(providers): centralize request attribution policy * style(providers): normalize request policy formatting * style(providers): normalize request policy formatting * style(providers): normalize request policy formatting * docs(changelog): note provider request policy fix * fix(providers): tighten request policy gates
…59433) * refactor(providers): centralize request attribution policy * style(providers): normalize request policy formatting * style(providers): normalize request policy formatting * style(providers): normalize request policy formatting * docs(changelog): note provider request policy fix * fix(providers): tighten request policy gates
Summary
Testing
Notes