squoze

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

README

squoze

Your context, squoze.

ci Go Reference Go version Version License Dependencies

Universal, deterministic LLM context optimizer. One static binary that sits between your AI agent and any OpenAI/Anthropic-compatible provider and shrinks request bodies — without losing information the model needs, and without breaking provider prompt caches.

squoze detects the wire format, classifies content blocks and squeezes verbose machine output (test runs, logs) with head/tail elision that never drops error lines. Compression presets adapt per model family, and every elision is locally reversible by ref.

Status: stable, v0.2.0 (Squoze v2). Measured across SWE-bench Verified (django__django-16595), TerminalBench v2.1, Aider Polyglot, and Live GitHub Pull Requests (go-chi/chi#1171): 100% Pass@1, <0.6 ms streaming latency, and up to 98.9% byte savings across test logs, dependency lockfiles (pnpm-lock.yaml, go.sum), and repetitive tool reads. Full protocol and gates: docs/eval-protocol.md.

Why

Agents waste most of their token budget on noise: repeated file reads, verbose CLI output, stale tool results. squoze removes the noise and keeps the signal — deterministically, with quality contracts:

  • Fail-open — any error means your request goes through untouched.
  • Never-elide — errors, failures and stack traces are never compressed away.
  • Cache-safe — decisions are stable across turns so provider prompt caches keep hitting (a 90% discount is worth more than a 20% squeeze).
  • Reversible — originals stay local; the model can pull them back on demand.

Install

go install github.com/Rethinger/squoze/cmd/squoze@latest

No prebuilt binaries yet — go install or go build from source. On Windows a freshly built binary may trip a Defender false positive (ThreatID 251873); add an exclusion or sign it locally.

Usage

# Drop-in proxy for any OpenAI/Anthropic-compatible client
squoze proxy --port 8787 --upstream https://api.anthropic.com
ANTHROPIC_BASE_URL=http://localhost:8787 claude

# Or zero-config: wrap the agent, env injection does the rest
squoze wrap --upstream https://api.anthropic.com claude

# Resolve an elision marker ref back to the full original text
squoze retrieve a3f9c2e1b4d0

# Check savings against a live provider, or patch opencode's provider list
squoze livecheck
squoze oc

Every response carries X-Squoze-Original-Bytes, X-Squoze-Sent-Bytes and X-Squoze-Format.

Use as a library

The root package is a thin facade over the engine — one instance per process keeps the decision memo warm, which is what makes repeat turns byte-identical:

import "github.com/Rethinger/squoze"

eng := squoze.NewEngine(squoze.DefaultMemoCapacity)
out, res := eng.Apply(requestBody)

This is how 2papi embeds it as an optimization mode.

Build

go build ./...
go test ./...                # unit + quality contracts
go test ./internal/eval -v   # was→is savings table

Apache-2.0. Pending work is tracked honestly in docs/UNFINISHED.md.

Documentation

Overview

Package squoze is the library facade for the universal, deterministic LLM context optimizer ("your context, squoze.").

Typical gateway embedding:

eng := squoze.NewEngine(squoze.DefaultMemoCapacity)
out, res := eng.Apply(requestBody)

One Engine instance per process keeps the decision memo warm: identical original bytes always produce byte-identical output, which keeps provider prompt caches stable across turns. See README.md for the quality contracts (fail-open, never-elide, cache-safe, reversible).

Index

Constants

View Source
const DefaultMemoCapacity = engine.DefaultMemoCapacity

DefaultMemoCapacity bounds the per-process decision memo (~4k blobs).

View Source
const Version = engine.Version

Version mirrors the CLI version.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine = engine.Engine

Engine runs the optimization pipeline with its cache-guard state.

func NewEngine

func NewEngine(memoCapacity int) *Engine

NewEngine returns an isolated pipeline instance.

type Result

type Result = engine.Result

Result reports what one pipeline pass did to a request body.

func Process

func Process(body []byte) ([]byte, Result)

Process runs the default shared engine over a request body.

Directories

Path Synopsis
cmd
squoze command
Command squoze is the universal, deterministic LLM context optimizer.
Command squoze is the universal, deterministic LLM context optimizer.
internal
compress
Package compress implements the first real transform: head/tail elision of verbose machine output, under the quality contracts.
Package compress implements the first real transform: head/tail elision of verbose machine output, under the quality contracts.
engine
Package engine hosts the squoze optimization pipeline.
Package engine hosts the squoze optimization pipeline.
eval
Package eval hosts the deterministic quality-fixture harness: realistic tool-output classes with must-survive facts and minimum savings floors.
Package eval hosts the deterministic quality-fixture harness: realistic tool-output classes with must-survive facts and minimum savings floors.
harness
Agent-level presets: the coding agents themselves (as opposed to raw providers).
Agent-level presets: the coding agents themselves (as opposed to raw providers).
profile
Package profile adapts compression aggressiveness to the target model family.
Package profile adapts compression aggressiveness to the target model family.
proxy
Package proxy implements the drop-in HTTP proxy mode:
Package proxy implements the drop-in HTTP proxy mode:
router
Package router classifies text blobs so the engine can decide WHO gets squeezed and who must pass through untouched.
Package router classifies text blobs so the engine can decide WHO gets squeezed and who must pass through untouched.
store
Package store provides the content-addressed decision memo behind the cache-guard contract.
Package store provides the content-addressed decision memo behind the cache-guard contract.
wire
Package wire detects the wire format of an LLM request body.
Package wire detects the wire format of an LLM request body.
wrap
Package wrap implements `squoze wrap CMD`: run an agent command with its provider base URLs pointed at an in-process squoze proxy.
Package wrap implements `squoze wrap CMD`: run an agent command with its provider base URLs pointed at an in-process squoze proxy.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL