Repository navigation
Conversation
Greptile SummaryFixes Confidence Score: 5/5Safe to merge — focused one-function fix with a targeted regression test and no surface-area expansion. The change is minimal and consistent with the established normalizeProviderTransportWithPlugin / normalizeProviderConfigWithPlugin pattern. The new test covers the chaining semantics, and no existing tests broke. No security, data, or auth paths are touched. No files require special attention. Reviews (1): Last reviewed commit: "fix(plugins): iterate all providers in w..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 52d72471a9
ℹ️ 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".
| for (const candidate of resolveProviderPluginsForHooks(params)) { | ||
| if (!candidate.wrapStreamFn || candidate === matchedPlugin) { | ||
| continue; |
There was a problem hiding this comment.
Filter wrapStreamFn candidates to matching providers
wrapProviderStreamFn now iterates resolveProviderPluginsForHooks(params) without checking whether each candidate matches params.provider, so any enabled provider plugin with a wrapStreamFn can wrap every request. This is a behavioral regression from the previous single-owner path and can corrupt non-target providers (for example, extensions/openrouter/stream.ts always applies the OpenRouter thinking wrapper, which mutates payload reasoning fields, even when the active provider is unrelated). Please gate the loop to candidates that match the provider id/aliases before calling their wrapper.
Useful? React with 👍 / 👎.
52d7247 to
8eddeec
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8eddeecdea
ℹ️ 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".
| // wrap the already-wrapped stream. This enables external plugins to compose | ||
| // additional stream transformations on top of the built-in provider's wrapper. | ||
| for (const candidate of resolveProviderPluginsForHooks(params)) { | ||
| if (!candidate.wrapStreamFn || candidate === matchedPlugin) { |
There was a problem hiding this comment.
Avoid double-invoking the matched provider stream wrapper
The dedupe guard in wrapProviderStreamFn uses reference equality (candidate === matchedPlugin), but matchedPlugin is resolved through a providerRefs lookup while the loop resolves the full provider list, and each lookup rebuilds provider objects (src/plugins/providers.runtime.ts:216-219), so the same provider is not reference-equal and its wrapStreamFn runs twice for provider-owned requests. This introduces duplicate wrapping (e.g., repeated header/payload mutations) on normal traffic; dedupe should use a stable identity like pluginId + id or a shared candidate list.
Useful? React with 👍 / 👎.
wrapProviderStreamFn() previously only checked a single provider via resolveProviderHookPlugin(). When a built-in provider (e.g. Anthropic) owned the provider ID, external plugins with matching hookAliases could never contribute their own wrapStreamFn. Apply the same iteration pattern already used by normalizeProviderTransportWithPlugin() and normalizeProviderConfigWithPlugin(): check the primary matched plugin first, then iterate all providers from resolveProviderPluginsForHooks() to let hookAlias plugins compose additional stream wrappers on top. This enables external plugins to chain stream transformations (e.g. injecting custom tool types into the API payload) without replacing the built-in provider's wrapper. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
8eddeec to
63df5c7
Compare
|
Both P1 issues addressed in the latest push:
Test updated to include an unrelated |
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Keep open: the provider stream-wrapper composition bug remains source-visible on current main, but this PR is not merge-ready because it targets the pre-split wrapper location, is now conflicting, and only has unit/mock proof. Canonical path: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review. So I’m closing this here because the remaining work is already tracked in the canonical issue. Review detailsBest possible solution: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review. Do we have a high-confidence way to reproduce the issue? Yes at source level: current main's active wrapper invokes only the resolved provider plugin wrapper and does not iterate additional matching hookAlias providers. No live external-plugin reproduction was run in this read-only review. Is this the best way to solve the issue? No as submitted: the fix idea is plausible, but the PR targets the old file and is now conflicting. The best fix is a current-main port into Security review: Security review cleared: The diff changes in-process provider hook composition and a unit test only, with no dependency, workflow, permission, download, or secret-handling changes. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against c5afa92c1f8a. |
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
|
This pull request has been automatically marked as stale due to inactivity. |
|
This pull request has been automatically marked as stale due to inactivity. |
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: fix(plugins): iterate all providers in wrapProviderStreamFn This is item 1/1 in the current shard. Shard 8/22. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
|
Closing due to inactivity. |
Summary
wrapProviderStreamFn()only checked a single provider viaresolveProviderHookPlugin(). When a built-in provider (e.g. Anthropic) owned the provider ID, external plugins with matchinghookAliasescould never contribute their ownwrapStreamFn.normalizeProviderTransportWithPlugin()andnormalizeProviderConfigWithPlugin(): check the primary matched plugin first, then iterate all providers fromresolveProviderPluginsForHooks().wrapProviderStreamFn()insrc/plugins/provider-runtime.ts. No other functions changed.Change Type
Bug fix —
wrapStreamFnon external plugins withhookAliasesis accepted at registration but never called when a built-in provider matches.Root Cause
wrapProviderStreamFn()calledresolveProviderHookPlugin()which returns the first matching provider (typically the built-in). The built-in provider'swrapStreamFnwas used exclusively. External plugins registered viahookAliaseswere discovered byresolveProviderPluginsForHooks()but never consulted forwrapStreamFn.The pattern for iterating all providers already existed in
normalizeProviderTransportWithPlugin()(line 457) andnormalizeProviderConfigWithPlugin()(line 486) —wrapProviderStreamFnwas the only provider hook that didn't follow it.Regression Test Plan
Added test: "chains wrapStreamFn from primary provider and hookAlias plugin"
id: "anthropic") and an external plugin (id: "custom-anthropic",hookAliases: ["anthropic"])wrapStreamFnctx.streamFnRun:
pnpm vitest run src/plugins/provider-runtime.test.tsSecurity Impact
Human Verification
provider-runtime.test.ts)normalizeProviderTransportWithPluginexactlyctx.streamFn🤖 Generated with Claude Code