dsh-force-compact
Aggressive context compaction for local-first agents using Qwen3.8‑27B on self-hosted llama.cpp, shrinking conversation history while preserving deep memory in compressed form.
Ficha actualizada 22 sept 2026, 22:56 · upstream 22 sept 2026, 22:52 · release sin release detectada
Qué es dsh-force-compact
Descripción editorial construida a partir del repositorio, su documentación y sus señales de mantenimiento.
dsh-force-compact is a Cordis function plugin that implements aggressive context compaction for DeepSeek Harness (DSH) agents running locally. It serves a Qwen3.8‑27B model on self-hosted llama.cpp with a modest context window, then shrinks the conversation history so the live prompt remains small and fast while keeping deep memory in the compressed head. This delivers a large-window experience without API costs or data egress.
The plugin operates transparently as a DSH Cordis function: it intercepts model requests before they reach the LLM layer, compacts relevant context into a single session-level buffer, and passes the reduced payload to the underlying model. No separate adapter is required; the standard DeepSeek adapter handles inference while this plugin manages memory.
Key design decisions include: - Two compaction engines coexist behind one facade: the official `compaction` service (preferred) and a builtin transaction that runs on `ctx.sessions`, `ctx.llm.stream`, or `ctx.tokenMeter`. The builtin is self-contained, uses the same event vocabulary as the official engine, and replays safely across builds. - Trigger points include per-request threshold checks in `agent/pre-step`, turn-end idle detection via `agent/status` → `idle`, manual `/force-compact` commands that queue a process-local flag for the next model step, and session flush checkpoints. Every path funnels into a single "compaction result landed" boundary where the LiveUI signal fires.
The plugin is designed to be private and free: no per-token billing or data egress. It only modifies the internal conversation buffer; all downstream calls remain unchanged.
- Reduce API costs by keeping conversations under a small context window (e.g., 2048 tokens) while still retaining long-term memory in compressed form
- Enable local agent deployment without external inference endpoints or data egress concerns
- Support multi-turn reasoning where the user expects deep recall but the conversation naturally exceeds the API limit
- Provide a private, on-premises alternative to cloud-based LLM agents that require large context windows
- Reduce latency by avoiding unnecessary token expansion and re-computation during long conversations
- Enable fine-grained control over which parts of history are summarized versus retained verbatim
- Supports Qwen3.8‑27B models with a configurable context threshold, allowing users to choose between aggressive compaction and full retention
- Provides per-attempt audit logging that records both the decision logic (e.g., `disableThinking=true`) and wire-level fields (`reasoningEffort`), enabling observability without capturing traffic
- Supports multiple compaction engines with a graceful fallback: official service wins when reachable, builtin transaction falls back automatically on failure or unavailability
- Offers a lazy-loaded `/force-compact` command that only registers after the first model request in a session, avoiding unnecessary overhead for idle agents
- Maintains full compatibility with existing DSH agent configurations while adding new compaction capabilities without breaking existing integrations
- The `autoThresholdTokens` setting has a hard floor of 32000 tokens; below this threshold, no compaction occurs regardless of the configured value
- The builtin transaction is limited to specific session fields (`ctx.sessions`, `ctx.llm.stream`, `ctx.tokenMeter`) and may not cover all edge cases in complex multi-agent workflows
- When a model request fails or times out, the current session's compaction state is lost unless an explicit flush occurs, potentially causing data loss for incomplete conversations
- The plugin does not handle context window changes dynamically; if the underlying model's context size shifts mid-session, existing compacted history may become stale
- Manual `/force-compact` commands are process-local and do not persist across agent restarts unless explicitly re-registered via `commands` service
Perfil de infraestructura
Estimación inicial derivada del repositorio y de los servicios detectados.
Despliegue detectado
Qué señales reales de instalación hemos encontrado.
Install as an npm package or via the DSH plugin CLI. Ensure your harness version is 0.1.7+ for profile support, otherwise use `$DSH_HOME/settings.yaml`. The plugin requires a running agent instance with at least one model request to register its `/force-compact` command. For production use, enable debug logging and monitor `~/.dsh/logs/dsh-force-compact.log` for compaction events. Consider using the builtin engine in environments where the official service is unavailable or when you need automatic fallback behavior.
Stack y dependencias
Componentes inferidos a partir de manifests, configuración y documentación.
Puede sustituir a
Relaciones detectadas por el análisis del repositorio y su categoría.
Experiencia real de la comunidad
Ayuda a contrastar la estimación automática con instalaciones reales.
Todavía no hay datos comunitarios para este proyecto.