`modelCapabilities.limits.maxContextWindowTokens` is ignored by the runtime; only the undocumented `provider.maxContextWindowTokens` works
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 65/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- python
- Lĩnh vực
- api, backend, developer-experience
Hướng nghiên cứu
The issue is in the Python SDK's serialization and runtime handling of model capabilities. Start by examining the CopilotClient class, specifically the create_session method and the _convert_provider_to_wire_format function. Look at the ModelCapabilitiesOverride and ModelLimitsOverride classes in the SDK, and compare their field names to the runtime's api.schema.json. The test file tests/copilot_sdk/test_max_context_window.py shows the workaround and can be used to verify a fix. The goal is to ensure the max_context_window_tokens parameter is correctly serialized and honored by the runtime, or to expose the working provider.maxContextWindowTokens field.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
create_session(model_capabilities=ModelCapabilitiesOverride(limits=ModelLimitsOverride(max_context_window_tokens=...))) is documented as "Override individual model capabilities resolved by the runtime", but it has no effect on the session's context-window management: session.history.compact keeps reporting contextWindow.tokenLimit = 128000 (the BYOK fallback default), so auto-compaction triggers far too early for long-context BYOK models.
Two additional problems compound this:
- The Python SDK serializes
ModelLimitsOverrideto camelCase (maxContextWindowTokens), while the runtime's ownapi.schema.jsondeclaresModelCapabilitiesOverrideLimitsproperties in snake_case (max_context_window_tokens) — so even if the runtime honored the override, the wire names would not match. Sending snake_case manually (by monkey-patching_capabilities_to_dict) changes nothing, so the parameter appears to be entirely non-functional. - The only working path — the BYOK
ProviderConfigtop-levelmaxContextWindowTokens— is not exposed by the Python SDK:ProviderConfig(TypedDict) lacks the field and_convert_provider_to_wire_formatdrops it from the dict.
Environment
github-copilot-sdk(Python): 1.0.14 (latest on PyPI at the time)- Runtime bundle: CLI 1.0.85
- OS: Linux x64
Evidence (all variants, same BYOK model deepseek-flash)
| Configuration path | history.compact → contextWindow.tokenLimit |
|---|---|
| (none — baseline) | 128000 |
model_capabilities limits maxContextWindowTokens (SDK default, camelCase wire) |
128000 ❌ |
model_capabilities limits max_context_window_tokens (snake_case wire via monkey-patch) |
128000 ❌ |
provider.modelCapabilities.limits.max_context_window_tokens (wire injected via monkey-patch) |
128000 ❌ |
provider.maxContextWindowTokens (wire injected via monkey-patch) |
1048576 ✅ |
Expected behavior
session.open'smodelCapabilities.limits.maxContextWindowTokensshould override the resolved context window used for compaction/truncation/token display (and the Python SDK's wire casing should match what the runtime deserializes); or- the Python SDK should expose
provider.max_context_window_tokens(ProviderConfigfield + wire conversion), since that is the only knob the runtime honors today.
Workaround
Monkey-patch CopilotClient._convert_provider_to_wire_format to pass maxContextWindowTokens through on the provider object. Verified working (tokenLimit = 1048576). Repro script: tests/copilot_sdk/test_max_context_window.py.
- Ngôn ngữ chính
- Java
- Star
- 10.5k
- Fork
- 1.5k
- Merge trung bình
- 1 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 117
Chuẩn bị môi trường
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của github/copilot-sdk
-
agentic-workflows
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
github/copilot-sdk#2779 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agentic-workflows
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
github/copilot-sdk#2760 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
github/copilot-sdk#2759 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
github/copilot-sdk#2758 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agentic-workflows
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
github/copilot-sdk#2709 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của github/copilot-sdk
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
openhab/openhab-core#5847 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
apache/parquet-java#3820 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
beehive-lab/jllm#187 ·