Architecture of microsoft/tokeneconomizer
microsoft/tokeneconomizer is 237 source files holding 3,815 symbols across 6 modules, written mainly in Python, Shell, TypeScript. The largest module is experiments, with 68 files, and 2 files are entry points into the dependency graph.
How tokeneconomizer fits together
The entry points are tokeneconomizer/__init__.py and tokeneconomizer/plugin/cli.py. The tokeneconomizer package switches on the token-saving stages for an agent run and decides when an agent is stuck repeating a failing fix. The plugin folder holds the host integrations, and plugin/opencode/tokeneconomizer.ts is the TypeScript plugin for opencode. The scripts directory packages the plugin into folders that Claude Code and Factory Droid can install. The experiments directory runs the benchmark sweeps that measure how much the token-saving stages save on coding tasks.
Largest modules
- experiments: 68 files and 14,705 lines of code
- tokeneconomizer: 61 files and 14,767 lines of code
- tests: 48 files and 11,618 lines of code
- plugin: 4 files and 1,013 lines of code
- docs: 3 files and 1,100 lines of code
- scripts: 2 files and 530 lines of code
Languages
By file count: Python 178 files, Shell 5 files, TypeScript 2 files, JavaScript 1 file.
Documentation
Repowise documents tokeneconomizer in 236 pages generated from the source, 14 of them written explanations of the repository and its modules. Module guides include:
- tokeneconomizer/trace: Agent Trace Capture
- experiments/te_bench: Benchmark Arm Specification
- experiments/te_bench/baselines: Benchmark Dataset Adapters
- tokeneconomizer: Envelope Core and Loop Guard
- experiments: Experiments
More on tokeneconomizer: summary and FAQ, codebase overview, code health.
Related guide: Best dependency graph tools for monorepos