Skip to content

fix(mlx): read engine context_length; Write joins the core tool tier - #381

Merged
dahai80 merged 1 commit into
mainfrom
fix/mlx-context-window-and-core-write
Nov 27, 2026
Merged

dahai80 merged 1 commit into
mainfrom
fix/mlx-context-window-and-core-write

Conversation

@dahai80

@dahai80 dahai80 commented Nov 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • The adapter read only max_input_tokens from /v1/models, but the engine reports the native window as context_length (262144 for Qwen3.8-27B-4bit-mtp). Every model fell back to the 32768 heuristic and ran with 1/8 of its real context window — driving constant compaction, core-tier tool reduction, and 600s-cap bench failures.
  • MLX_CORE_TOOL_NAMES (the over-budget reduction tier) had Edit but no Write: agents could modify files but never create them. Bench T13 died exactly this way (Edit imported exceptions.py, the Write creating it was rejected, pytest collection failed). Write's schema is small; the capability loss was not.
  • Fixes: read context_length as fallback; Write joins the core tier; both regression-tested.

Evidence

  • Engine: "context_length": 262144 for Qwen3.8-27B-4bit-mtp
  • Bench T13 log: [MLX-Preflight] tool tier=core (contextWindow=32768), toolSet size=5 → No such tool available: Write
  • Transcript replay of the agent's solution: 2/2 tests pass locally

Test plan

  • bun test: 1885 pass / 0 fail (2 new tier-content tests)
  • bun run build: green

🤖 Generated with Claude Code

Two related defects found by bench forensics (T13: agent's correct
solution died because the reduced toolset rejected Write):

1. The adapter only read max_input_tokens from /v1/models, but the
   engine reports the native window as context_length (262144 for
   Qwen3.8-27B-4bit-mtp). Every model therefore fell back to the
   32768 heuristic and ran with 1/8 of its real window - constant
   compaction, core-tier tool reduction, and 600s-cap failures.
   Fix: read context_length as a fallback.

2. MLX_CORE_TOOL_NAMES (the <=32k reduction tier) had Edit but not
   Write: agents could modify existing files but never create them.
   Bench T13 failed pytest collection because its Edit already
   imported exceptions.py while the Write creating it was rejected.
   Fix: Write joins the core tier (schema is small; the capability
   loss was not).

Co-Authored-By: Claude Code <[email protected]>
@dahai80
dahai80 merged commit fc23d60 into main Nov 27, 2026
1 check passed
@dahai80
dahai80 deleted the fix/mlx-context-window-and-core-write branch November 27, 2026 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant