What happened?
Before the first model reply (or after a /model switch or resume, when /context has no provider token count), the estimated breakdown can add up to more than the context window. With tools.codeModeOnly and an MCP server whose tools are always loaded, the MCP schemas are billed in the MCP tools row even though they are not in the declared tool list, so the rows, free space and autocompact buffer overshoot the window by the size of those schemas.
Reproduced with the fixture from the existing charges the builtin-clamp deficit to the mcp row, not to messages test, using the estimated path (total: 0):
window=200000 accounted=200128
What did you expect to happen?
The estimated breakdown should account for exactly the window, the same as the provider-count path. That path already charges the deficit to the MCP row (the existing test above); the estimated path skips it.
Client information
Built from main at c5b0e1f (0.24.7), Linux. Not platform specific.
Login information
N/A, no model call is needed to reproduce.
Anything else we need to know?
The overshoot equals the MCP schema tokens that are not in the declared tools, so it can be thousands of tokens with a large MCP server. The fix is to apply the existing clamp in both branches of the breakdown. I'd like to send a small fix with a test.
What happened?
Before the first model reply (or after a
/modelswitch or resume, when/contexthas no provider token count), the estimated breakdown can add up to more than the context window. Withtools.codeModeOnlyand an MCP server whose tools are always loaded, the MCP schemas are billed in the MCP tools row even though they are not in the declared tool list, so the rows, free space and autocompact buffer overshoot the window by the size of those schemas.Reproduced with the fixture from the existing
charges the builtin-clamp deficit to the mcp row, not to messagestest, using the estimated path (total: 0):What did you expect to happen?
The estimated breakdown should account for exactly the window, the same as the provider-count path. That path already charges the deficit to the MCP row (the existing test above); the estimated path skips it.
Client information
Built from main at c5b0e1f (0.24.7), Linux. Not platform specific.
Login information
N/A, no model call is needed to reproduce.
Anything else we need to know?
The overshoot equals the MCP schema tokens that are not in the declared tools, so it can be thousands of tokens with a large MCP server. The fix is to apply the existing clamp in both branches of the breakdown. I'd like to send a small fix with a test.