feat: add context window limit lookup table#2249
feat: add context window limit lookup table#2249opieter-aws merged 1 commit intostrands-agents:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Assessment: Comment The design is sound — lazy resolution in Review Categories
Good feature that directly reduces friction for the most common use case. |
0557068 to
46091e3
Compare
46091e3 to
6def016
Compare
|
Assessment: Comment (trending toward Approve) The update addressed the key concerns from the previous review: type safety via Remaining Items
None of these are blocking. The core design is solid and well-tested. |
6def016 to
1ccc5a4
Compare
|
Assessment: Approve All substantive feedback from previous rounds has been addressed. The code is clean, well-tested (100% coverage on modified lines), and the design decisions are well-documented in the module docstring. Resolved Items
Non-blocking Suggestions (still open)
Well-designed feature that removes real user friction. Ship it! 🚀 |
1ccc5a4 to
abbd94b
Compare
|
Assessment: Approve All feedback from previous review rounds has been addressed. This iteration brings a clean The code is well-structured, well-tested, well-documented, and follows the project's coding standards. No remaining blocking concerns. |
Description
context_window_limitis required for proactive context compression (#555, #1295), but users currently have to manually look up and hard-code context window sizes for every model they instantiate. This is error-prone and creates friction for the most common models across all providers.context_window_limitis now auto-populated from a built-in lookup table when not explicitly provided in the model config. Explicit values always take precedence. Unknown model IDs leave itNone.A new
_defaults.pymodule maps model IDs to their known context window limits. Each provider'sget_config()lazily resolves the limit viaresolve_config_metadata(). The stored config is nevermutated, so changing model_id via
update_config()naturally re-resolves on the nextget_config()call.For Bedrock cross-region model IDs (e.g. us.anthropic.claude-sonnet-4-6), the region prefix is stripped before lookup.
Values sourced from https://github.com/BerriAI/litellm/blob/litellm_internal_staging/model_prices_and_context_window.json
Related Issues
Port of strands-agents/sdk-typescript#954.
Resolves: #1295
Documentation PR
Part of proactive compression doc updates
Type of Change
New feature
Testing
How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli
hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.