mirror of
https://github.com/hanzoai/stack.git
synced 2026-11-19 03:06:57 +00:00
1.5 KiB
1.5 KiB
Token Limit Fix Summary
Problem
MCP tools were returning responses exceeding the 25,000 token limit, causing errors when tools like directory_tree were used on large directories.
Solution
Added proper token limiting to all tools that can return large responses using the truncate_response function with a 25,000 token limit.
Tools Fixed
Filesystem Tools
- directory_tree.py - Now truncates large directory listings
- read.py - Truncates large file contents
- grep.py - Truncates extensive search results
- find.py - Added truncation import (implementation pending)
Shell Tools
- base_process.py - Truncates command output to prevent large responses
Additional Fixes
- Fixed test import errors reducing collection errors from 45 to 7
- Fixed
ClientSession→ClientSessionGroupimport - Fixed async function syntax errors
- Installed hanzo-memory dependency
- Updated outdated test imports
Token Truncation Details
- Max tokens: 25,000
- Uses tiktoken for accurate token counting
- Adds helpful truncation messages directing users to:
- Use pagination
- Narrow search scope
- Use offset/limit parameters
Test Status
- 338 tests collected (up from 49)
- 7 collection errors remaining (down from 45)
- 179 tests passing
Usage Notes
All tools now safely handle large outputs without exceeding MCP token limits. Users will see clear messages when output is truncated with guidance on how to get more specific results.