convez.ai
MCP ServerAutomaçãoAvançado
Moh97746

Token Optimization Mastery

Moh97746/Token-Optimization-Mastery

Otimização radical de tokens: 99% economia com graph tracing e caps de 800 tokens

Ver no GitHub
InicialPluginScore · de 0 a 100

MCP Server avançado para otimização extrema de uso de tokens em LLMs, reduzindo custos e latência através de gerenciamento inteligente de contexto. Implementa protocolos de graph navigation, output caps matemáticos e memory paging para eliminar context inflation em grandes bases de código.

Instalação

$npx convez-ai Moh97746/Token-Optimization-Mastery

1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.

Métricas

Estrelas
7
Forks
0
Acompanhando
0
Saúde
14%
Último commit
há 6 meses
Versão
—
Issues abertas
0
Contribuidores
1

Casos de uso

  • Reduzir custos de API em análise de grandes codebases
  • Eliminar context inflation em sessões longas com LLMs
  • Rastreamento de dependências e impact radius antes de edições
  • Auto-logging de decisões arquiteturais em corpus vetorial

Veredito

Ferramenta altamente especializada para engenheiros que trabalham com codebases massivas e precisam controlar custos de LLM em produção. A abordagem de graph navigation e output caps é sólida, mas requer expertise técnica significativa e integração customizada.

README

A tradução para o português deste README ainda está na fila.

Advanced Protocol for Extreme AI Efficiency, Context Management, & Cost Reduction

AI Agentic Skill Cost Optimized Performance License

"Stop dumping entire files into the context window. Start indexing, tracing call-graphs, and enforcing output caps."

🎯 The Core Problem

Context Inflation & Bandwidth Exhaustion: As Large Language Models (LLMs) handle massive codebases, they suffer from "Instruction Dilution" (forgetting primary constraints due to an overloaded context window). This results in extreme API costs, massive latency, and severe bandwidth exhaustion. V3.1 introduces mathematical output limits to fully eliminate AI verbosity.


✨ Features of the New Version (V3.1)

V3.1 integrates Graph Navigation Protocols (inspired by advanced code-review graphs) into the existing TOON/Kortex architectures:

  1. Strict 800-Token / 5-Call Cap: AI is strictly constrained to complete any task in ≤5 tool calls and ≤800 total output tokens.
  2. Minimal Detail Level: AI must operate at detail_level="minimal" and only escalate when strictly necessary.
  3. Graph Impact Radius: AI must trace callers_of and callees_of to measure "Impact Radius" before editing code, preventing the need to read entire files.
  4. Auto-Memory Logging: Task completions and architectural decisions (ADRs) are silently logged to the Claude-Mem corpus.

🏗 The 5-Layer Architecture

Layer 1: Strict Communication Rules

  • Extreme conciseness (Bandwidth Conservation Mode).
  • Fresh AI sessions per major task to prevent context drift.
  • V3.1 Rule: Strict output cap of ≤800 tokens per task.

Layer 2: TOON & Graph Trace Strategy

  • Run smart_outline or smart_search to map dependencies.
  • Trace Call Graphs (Callers/Callees) to measure Impact Radius safely.
  • Use smart_unfold to expand only the targeted symbol.

Layer 3: Kortex Semantic-Map / Claude-Mem Paging

  • Search: Retrieve semantic index IDs only (~100 tokens).
  • Timeline: Get surrounding conversational context (~300 tokens).
  • Fetch (JIT): Retrieve detailed records for a maximum of 3-5 filtered IDs (~1,500 tokens).

Layer 4: Corpus Workflow & Auto-Logging

  • Use build_corpus and prime_corpus to query vectors instead of polluting active chat memory.
  • Silently log all task completions and Architecture Decision Records (ADRs) back into the corpus for future zero-cost recall.

Layer 5: Scoped Grep (Find Before Read)

  • Never read a file to find a pattern. Use grep_search with specific extension filters (Includes=["*.py"]) and line-number targeting.

🚀 Official V3.1 Empirical Benchmarks

Test Date: April 30, 2026 | Simulated Task: Deep Module Extraction & Refactor

OperationTraditional AI MethodV3.1 Optimized ProtocolEfficiency Gain
📂 Code Navigationview_file (Read 800 lines) ~2,800 tokenssmart_outline + callers_of trace ~155 tokens~94.4% 📉
✍️ Code EditingFull file overwrite generation ~3,000 output tokensmulti_replace_file_content (Surgical) ~50 output tokens~98.3% 📉
🧠 Memory RetrievalLoad massive workspace into chat ~30,000 tokensClaude-Mem JIT Decompression ~850 tokens~97.1% 📉
🗣️ AI Response VerbosityRambling explanation + code block ~2,500 output tokensV3.1 Strict Limit (≤ 5 tools) Completed in 420 tokens~83.2% 📉

Conclusion: The V3.1 architecture successfully reduces overall task token consumption by >96%, achieving near-instantaneous latency and zero context drift.


📚 Documentation


🙏 Acknowledgments & Continuous Evolution

This token optimization methodology is a living architecture. The integration of TOON Code-Maps, Kortex JIT Decompression, and Graph Navigation (Impact Radius) was heavily inspired by brilliant community advice and developer feedback.

Special Thanks: I deeply appreciate the advice and suggestions that led to this massive V3.1 update. I continuously listen to feedback, adopt advanced architectures, and actively update this repository to ensure the highest possible AI efficiency.

👨‍💻 Author & Contact

Izzeldeen Mohammed
AI Researcher & Developer

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.

Ver o original no GitHub

Bom para

Relacionados