← All projects
Context window tooling

Context engineering

A toolkit for deciding what goes into an LLM’s context window: pack, score, cache, debug and red-team it.

Context Engineering Toolkit banner: a stacked context window above a dashed budget line, with the tagline “Pack, debug, red-team, and orchestrate LLM context windows”, 17 packages, and TypeScript plus Python.

The idea

Every model call has a finite window. System prompt, retrieved documents, history, tool definitions and the query all compete for it, and the naive answer — drop the oldest messages — eventually loses the system prompt and keeps the stale material. This toolkit treats the choice of what goes in as an engineering problem in its own right.

The approach

The core pipeline scores items, places them, packs them into a budget, gates the result on quality and records a trace. Around it sit the parts that feed and watch that pipeline: learned weights adjust scoring, cache topology orders stable content first so a provider’s prefix cache can reuse it, and drift detection monitors quality across a sliding window. Seventeen TypeScript packages each have a matching Python implementation. The packages are not yet published to a registry; the examples run inside the cloned workspace.

  • pack() and a pipeline builder for budget allocation by content kind
  • A Council of Experts: several models deliberate by parallel, debate, stepladder or Delphi strategies
  • Adversarial testing with six attack types, from contradiction injection to temporal poisoning
  • Checkpoint, rewind, fork and merge for context states

Project details and current setup instructions: GitHub repository .