Skip to content

Add Token Optimizer#145

Open
alexgreensh wants to merge 1 commit into
hashgraph-online:mainfrom
alexgreensh:add-token-optimizer
Open

Add Token Optimizer#145
alexgreensh wants to merge 1 commit into
hashgraph-online:mainfrom
alexgreensh:add-token-optimizer

Conversation

@alexgreensh
Copy link
Copy Markdown

Token Optimizer

Context windows degrade silently. By the time you notice your AI is "getting dumber," you've already lost quality you can't get back. Most token tools compress command output and call it a day. That covers maybe 15-25% of the problem.

The three types of context waste

1. Behavioral waste -- What you do in your sessions. Re-reading files already in context. Retry loops where the same approach fails three times. Not compacting until it's too late. Asking the agent to explore broadly when the window is already at 70%.

2. Structural waste -- What eats your context before you type a word. Bloated AGENTS.md or CLAUDE.md files. Skills you installed once and never use but that load every session. Dead MCP servers sitting in config. Stale memory entries past line 200 that the model can't even see.

3. Runtime waste -- What accumulates during the session. Tool results returning 50KB when you needed 2 lines. Duplicate system reminders injected on every turn. Verbose bash output flooding the window. File reads repeated after the file was already edited.

Most tools touch one of these. Usually runtime (output compression). Token Optimizer covers all three. And nobody else measures the quality of your context as it degrades.

What it actually does

It doesn't just observe. It actively optimizes:

  • Smart Compaction captures a checkpoint of your decisions, active files, and session mode before compaction fires, then injects mode-aware PRESERVE/DROP guidance so the compactor keeps what matters
  • Session Continuity restores context from prior sessions when you start a new one on the same topic
  • Loop Detection catches retry patterns before they burn through your window
  • Quality Nudges warn when context health drops, fill exceeds thresholds, or tool call fatigue sets in
  • 7-Signal Quality Engine with dual ResourceHealth (monotonic) + SessionEfficiency (rolling window) scoring, calibrated per model family via MRCR curves
  • Token Coach mode teaches you how to work smarter with your context window
  • Dashboard tracks every session: quality trends, tool calls, compaction depth, all auto-updated

Platform support

Native plugins for Claude Code (Python), Codex (Python), OpenCode (TypeScript), and OpenClaw (TypeScript). Each platform has its own native implementation, no bridging, no shared runtime.

Stats

  • 1,050+ GitHub stars
  • Zero runtime dependencies, zero telemetry
  • MRCR curves for 30+ models (Anthropic, OpenAI, Google, DeepSeek, Qwen, Mistral, xAI)
  • Fully local, every measurement is a SQLite write to a file you own

PR Checklist

  • README.md entry is alphabetically sorted within its category
  • Plugin bundle exists under plugins/alexgreensh/token-optimizer/
  • .codex-plugin/plugin.json exists and is valid JSON
  • composerIcon field is set in plugin.json interface section
  • Icon file exists at the path referenced by composerIcon
  • All links in the README entry are valid
  • No placeholder or TODO values in plugin.json

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the Token Optimizer plugin by adding it to the README and creating a manifest file. However, the reviewer identified that the plugin bundle is incomplete, missing functional components and the required skills configuration. Additionally, the manifest requires corrections for the category and icon path, the README entry needs to be alphabetically sorted, and the plugins.json file must be updated to include the new entry.

@@ -0,0 +1,14 @@
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The plugin bundle appears to be incomplete. This repository mirrors installable bundles under the plugins/ directory (see README lines 56 and 93), but the actual functional components (such as the skills/ directory and associated scripts mentioned in the PR description) are missing from this pull request. Furthermore, the manifest is missing the required skills configuration field mentioned in the plugin development guide (README line 233).

Comment on lines +11 to +12
"category": "Developer Tools",
"composerIcon": "./assets/icon.png"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The category should be aligned with the repository's existing taxonomy ('Development & Workflow'). Additionally, the composerIcon path is likely incorrect; since the manifest is located in the .codex-plugin/ subdirectory, the path should be ../assets/icon.png to reach an assets folder at the plugin root. Please also ensure the icon file itself is included in the PR.

Suggested change
"category": "Developer Tools",
"composerIcon": "./assets/icon.png"
"category": "Development & Workflow",
"composerIcon": "../assets/icon.png"

Comment thread README.md
- [Tandem Workflow Architect](https://github.com/frumu-ai/tandem-codex-plugin) - Plan Tandem workflows in Codex, then validate, preview, and run them through the governed Tandem engine.
- [Tartiner Labs](https://github.com/tartinerlabs/skills) - Agent skills for git workflows, GitHub automation, security audits, code refactoring, and project tooling.
- [Team Skills Platform](https://github.com/Colin4k1024/tsp) - Role-based team delivery framework — Tech Lead-orchestrated 8-role system with 195+ skills, 27 specialist agents, 80+ commands, hooks, and ECC harness for Claude Code, Codex, and OpenCode.
- [Token Optimizer](https://github.com/alexgreensh/token-optimizer) - Detect and fix all three types of context waste (behavioral, structural, runtime), track quality degradation with a 7-signal scoring engine, and actively optimize sessions with smart compaction, loop detection, and continuity recovery across Claude Code, Codex, OpenCode, and OpenClaw.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The 'Token Optimizer' entry is not alphabetically sorted. Based on the existing list (Team, Test, TODO, Tool), it should be placed after 'TODO Harvest'. Additionally, please ensure that plugins.json is updated to include this new entry and that the total count is incremented (to 83), as that file is used for automation.

Context quality scoring, smart compaction, session continuity, and
active optimization across Claude Code, Codex, OpenCode, and OpenClaw.
@alexgreensh alexgreensh force-pushed the add-token-optimizer branch from a860e95 to 519c406 Compare May 21, 2026 14:09
@kilo-code-bot
Copy link
Copy Markdown

kilo-code-bot Bot commented May 21, 2026

Code Review Summary

Status: 3 Issues (from previous review, unresolved) | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 0
Existing Issues (unresolved from prior review — do not duplicate)

The following issues were raised in Review #4337644533 and remain unresolved in the current state of this PR:

File Line Severity Issue
plugins/alexgreensh/token-optimizer/.codex-plugin/plugin.json 1 HIGH Plugin bundle incomplete: skills/ directory and associated scripts referenced in the PR description are not present in this PR.
plugins/alexgreensh/token-optimizer/.codex-plugin/plugin.json 12 HIGH category is "Developer Tools" but repo taxonomy uses "Development & Workflow"; composerIcon path is "./assets/icon.png" from .codex-plugin/ subdirectory but should be "../assets/icon.png" to reach the plugin root assets folder.
README.md 165 MEDIUM PR description references a "Table of Contents" section reordering that has no corresponding change in this diff; if the intention is to also update a TOC or plugins.json, those files must be included in the PR.
Other Observations (not in diff)

No issues found in unchanged code relevant to this diff.

File Line Issue
Files Reviewed (3 files)
  • README.md — line 165 diff line reviewed; alphabetization checked (Listing is in correct order: Team Skills Platform, Token Optimizer, Test Gap, TODO Harvest, Tool Advisor, Unity Agent Workflows — all T-starting entries are correctly sorted)
  • plugins/alexgreensh/token-optimizer/.codex-plugin/plugin.json — all 14 new lines reviewed; no new issues beyond those already flagged
  • plugins/alexgreensh/token-optimizer/assets/icon.png — new binary file added and referenced by plugin.json

Reviewed by step-3.5-flash · 394,607 tokens

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant