Skip to content

Add opt-in token-efficient mode for Instruction Hub plugins - #104

Draft
adit-chandra wants to merge 1 commit into
mainfrom
adit-chandra/codex/token-efficient-mode
Draft

adit-chandra wants to merge 1 commit into
mainfrom
adit-chandra/codex/token-efficient-mode

Conversation

@adit-chandra

@adit-chandra adit-chandra commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Adds token-efficient mode to generated Instruction Hub plugins with independent switches for concise responses and experimental input compaction. Both default off. The canonical pig plugin owns the Claude hooks; generated skill compaction also applies to the other targets and MCP projections.

concise_output injects a short instruction on SessionStart/SubagentStart, preserving required detail, uncertainty, literals, and work/checks. compact_instructions applies seven audited phrase substitutions to generated skill entrypoints and Claude Agent/Task prompts. It preserves source files, frontmatter, code, possible literals, unrelated arguments, and permission decisions. pig compact-preview, an offline tokenizer measurement script, and a paid synthetic evaluation runner make the effects reviewable. Documented opt-out and rebuild behavior restore the baseline.

The CAVEWOMAN study cautions against generic input word deletion; LLMLingua-2 evaluates a learned context-aware compressor rather than stopword stripping. The research and results explain how this informs the narrow scope. Like Caveman's activation hooks, output guidance is added as context. Typed user prompts cannot be replaced by UserPromptSubmit and are untouched.

Measured limits: the current hub's 69 skill entrypoints remain 116,660 tokens with o200k_base: zero input savings. Twelve synthetic constraints passed in all four baseline/compact/concise/both arms on both workstations. The fixed-format answers did not get shorter, so concise guidance added overhead. This is not a guarantee of unchanged coding quality or whole-session savings. The follow-up hub PR enables only concise output.

Validation:

  • Full local regression run: 1,076 tests pass; final focused suite including Unicode regressions: 54 pass. Ruff lint/format and ty pass.
  • Actual hub verifies across all four targets; 44 hub tests and five hosted-MCP publication tests pass.
  • Built sdist and wheel; installed wheel generates the standalone hook. Python 3.9 runner smoke passes.
  • Linux Claude CLI loads the generated SessionStart hook from a path with spaces; a fresh session with PIG_TOKEN_EFFICIENT_MODE=off gets no injected instruction.
  • SubagentStart/PreToolUse have contract and subprocess coverage; native delegation and desktop/Windows installation remain untested.

Follow-up hub configuration: https://github.com/Promptless/instruction-hub/pull/1540 (merge this toolchain PR first).

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