feat(amazon-bedrock): support service_tier parameter for Bedrock models#64512
feat(amazon-bedrock): support service_tier parameter for Bedrock models#64512obviyus merged 1 commit intoopenclaw:mainfrom
Conversation
Greptile SummaryThis PR adds
Confidence Score: 3/5Not safe to merge as-is — the extension path can inject A P1 behavioral divergence between the two implementation paths means the extension's service-tier wrapping can produce request failures when a Bedrock model uses a non-converse API. The pi-embedded-runner path is correct; the extension path is missing the same guard. This needs to be fixed before the feature is reliable across all Bedrock model configurations. extensions/amazon-bedrock/register.sync.runtime.ts — the Prompt To Fix All With AIThis is a comment left during a code review.
Path: extensions/amazon-bedrock/register.sync.runtime.ts
Line: 50-56
Comment:
**Missing `model.api` guard before injecting `serviceTier`**
The extension's service-tier wrapper calls `streamWithPayloadPatch` for every model, but the parallel implementation in `bedrock-stream-wrappers.ts` explicitly skips the patch when `model.api !== "bedrock-converse-stream"`. Without that guard, `serviceTier` is injected into the `onPayload` callback regardless of API type. If a Bedrock model routes through a non-converse API (e.g. an Anthropic-family model using a different API style), the extra field is sent to an endpoint that doesn't expect it and Bedrock will reject the request with a validation error.
`createBedrockServiceTierWrapper` in `bedrock-stream-wrappers.ts` already has this guard:
```typescript
if (model.api !== "bedrock-converse-stream") {
return underlying(model, context, options);
}
```
The same check should be added here:
```suggestion
return (model, context, options) => {
if (model.api !== "bedrock-converse-stream") {
return inner(model, context, options);
}
return streamWithPayloadPatch(inner, model, context, options, (payload) => {
if (payload.serviceTier === undefined) {
payload.serviceTier = { type: serviceTier };
}
});
};
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: extensions/amazon-bedrock/register.sync.runtime.ts
Line: 25-57
Comment:
**Duplicated logic not exposed through SDK barrel**
`BEDROCK_SERVICE_TIER_VALUES`, `resolveBedrockServiceTier`, and the service-tier patch logic are all re-implemented here but were just added (and exported) in `bedrock-stream-wrappers.ts`. The `provider-stream-shared.ts` SDK barrel already re-exports other helpers from that same file (`createBedrockNoCacheWrapper`, `isAnthropicBedrockModel`, `streamWithPayloadPatch`), but the new `createBedrockServiceTierWrapper` and `resolveBedrockServiceTier` exports were not added to the barrel.
Adding those two exports to `src/plugin-sdk/provider-stream-shared.ts` would let the extension replace its local reimplementations with:
```typescript
import {
createBedrockServiceTierWrapper,
resolveBedrockServiceTier,
} from "openclaw/plugin-sdk/provider-stream-shared";
```
…and collapse the `createServiceTierWrapStreamFn` factory down to a direct call at the `wrapStreamFn` call site.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "feat(amazon-bedrock): support service_ti..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dfef607067
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…SDK barrel - Add createBedrockServiceTierWrapper and resolveBedrockServiceTier exports to provider-stream-shared.ts barrel - Replace local reimplementations in the extension with SDK imports - Remove createServiceTierWrapStreamFn factory in favor of direct createBedrockServiceTierWrapper call at wrapStreamFn site - Addresses Greptile P2 review comment on PR openclaw#64512
Addressing Greptile Review CommentsP1 — Missing P2 — Duplicated logic not exposed through SDK barrel: Fixed in commit 53ed819.
Net result: -37 lines, +8 lines. The extension now imports shared helpers from the SDK barrel instead of duplicating them. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: adbf917d2c
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9be374ac4a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
220ba92 to
69ef7ab
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 69ef7abd95
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
9379ec2 to
2b65ad0
Compare
…SDK barrel - Add createBedrockServiceTierWrapper and resolveBedrockServiceTier exports to provider-stream-shared.ts barrel - Replace local reimplementations in the extension with SDK imports - Remove createServiceTierWrapStreamFn factory in favor of direct createBedrockServiceTierWrapper call at wrapStreamFn site - Addresses Greptile P2 review comment on PR openclaw#64512
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 126c643e1e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0bc96ebb43
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Warn operators when their service_tier config is silently ignored due to invalid casing or typos (e.g. 'Priority' or 'priority '). Normalize input by trimming whitespace and lowercasing before validation, matching the pattern used by the OpenAI service tier resolver. Fixes code review feedback on PR openclaw#64512.
|
Codex review: needs changes before merge. Summary Reproducibility: not applicable. as a bug reproduction; this is a feature PR for a new Bedrock request parameter. Current main lacks the feature, while PR source inspection and the uploaded OpenClaw/AWS screenshots provide a high-confidence verification path once the branch is rebased. Real behavior proof Next step before merge Security Review findings
Review detailsBest possible solution: Land a rebased patch that keeps Bedrock service-tier request shaping in the Bedrock provider wrapper, refreshes the Plugin SDK API baseline, and validates the Bedrock provider tests plus SDK API check. Do we have a high-confidence way to reproduce the issue? Not applicable as a bug reproduction; this is a feature PR for a new Bedrock request parameter. Current main lacks the feature, while PR source inspection and the uploaded OpenClaw/AWS screenshots provide a high-confidence verification path once the branch is rebased. Is this the best way to solve the issue? No, not mergeable as-is. The wrapper approach is narrow and matches the AWS Converse request shape, but the public SDK baseline and dirty branch must be fixed before merge. Full review comments:
Overall correctness: patch is incorrect Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 9e58cc82c8d3. |
|
Unit tests for expected behavior added based on previous Codex comments. |
374f51f to
98b6ea9
Compare
Real behavior proof (required for external PRs)
|
fef2ca4 to
b87ee32
Compare
b87ee32 to
c65da92
Compare
- Add resolveBedrockServiceTier() and createBedrockServiceTierWrapper() to bedrock-stream-wrappers.ts - Export service tier functions from provider-stream-shared.ts SDK barrel - Wire service tier into Bedrock provider wrapStreamFn - Accepts serviceTier or service_tier via agents.defaults.params Valid values: default, flex, priority, reserved Authored by Deepseek-v4-Pro, reviewed by rob@mobilinkd.com.
c65da92 to
84828a5
Compare
|
Landed via rebase onto main.
Thanks @mobilinkd! |


Closes #63415
Real behavior proof (required for external PRs)
service_tierparameter toamazon-bedrockmodels.~/.aws/credentials, Node.js v22.22.0.agents.defaults.params.serviceTier="flex".amazon-bedrock/moonshotai.kimi-k2.5.flex; Bedrock returned the documented unsupported-tier behavior.serviceTier="default"and confirmed the override path worked.amazon-bedrock/moonshotai.kimi-k2.5model invocation withServiceTier=flex.ServiceTier=flex.ServiceTier=flex, and the per-modelserviceTier="default"override changed the served tier for that model.Model invocation via subagent on OpenClaw.

serviceTier=flexpassed to Amazon Bedrock model invocation.