fix(lean): lower offloader default limit below client output cap - #184
Conversation
The offloader default (unknown_token_limit=25000 tokens, ~88KB) sat ABOVE Claude Code's client MAX_MCP_OUTPUT_TOKENS (~60KB for git output), so 60-88KB results slipped past the server offloader and were truncated by the client instead of offloaded to /tmp. Lower the default to 12000 tokens (~42KB) so the offloader spills before the client truncates. Env override (MCP_GIT_UNKNOWN_TOKEN_LIMIT) still raises it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Claude finished @MementoRC's task —— View job PR Review
Overall: Clean, well-motivated fix with good regression coverage. A few observations below.
|
| Area | Status |
|---|---|
| Core fix (25000 → 12000) | ✅ Correct and well-explained |
| Env override still works | ✅ Tested |
| New default regression tests | ✅ Solid |
CONSERVATIVE profile consistency |
|
_CHARS_PER_TOKEN_ESTIMATE usage |
|
| Profile-level test coverage | ℹ️ Optional improvement |
The CONSERVATIVE profile issue is the most substantive one since it partially undermines the goal of the PR for users who explicitly choose "conservative" behavior.
…ive test cap - CONSERVATIVE profile unknown_token_limit 18000 -> 8000 (was above the new default and the client cap, undermining the 'conservative' intent). - Derive _CLIENT_CAP_APPROX_TOKENS from _CHARS_PER_TOKEN_ESTIMATE instead of hardcoding, so they can't drift. - Add profile-coverage tests asserting CONSERVATIVE/BALANCED stay below the client cap and BALANCED==12000. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Thanks for the review — addressed in faf40b9:
The over-broad |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
Summary
Follow-up to the ResponseOffloader wiring fix (#182). Live testing showed the offloader default sat above Claude Code's client-side output cap, defeating its purpose.
Problem
GitLeanInterfacebuilds its defaultMCPTokenLimiterfromsettings.unknown_token_limit(was 25000 tokens). At the offloader's 3.5 chars/token estimate that's ~88KB. But Claude Code's clientMAX_MCP_OUTPUT_TOKENStruncates around ~60KB for git-hash-heavy text. So outputs in the ~60–88KB band slip past the server offloader (returned inline) and get truncated-to-file by the client instead of cleanly offloaded to/tmp— the opposite of what the offloader is for.Observed live: a ~60KB
git_logwas returned inline and hit the client cap, while ~88KBgit_diffoutputs offloaded correctly.Change
Lower the default
unknown_token_limit25000 → 12000 tokens (~42KB at 3.5 ch/tok), a safe margin under the client cap, so the offloader spills before the client truncates. TheMCP_GIT_UNKNOWN_TOKEN_LIMITenv override still raises it for anyone who wants the old behavior. (BALANCEDprofile updated to match; explicit high-limit profilesAGGRESSIVE/DEVELOPMENTleft as-is.)src/mcp_server_git/config/token_limits.py: default + BALANCED profile 25000 → 12000tests/unit/lean/test_offloader_token_limit.py: +5 regression tests (default is 12000, default < client cap, env override still works, new default truncates a ~50KB payload, old default did not — regression anchor)Test plan
pixi run -e quality test-unit— passes (exit 0)pixi run -e quality lint(ruff F,E9) — clean🤖 Generated with Claude Code