You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The proposed provider-independent Pi extension in #2657 can double-compress tool results already compacted or truncated by pi-rtk-optimizer.
This does not mean RTK and Headroom cannot coexist: the hooks and /v1/compress contract work together. The problem is that Headroom does not recognize RTK's compaction metadata, so it treats an already-lossy RTK result as a fresh compression candidate.
The candidate is still accepted because hasPruningMetadata() only checks top-level prunedAt/pruned and details.truncation.truncated; it does not inspect details.rtkCompaction.truncated or details.metadata.rtkCompaction.truncated.
The candidate is sent to /v1/compress and accepted again.
The Headroom Pi bridge's validateCompression() accepts this result, so the model-facing context is compressed a second time. The CCR/retrieval path cannot restore bytes that RTK already removed.
Headroom should detect that the candidate was already lossily compacted by RTK and, by default, skip it or apply an explicit, documented composition policy. It should not silently perform a second lossy transformation on a result whose source has already been truncated.
RTK's command rewriting and ordinary non-truncated output should remain eligible for Headroom compression.
Suggested fix
Extend the Pi policy's pruning/compaction metadata detection to recognize RTK's shape, including both locations RTK writes:
details.rtkCompaction.truncated === true
details.metadata.rtkCompaction.truncated === true
Add a regression test using an RTK-shaped toolResult and assert that candidateFromToolResult() returns undefined. A separate test can confirm that non-truncated RTK aggregation remains configurable/eligible.
Summary
The proposed provider-independent Pi extension in #2657 can double-compress tool results already compacted or truncated by
pi-rtk-optimizer.This does not mean RTK and Headroom cannot coexist: the hooks and
/v1/compresscontract work together. The problem is that Headroom does not recognize RTK's compaction metadata, so it treats an already-lossy RTK result as a fresh compression candidate.Versions
0.84.2pi-rtk-optimizer:0.9.00.35.0plugins/pi/src/policy.ts)Reproduction
truncate.maxChars: 12000).bashcommand that emits log output (example: 2,000 repetitive structured log lines, 262,369 characters).tool_resulthook changes the result to 12,000 characters and returns metadata equivalent to:{ "rtkCompaction": { "applied": true, "techniques": ["truncate"], "truncated": true, "originalCharCount": 262369, "compactedCharCount": 12000 }, "metadata": { "rtkCompaction": { "applied": true, "techniques": ["truncate"], "truncated": true } } }toolResultthrough the candidate policy in feat(integrations): add provider-independent Pi/OMP extension #2657.hasPruningMetadata()only checks top-levelprunedAt/prunedanddetails.truncation.truncated; it does not inspectdetails.rtkCompaction.truncatedordetails.metadata.rtkCompaction.truncated./v1/compressand accepted again.Observed result with the current proxy:
The Headroom Pi bridge's
validateCompression()accepts this result, so the model-facing context is compressed a second time. The CCR/retrieval path cannot restore bytes that RTK already removed.A second error-log fixture produced:
Expected behavior
Headroom should detect that the candidate was already lossily compacted by RTK and, by default, skip it or apply an explicit, documented composition policy. It should not silently perform a second lossy transformation on a result whose source has already been truncated.
RTK's command rewriting and ordinary non-truncated output should remain eligible for Headroom compression.
Suggested fix
Extend the Pi policy's pruning/compaction metadata detection to recognize RTK's shape, including both locations RTK writes:
details.rtkCompaction.truncated === truedetails.metadata.rtkCompaction.truncated === trueAdd a regression test using an RTK-shaped
toolResultand assert thatcandidateFromToolResult()returnsundefined. A separate test can confirm that non-truncated RTK aggregation remains configurable/eligible.Related: #2657, #645.