dsh-memory-router: A Token compression plugin attached to the DSH tool call boundary
Maintained by dcd887, dsh-memory-router is a Token compression plugin positioned at the boundary of DSH tool calls. It addresses two types of waste: the model's repeated reading of the same file or command following duplicate invocations, and scenarios where only a few fields from a long tool output are needed. The plugin consists of four modules: dedupe performs TTL cache reuse based on identical tools and parameters to prevent tool execution; edg utilizes a declarative decision graph to match tools and parameters, executing read-only local actions to replace the original output when guards are true; liveState automatically persists "what is being processed and which files have been modified" and injects this into the first round of new sessions; and inject controls injection via content hashing, length limits, and rate limiting. The fixed processing pipeline follows the order of de-duplication, decision graph, threshold compression, and caching the final text; if any step fails, it falls back. Installation involves git cloning and creating a local symlink in the profile's node_modules, requiring a restart to take effect. It requires Node >= 18, is MIT-licensed, and is currently in the alpha state. The README provides comparative data from real production sessions: reading large tax tables saved 1,433 tokens, and reading blind push records saved 1,582 tokens; across ten A/B test cases, it hit 6/10, achieving an average saving of 96% when triggered. The plugin includes built-in accounting metrics, recording savings, spending, and losses into the trim, dedupe, edg, reread, and inject categories respectively. It is worth noting that the author explicitly states that the cumulative net profit is currently negative (net -10,517), due to the accumulated cost of injection overhead and the amplification of the verification method, and that the plugin saves context volume rather than model turns. One should read the source code before installation, as the plugin operates with the privileges of the current DSH process.
Read More