feat(amazon-bedrock-mantle): add known context windows for open-weight Mantle models#68725
feat(amazon-bedrock-mantle): add known context windows for open-weight Mantle models#68725wirjo wants to merge 4 commits intoopenclaw:mainfrom
Conversation
Greptile SummaryAdds Claude Opus 4.7 support on Bedrock Mantle by enriching model discovery with a static context-window map, an image-input allowlist, and reasoning pattern entries for the new Claude generation. The tests are well-structured and cover the new code paths. Two minor P2 observations about the allowlist design are noted inline. Confidence Score: 5/5Safe to merge — all findings are P2 style suggestions with no correctness impact on current behavior. The changes are well-scoped, all current models are covered correctly, and the new test suite directly validates context windows, image input, and reasoning flags. The only issues are maintenance-oriented P2 concerns about how future Claude models will be handled. No files require special attention. Prompt To Fix All With AIThis is a comment left during a code review.
Path: extensions/amazon-bedrock-mantle/discovery.ts
Line: 51-56
Comment:
**Inconsistent matching strategy vs. stated intent**
The PR description states "all Claude models on Mantle support image input," but `resolveInputModalities` uses an explicit allowlist with `modelId.includes(p)`. Meanwhile, `REASONING_PATTERNS` uses short substrings like `"claude-opus-4-7"` that naturally cover future variants. A new Claude model added to Mantle but not to `IMAGE_INPUT_MODELS` will silently get `input: ["text"]` — contradicting the stated intent. A `modelId.includes("anthropic.claude")` pattern check would be consistent with `REASONING_PATTERNS`' approach and eliminate the need to keep two parallel lists in sync.
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-mantle/discovery.ts
Line: 39-45
Comment:
**Two parallel lists to keep in sync**
`IMAGE_INPUT_MODELS` and the keys of `KNOWN_CONTEXT_WINDOWS` are identical, which means every new Claude model on Mantle requires updating both structures. Since `resolveInputModalities` already iterates, consider deriving image support directly from `KNOWN_CONTEXT_WINDOWS` (i.e., `Object.keys(KNOWN_CONTEXT_WINDOWS).some((k) => modelId.includes(k))`) or consolidating into a single model metadata map to reduce the maintenance surface.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "feat(amazon-bedrock-mantle): add Claude ..." | Re-trigger Greptile |
| function resolveInputModalities(modelId: string): Array<"text" | "image"> { | ||
| if (IMAGE_INPUT_MODELS.some((p) => modelId.includes(p))) { | ||
| return ["text", "image"]; | ||
| } | ||
| return ["text"]; | ||
| } |
There was a problem hiding this comment.
Inconsistent matching strategy vs. stated intent
The PR description states "all Claude models on Mantle support image input," but resolveInputModalities uses an explicit allowlist with modelId.includes(p). Meanwhile, REASONING_PATTERNS uses short substrings like "claude-opus-4-7" that naturally cover future variants. A new Claude model added to Mantle but not to IMAGE_INPUT_MODELS will silently get input: ["text"] — contradicting the stated intent. A modelId.includes("anthropic.claude") pattern check would be consistent with REASONING_PATTERNS' approach and eliminate the need to keep two parallel lists in sync.
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/amazon-bedrock-mantle/discovery.ts
Line: 51-56
Comment:
**Inconsistent matching strategy vs. stated intent**
The PR description states "all Claude models on Mantle support image input," but `resolveInputModalities` uses an explicit allowlist with `modelId.includes(p)`. Meanwhile, `REASONING_PATTERNS` uses short substrings like `"claude-opus-4-7"` that naturally cover future variants. A new Claude model added to Mantle but not to `IMAGE_INPUT_MODELS` will silently get `input: ["text"]` — contradicting the stated intent. A `modelId.includes("anthropic.claude")` pattern check would be consistent with `REASONING_PATTERNS`' approach and eliminate the need to keep two parallel lists in sync.
How can I resolve this? If you propose a fix, please make it concise.| const IMAGE_INPUT_MODELS = [ | ||
| "anthropic.claude-opus-4-7", | ||
| "anthropic.claude-opus-4-6-v1", | ||
| "anthropic.claude-sonnet-4-6", | ||
| "anthropic.claude-sonnet-4-5-20250929-v1:0", | ||
| "anthropic.claude-haiku-4-5-20251001-v1:0", | ||
| ]; |
There was a problem hiding this comment.
Two parallel lists to keep in sync
IMAGE_INPUT_MODELS and the keys of KNOWN_CONTEXT_WINDOWS are identical, which means every new Claude model on Mantle requires updating both structures. Since resolveInputModalities already iterates, consider deriving image support directly from KNOWN_CONTEXT_WINDOWS (i.e., Object.keys(KNOWN_CONTEXT_WINDOWS).some((k) => modelId.includes(k))) or consolidating into a single model metadata map to reduce the maintenance surface.
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/amazon-bedrock-mantle/discovery.ts
Line: 39-45
Comment:
**Two parallel lists to keep in sync**
`IMAGE_INPUT_MODELS` and the keys of `KNOWN_CONTEXT_WINDOWS` are identical, which means every new Claude model on Mantle requires updating both structures. Since `resolveInputModalities` already iterates, consider deriving image support directly from `KNOWN_CONTEXT_WINDOWS` (i.e., `Object.keys(KNOWN_CONTEXT_WINDOWS).some((k) => modelId.includes(k))`) or consolidating into a single model metadata map to reduce the maintenance surface.
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
…t models Mantle's /v1/models endpoint returns only model IDs with no token limit metadata. All models get a hardcoded 32K context window, which is wrong for most models (MiniMax M2: 1M, Qwen Coder: 256K, etc.). Add a KNOWN_CONTEXT_WINDOWS lookup table for open-weight models currently available on Mantle and raise the default fallback from 32K to 128K for unknown models. Note: Claude models are NOT included — they use the separate /anthropic/v1/messages endpoint on Mantle, not the OpenAI-compatible /v1/chat/completions endpoint that this extension handles. Claude model metadata is managed by the amazon-bedrock extension.
ecbaa9c to
ab9b0d0
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ecbaa9c795
ℹ️ 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".
| function resolveKnownContextWindow(modelId: string): number | undefined { | ||
| return KNOWN_CONTEXT_WINDOWS[modelId]; |
There was a problem hiding this comment.
Match known Claude context windows against ID variants
resolveKnownContextWindow does an exact key lookup, so any Mantle ID variant (for example a prefixed or suffixed Claude ID such as ...-v1:0) falls through to the 128K default even when it belongs to a model family you already marked as 1M/200K elsewhere in this change. In those cases discovery returns inconsistent metadata (reasoning/image may match by substring while context does not), which can cause unnecessary prompt truncation for affected Claude IDs.
Useful? React with 👍 / 👎.
|
@vincentkoc Ready for review — no CI failures, single-extension change. Happy to address any feedback. |
Cross-referenced against known Mantle model list. Added: - qwen.qwen3-next-80b-a3b-instruct (128K) - qwen.qwen3-vl-235b-a22b-instruct (128K) - mistral.mistral-large-3-675b-instruct (128K) - mistral.devstral-2-123b (128K) Reordered entries by context window size (1M first) for readability. Models at 128K default (GPT-OSS, Kimi, Mistral small, etc.) are intentionally omitted — the 128K fallback handles them correctly.
Validated against live Mantle /v1/models endpoint (39 models). Added missing entries: - anthropic.claude-opus-4-7 (1M) — appears in /v1/models; uses /anthropic/v1/messages for inference, not Chat Completions - minimax.minimax-m2.5 (1M) - nvidia.nemotron-super-3-120b (128K) - zai.glm-5 (128K)
Consistent with openclaw#65952. 200K matches the Claude model floor — ensures new models get a sensible default without table updates.
|
Raised default from 128K → 200K, consistent with #65952. Claude is the most popular model family and 200K is the floor for all current Claude models — this future-proofs against new releases without requiring table updates. |
|
Codex review: needs changes before merge. Summary Reproducibility: yes. The Next step before merge Security Review findings
Review detailsBest possible solution: Land a rebased Mantle-local metadata update that maps known open-weight model IDs, keeps fallback behavior conservative, preserves the current Claude Anthropic Messages handling, and adds focused tests plus a changelog entry. Do we have a high-confidence way to reproduce the issue? Yes. The Is this the best way to solve the issue? No, not as written. A static known-context-window table is the right narrow shape, but this branch needs conservative fallback semantics, aligned Nemotron metadata, and release-note/test coverage 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 3980eaa1c22e. |
Problem
Mantle's
/v1/modelsendpoint returns only model IDs — no token limit metadata. Discovery hardcodescontextWindow: 32000for every model, which is wrong for most:This causes the same premature context overflow and wrong compaction thresholds as #65952 (the amazon-bedrock equivalent).
Fix
Add a
KNOWN_CONTEXT_WINDOWSlookup table for open-weight models currently available on Mantle. Raise the default fallback from 32K → 128K for unknown models.Claude models are intentionally excluded — they use a separate Anthropic-native endpoint on Mantle (
/anthropic/v1/messages), not the OpenAI-compatible/v1/chat/completionsendpoint that this extension handles. Claude model metadata is managed by theamazon-bedrockextension (#65952).Changes
extensions/amazon-bedrock-mantle/discovery.tsresolveKnownContextWindow(), default bumpSingle file, no type system changes.
References
/anthropic/v1/messageson Mantle, not Chat Completions