File size: 2,283 Bytes
11d7a2c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# 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.