Anthropic: wire explicit service tier params#45453
Conversation
14952ac to
f1c9349
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f1c934936d
ℹ️ 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".
Greptile SummaryThis PR wires explicit One structural issue to address:
Confidence Score: 4/5Safe to merge after removing the two duplicate Bedrock utility exports accidentally included in anthropic-stream-wrappers.ts. The core logic — service-tier resolution, wrapper composition, precedence over fast mode — is correct and well-tested. The only concrete defect is createBedrockNoCacheWrapper and isAnthropicBedrockModel being exported from anthropic-stream-wrappers.ts as dead code when the identical functions already live in bedrock-stream-wrappers.ts. Since no caller picks them up from the new location this does not affect runtime behavior today, but it is misleading, creates a maintenance hazard, and should be cleaned up before the branch lands. src/agents/pi-embedded-runner/anthropic-stream-wrappers.ts — remove the two duplicate Bedrock utility functions added at the end of the file.
|
| Filename | Overview |
|---|---|
| src/agents/pi-embedded-runner/anthropic-stream-wrappers.ts | Adds createAnthropicServiceTierWrapper, resolveAnthropicServiceTier, and the normalizer helper — all correct. Also appends duplicate createBedrockNoCacheWrapper and isAnthropicBedrockModel that already exist identically in bedrock-stream-wrappers.ts and are never imported from here; these are dead code in the wrong file. |
| src/agents/pi-embedded-runner/extra-params.ts | Wires resolveAnthropicServiceTier and createAnthropicServiceTierWrapper into applyPostPluginStreamWrappers. Service-tier wrapper is applied before the fast-mode wrapper, making it the inner layer; per streamWithPayloadPatch chaining semantics the inner onPayload fires first, so an explicit tier correctly wins over a fast-mode default. |
| src/agents/pi-embedded-runner-extraparams.test.ts | Adds six targeted tests covering camelCase and snake_case params, OAuth path, explicit-tier-over-fast-mode precedence, and the proxied-base-URL skip. Good coverage for the new behavior. |
| src/config/io.ts | One-line fix removing a duplicate sourceConfig key that caused a pnpm check failure after the rebase; straightforward and correct. |
| CHANGELOG.md | Adds an Unreleased entry for the new explicit Anthropic service-tier support. Entry is well-placed and follows the existing format. |
Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/agents/pi-embedded-runner/anthropic-stream-wrappers.ts
Line: 428-440
Comment:
**Dead duplicate exports accidentally landed in this file**
`createBedrockNoCacheWrapper` and `isAnthropicBedrockModel` added here are byte-for-byte copies of the same exports that already live in `bedrock-stream-wrappers.ts`. `extra-params.ts` continues to import them from `"./bedrock-stream-wrappers.js"` (line 22), so these new exports are never consumed — they are dead code in the wrong file.
This appears to be a copy-paste artifact from an earlier draft. The two functions should be removed from `anthropic-stream-wrappers.ts`; no callers will pick them up from here as long as the import in `extra-params.ts` points to `bedrock-stream-wrappers.js`.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix(config): drop duplicate healed sourc..." | Re-trigger Greptile
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 24f8cfaf9f
ℹ️ 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".
* Anthropic: add explicit service tier wrapper * Runner: wire explicit Anthropic service tiers * Tests: cover explicit Anthropic service tiers * Changelog: note Anthropic service tier follow-up * fix(agents): make Anthropic service tiers override fast mode * fix(config): drop duplicate healed sourceConfig * docs(anthropic): update fast mode service tier guidance * fix(agents): remove dead Anthropic Bedrock exports * fix(agents): avoid cross-provider Anthropic tier warnings * fix(agents): avoid cross-provider OpenAI tier warnings
* Anthropic: add explicit service tier wrapper * Runner: wire explicit Anthropic service tiers * Tests: cover explicit Anthropic service tiers * Changelog: note Anthropic service tier follow-up * fix(agents): make Anthropic service tiers override fast mode * fix(config): drop duplicate healed sourceConfig * docs(anthropic): update fast mode service tier guidance * fix(agents): remove dead Anthropic Bedrock exports * fix(agents): avoid cross-provider Anthropic tier warnings * fix(agents): avoid cross-provider OpenAI tier warnings
* Anthropic: add explicit service tier wrapper * Runner: wire explicit Anthropic service tiers * Tests: cover explicit Anthropic service tiers * Changelog: note Anthropic service tier follow-up * fix(agents): make Anthropic service tiers override fast mode * fix(config): drop duplicate healed sourceConfig * docs(anthropic): update fast mode service tier guidance * fix(agents): remove dead Anthropic Bedrock exports * fix(agents): avoid cross-provider Anthropic tier warnings * fix(agents): avoid cross-provider OpenAI tier warnings
* Anthropic: add explicit service tier wrapper * Runner: wire explicit Anthropic service tiers * Tests: cover explicit Anthropic service tiers * Changelog: note Anthropic service tier follow-up * fix(agents): make Anthropic service tiers override fast mode * fix(config): drop duplicate healed sourceConfig * docs(anthropic): update fast mode service tier guidance * fix(agents): remove dead Anthropic Bedrock exports * fix(agents): avoid cross-provider Anthropic tier warnings * fix(agents): avoid cross-provider OpenAI tier warnings
* Anthropic: add explicit service tier wrapper * Runner: wire explicit Anthropic service tiers * Tests: cover explicit Anthropic service tiers * Changelog: note Anthropic service tier follow-up * fix(agents): make Anthropic service tiers override fast mode * fix(config): drop duplicate healed sourceConfig * docs(anthropic): update fast mode service tier guidance * fix(agents): remove dead Anthropic Bedrock exports * fix(agents): avoid cross-provider Anthropic tier warnings * fix(agents): avoid cross-provider OpenAI tier warnings
* Anthropic: add explicit service tier wrapper * Runner: wire explicit Anthropic service tiers * Tests: cover explicit Anthropic service tiers * Changelog: note Anthropic service tier follow-up * fix(agents): make Anthropic service tiers override fast mode * fix(config): drop duplicate healed sourceConfig * docs(anthropic): update fast mode service tier guidance * fix(agents): remove dead Anthropic Bedrock exports * fix(agents): avoid cross-provider Anthropic tier warnings * fix(agents): avoid cross-provider OpenAI tier warnings
* Anthropic: add explicit service tier wrapper * Runner: wire explicit Anthropic service tiers * Tests: cover explicit Anthropic service tiers * Changelog: note Anthropic service tier follow-up * fix(agents): make Anthropic service tiers override fast mode * fix(config): drop duplicate healed sourceConfig * docs(anthropic): update fast mode service tier guidance * fix(agents): remove dead Anthropic Bedrock exports * fix(agents): avoid cross-provider Anthropic tier warnings * fix(agents): avoid cross-provider OpenAI tier warnings
Summary
service_tier, but explicit AnthropicserviceTier/service_tiermodel params were still ignored.standard_onlyorauto, and explicit Anthropic tiers could not reliably override/fastdefaults.sk-ant-oat-*traffic on the same public API path; explicit service tiers now beat fast-mode defaults, while caller-provided payload values still win.src/config/io.tsfix from currentmainto remove a duplicatesourceConfigkey that brokepnpm checkafter the rebase.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause / Regression History (if applicable)
fastModecould shapeservice_tier. After rebasing onto currentmain, there was also a wrapper-order bug where explicitserviceTierstill lost tofastModeuntil the composition order was corrected.serviceTieron OAuth, for explicit-tier-versus-fast-mode precedence, or for the proxied-base-url skip path.git blame, prior PR, issue, or refactor if known): fix: inject anthropic service_tier for OAuth auth #55922 removed the stale Anthropic OAuth fast-mode exclusion. This follow-up aligns explicit Anthropic service-tier behavior with that current direct-public-API path.Regression Test Plan (if applicable)
src/agents/pi-embedded-runner-extraparams.test.tsserviceTierandservice_tierparams inject into direct public Anthropic payloads, explicit tiers override fast-mode defaults, OAuth follows the same path, and proxied base URLs still skip injection.User-visible / Behavior Changes
serviceTier/service_tiermodel params.fastModeand explicitserviceTierare set, the explicit service tier wins.Diagram (if applicable)
Security Impact (required)
Yes/No) NoYes/No) NoYes/No) NoYes/No) NoYes/No) NoYes, explain risk + mitigation:Repro + Verification
Environment
agents.defaults.models["anthropic/claude-sonnet-4-5"].params.serviceTierSteps
params.serviceTier: standard_onlyorparams.service_tier: standard_only.fastMode: true, and with both direct API-key andsk-ant-oat-*OAuth auth.Expected
service_tier: "standard_only".fastMode: trueis also configured, the explicitserviceTierstill wins.service_tierinjection.Actual
fastModeshaped Anthropicservice_tier; explicit AnthropicserviceTierconfig was ignored, and the stale draft still had precedence/scope bugs after#55922.Evidence
Attach at least one:
Human Verification (required)
What you personally verified (not just CI), and how:
main, reproduced the stale precedence bug with focused Vitest filters, then added/updated payload-mutation coverage for explicit Anthropic tiers, OAuth, snake_case aliasing, and proxied-base-url skips.fastMode; proxied base URLs still skip injection.Review Conversations
Compatibility / Migration
Yes/No) YesYes/No) NoYes/No) NoRisks and Mitigations
serviceTiercould accidentally affect unsupported Anthropic-compatible proxy paths.provider === "anthropic",api === "anthropic-messages", and the direct public Anthropic base URL.maincould leave the branch red on unrelated compile drift.sourceConfigkey introduced on currentmain, reranpnpm check, and reranpnpm buildon the final tree.