microsoft / microsoft/vscode

Agent Host loses BYOK Custom Endpoint context limits: context usage hidden and 1M model compacted at 128K

Open
#336,797 1 comment 0 reactions 1 assignee Assigned to @vritant24 View on GitHub
agent-host new release
Dominant language
TypeScript
Stars
193k
Forks
42.4k
PR merge metrics
PR metrics pending

Description

Type: Bug

I configured a BYOK / Custom Endpoint model in VS Code with vendor: customendpoint, apiType: chat-completions, maxInputTokens: 936000, and maxOutputTokens: 64000, for an effective 1,000,000-token context window.

Steps:

1.Add a Custom Endpoint model to chatLanguageModels.json with a context window much larger than 128K. Example values:
maxInputTokens: 936000
maxOutputTokens: 64000
streaming: false
2. Reload VS Code.
3. Start a new Copilot Agent session and select that BYOK / Custom Endpoint model.
4. Continue using the session until the conversation exceeds about 100K tokens.
5. Observe that the context-usage bar/ring is not shown.
6. Inspect the Agent Host session/debug data. In my case, the configured model is correctly known by the normal VS Code model registry as 936000 input + 64000 output, but the corresponding Agent Host model entry has maxInputTokens = 0 and maxOutputTokens = 0.
7. The Agent Host then falls back to a 128000-token budget instead of using the configured 1,000,000-token window.
8. In the Agent Host debug event stream, automatic compaction occurred at approximately:
currentTokens: 102516, tokenLimit: 128000
currentTokens: 103321, tokenLimit: 128000
9. The compaction trigger was "threshold", which is consistent with a threshold of about 102400 tokens, i.e. 80% of 128000.

Expected result:

The Agent Host should receive and use the model's configured context limits.
The context-usage indicator should be visible and use the configured 1,000,000-token window.
Automatic compaction should be based on the configured model context rather than a generic 128K fallback.

Actual result:

The Agent Host model metadata loses the configured limits and becomes 0 / 0.
The context-usage indicator is hidden.
The Agent Host budgets the session at 128000 tokens.
Automatic compaction occurs around 102400 tokens even though the configured model context is 1,000,000 tokens.
Compaction happened silently; I did not see a visible compaction notification.

Additional observation:

Token usage itself is present and nonzero, so this does not appear to be a missing usage-response problem.
The same 128K behavior was observed across BYOK models configured with several different context sizes, including 144K, 171K, and 1M.
I also saw no context bar during a local/inline A/B test with the same BYOK model.

Environment:

VS Code 1.138.0
Commit: 7debcd0e2acdea1c52de81bf9ee1620444407dda
Windows 11 x64
GitHub Copilot Chat bundled version 0.66.0
BYOK / Custom Endpoint
OpenAI-compatible chat-completions API
chat.contextUsage.enabled = true

No API keys or private repository contents are required to reproduce the issue.

VS Code version: Code 1.138.0 (7debcd0e2acdea1c52de81bf9ee1620444407dda, 2026-09-15T07:24:32Z)
OS version: Windows_NT x64 10.0.26200
Modes:

System Info

|Item|Value|
|---|---|
|CPUs|AMD Ryzen 9 5900X 12-Core Processor (24 x 3700)|
|GPU Status|2d_canvas: enabled
GPU0: VENDOR= 0x10de, DEVICE=0x2204 [NVIDIA GeForce RTX 3090], DRIVER_VENDOR=NVIDIA, DRIVER_VERSION=32.0.15.9186 *ACTIVE*
GPU1: VENDOR= 0x10de, DEVICE=0x2204 [NVIDIA GeForce RTX 3090], DRIVER_VERSION=32.0.15.9186
GPU2: VENDOR= 0x1414, DEVICE=0x008c [Microsoft Basic Render Driver], DRIVER_VERSION=10.0.26100.9278
Machine model name:
Machine model version:
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
trees_in_viz: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgpu: enabled
webnn: disabled_off|
|Load (avg)|undefined|
|Memory (System)|127.91GB (112.92GB free)|
|Process Argv|--crash-reporter-id 2cae5ca7-6a84-478b-a86f-2c9f797d4dbb|
|Screen Reader|no|
|VM|0%|
Extensions (12)

Name|Identifier|Author|Version
---|---|---|---
Container Tools|ms-azuretools.vscode-containers|ms-azuretools|2.5.1
Docker|ms-azuretools.vscode-docker|ms-azuretools|2.0.0
Black Formatter|ms-python.black-formatter|ms-python|2026.6.0
Python Debugger|ms-python.debugpy|ms-python|2026.6.0
Python|ms-python.python|ms-python|2026.4.0
Pylance|ms-python.vscode-pylance|ms-python|2026.3.1
Python Environments|ms-python.vscode-python-envs|ms-python|1.36.0
WSL|ms-vscode-remote.remote-wsl|ms-vscode-remote|0.104.3
PowerShell|ms-vscode.powershell|ms-vscode|2025.4.0
Cline|saoudrizwan.claude-dev|saoudrizwan|4.1.17
AI Insights - Token Tracker|thewalking-dev.ai-insights|thewalking-dev|0.1.16
vscode-pdf|tomoki1207.pdf|tomoki1207|1.2.2

A/B Experiments

```
vsliv368:30146709
binariesv615:30325510
nativeloc1:31344060
dwcopilot:31170013
dwoutputs:31242946
copilot_t_ci:31333650
e5gg6876:31282496
pythonrdcb7:31342333
6518g693:31463988
aj953862:31281341
4f60g487:31327383
envsactivate1:31551504
cloudbuttont:31379625
3efgi100_wstrepl:31403338
55ia6109:31457054
ec5jj548:31422691
cp_cls_t_966_ss:31526232
4je02754:31466945
c3h7c220:31478652
cp_cls_c_1081:31454833
conptydll_true:31498968
e9c30283:31461165
46204921:31447328
capico_axe_098a3278:31582664
ei9d7968:31496641
chat:31457767
8hig5102:31480529
ah:31461780
89g7j272:31518289
i2gc6536:31499202
52612955:31516516
ddid_c:31478207
hmra_i5g22:31518061
7df3h592:31512476
cp_cls_t_1082:31535311
logging_enabled_new:31498466
j0d79568:31499440
jb_cp_cls_t_632:31543129
748c7209:31512887
32d76977:31512328
ha629193:31508444
jh5f2457_c:31540921
jbcp_cls_pctr_t:31531130
cp_intellij_t_nes:31548657
gf14b233:31526830
ahp-both-windows:31556933
hjji5903:31534458
7g2b5551:31542111
nes-ex-cf-euporie-03:31542868
enable_editor_pane_layout:31569726
allow-none:31555437
ac562147:31564510
c7c27ce7:31554789
1h923230:31564177
treatment-23-1:31555779
unuse_dynamic_mcp:31555281
0d8dfbc3:31570291
0c1h4866:31566224
session-archive:31558132
5b8j3302:31564601
autotiers:31584978
mangle-name-treatment:31572634
signed-out-control:31584138
intellij_nes_preview_t:31580086
39a5d156:31574986
2bfb8b39:31585911
accent:31581110
links-control:31586637
aw-autom-on:31583758
revealsession_treatment_7ed7e840:31582194
7g328426_fixed:31584544
codex-agent-host-stable-control:31585316
0485115c-2712-4002-b6e9-b5d4e30fb963:31586114
permission_prompt_control:1332567
ccr_pr_nudge_adoption:1319471
vsc_wsm_c:1340633
h5e14506_copy:1348995
1g5a5742:1379227
3aced641:1389836

```

Contributor guide

Open the contributing guide

Research direction

Start with the BYOK model entry in chatLanguageModels.json and trace how its limits reach the Agent Host model metadata. Reproduce with the supplied maxInputTokens and maxOutputTokens values, then inspect the Agent Host debug event stream and context-usage setting. Done means the configured limits are retained, the context indicator appears, and compaction uses the configured window rather than 128K.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vscode
Domain
ai-infra-agents, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.