Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

`modelCapabilities.limits.maxContextWindowTokens` is ignored by the runtime; only the undocumented `provider.maxContextWindowTokens` works

Open
#2,756 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
65/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python

Research direction

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.

Written by the indexing model from the issue text.

Description

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:

  1. The Python SDK serializes ModelLimitsOverride to camelCase (maxContextWindowTokens), while the runtime's own api.schema.json declares ModelCapabilitiesOverrideLimits properties 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.
  2. The only working path — the BYOK ProviderConfig top-level maxContextWindowTokens — is not exposed by the Python SDK: ProviderConfig (TypedDict) lacks the field and _convert_provider_to_wire_format drops 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's modelCapabilities.limits.maxContextWindowTokens should 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 (ProviderConfig field + 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.

Dominant language
Java
Stars
10.5k
Forks
1.5k
Avg merge
1d 9h
Merged PRs (30d)
130

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from github/copilot-sdk

All issues in github/copilot-sdk

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.