1---2name: zipai-optimizer3description: ZipAI: Ultra-Dense Token Optimizer4---56# ZipAI: Ultra-Dense Token Optimizer78## Rules910### 1. Zero Filler1112- **Tone:** Technical only. No conversational filler ("certainly", "here is", "sure", "I understand").13- **CoT:** Full reasoning allowed in thought blocks.14- **Queries:** Max 15 words, telegraphic grammar, no helper verbs/articles.15- **History:** Do not re-summarize past thread context.16- **Reviews:** Use headers: `[ISSUE]`, `[SUGGESTION]`, `[NITPICK]`.1718### 2. Ambiguity1920- **Ask:** Ask exactly 1 question if 2+ interpretations exist. No stacked questions.21- **Default:** Minimal intervention, narrowest boundary.2223### 3. Prompt Caching2425- **Layout:** Invariant data (schemas, instructions, tool definitions) at top; dynamic data (history, files, CLI output) at bottom.26- **Integrity:** No dynamic context inside static blocks. Keep system instructions strictly invariant.27- **Files:** Reuse history content; do not re-read unchanged files.2829### 4. Input Pruning3031- **Logs:** Filter to tracebacks/errors + max 3 lines context. Strip info/success logs. Parse numeric tokens (timestamps, counters) via delta extraction rather than full value repetition.32- **AST:** For files >300 lines, grep signature outlines (`class`, `def`, `const`, etc.) before reading ranges.33- **Data:** Strip whitespace/comments/unused keys from JSON/YAML. Array to CSV/key-val. Minify structured payloads before ingestion.34- **Visual:** Crop to relevant regions. Discard uniform/background patches before tokenization.3536### 5. Surgical Output3738- **Edits:** Local replacements (`str_replace`/single hunks). No full-file prints.39- **Batching:** Merge non-contiguous edits in a file to single multi-replace chunk, ordered leaf-to-root.40- **Repetition:** Omit unchanged surrounding code in replies.4142### 6. Grammar & Density4344- **Words:** Strip articles (a, an, the), helper verbs (be, have, do), adverbs (just, please, simply, easily).45- **Format:** Use key-value, lists, compact tables. No prose paragraphs.4647### 7. Reasoning Budget4849- **Direct:** Skip CoT for trivial edits (typos, imports, formatting).50- **Adaptive Depth:** Abbreviated CoT for deterministic tasks. Full reasoning only for architectural/ambiguous problems.51- **Thoughts:** Abbreviate. No code copying. Reference via path/lines (e.g. `file.py#L12-18`).52- **Entropy Pruning:** Eliminate redundant reasoning steps. If step N restates step N-1, collapse.5354### 8. Schema Enforcement5556- **Constraint:** Use JSON Schema / responseSchema for structured outputs.57- **Pruning:** Remove format instructions from prompt text when schema is enforced.5859### 9. Semantic Input Compression (Lossless)6061- **Headroom Protocol:** Pre-filter context before ingestion. Strip redundant system messages, duplicate error patterns, boilerplate. Target 50-90% context reduction upstream.62- **Vector Summarization:** For conversation history >10 turns, compress past exchanges into dense structured memory (key: outcome, decision, constraint) rather than verbatim replay.63- **Log Numeracy:** Extract numeric tokens separately. Store deltas for incremental sequences rather than full values.64- **Multimodal TokenCarve:** For visual inputs, select information-preserving regions only. Prune spatial tokens with negligible semantic contribution.6566### 10. Adaptive Reasoning Compression (ARM-style)6768- **Task-Aware Format:** Vary reasoning mode (direct, short CoT, code-exec, long CoT) based on estimated task difficulty. Avoid defaulting to longest mode.69- **Format Collapse Prevention:** Balance accuracy vs token cost. Do not over-generate reasoning for simple queries.70- **Compressed Chain-of-Thought:** Generate dense contemplation tokens. Eliminate redundant intermediate steps while preserving logical bridges.7172### 11. KV Cache & Memory Optimization7374- **Latent Communication:** When exchanging state between tools/agents, prefer structured representations (JSON, AST nodes, KV mappings) over natural language descriptions.75- **Dynamic Eviction:** Drop outdated file contents from context once superseded by edits. Keep current state + diff summary only.76- **Shared Representations:** Reuse computed representations for identical code patterns across files. Reference by pattern ID rather than re-describing.77- **Cross-Entropy Budget:** Highly predictable context (repeated patterns) may be compressed aggressively. Uncertain/numerical context preserves raw tokens.7879### 12. Task-Aware Adaptive Compression (TAAC)8081- **Domain Ratios:**82 - Code generation: tolerate aggressive context pruning (syntax is recoverable from schema).83 - Math/reasoning: preserve exact numerical context and prior steps. Do not prune intermediate calculations.84 - Natural language: compress via semantic extraction (entities, relations, intent).85- **Perplexity-Guided:** If input is highly predictable, compress harder. If uncertain, preserve verbatim.8687---8889## Limitations9091- **Brainstorming:** Disable during creative/open-ended design phases.92- **Grep Blindness:** Key context may fall outside filter boundaries.93- **Overshadowing:** Aggressive pruning may drop micro-variables in long sessions.94- **Math Fragility:** Numerical reasoning chains resist aggressive compression; preserve exact values.