compressor-reflex / INSERTION.md
aialchemist-dev's picture
Compressor Reflex v2 (INT8): 100% must-keep retention @ tau*=0.50
11d7a2c verified
|
Raw History Blame Contribute Delete
2.28 kB
# Compressor Reflex (v1): Insertion Point Specification
## 1. Architectural Placement
The Compressor Reflex sits **inline between tool execution and conversational context append**.
```
[Agent Core / LLM]
│
│ 1. Emits Tool Call (e.g. view_file, grep_search, run_command)
▼
[Tool Execution Engine]
│
│ 2. Returns Raw Output (stdout/stderr, file lines, search hits)
▼
┌────────────────────────────────────────────────────────┐
│ COMPRESSOR REFLEX INTERCEPTION │
│ │
│ Input: Step Intent (<= 128 tok) + Raw Output Chunk │
│ Logic: Line-level keep/drop classification │
│ Policy: Fails-Open (keep on uncertainty / <= 5 lines) │
└────────────────────────────────────────────────────────┘
│
│ 3. Returns Compressed Output (Decision-relevant lines only)
▼
[Context Accumulator / Trajectory Store]
│
│ 4. Compressed context sent to LLM on subsequent step
▼
[Next Agent Step]
```
## 2. Interception Contract
1. **Timing:** Immediately after the tool process finishes execution and captures stdout/stderr/return payload, but **strictly before** that text is appended to the message history or prompt buffer.
2. **Inputs:**
- `intent`: The current user prompt, active goal, or reasoning step that prompted the tool call ($\le 128$ tokens).
- `raw_output`: The verbatim text output from the tool execution.
3. **Fail-Open Policy:**
- If output length $\le 5$ lines or $\le 64$ tokens $\rightarrow$ bypass compressor, pass through verbatim.
- If any runtime, tokenizer, or inference error occurs $\rightarrow$ pass through verbatim with warning log.
- Line scoring: Keep any line where $p(\text{keep}) \ge \tau$ (where $\tau$ is calibrated on the must-keep anchor set).
4. **Output:** A reconstructed string containing only the kept lines in their exact original relative order, preserving line numbers and error context.