Implementation: SHADOW (context compiler) · ENABLED (work-item context packs) · Exposure: INTERNAL. See status labels. Context is what a component sees for one step. In Allternit it is compiled from canonical state for that step, not accumulated in a growing transcript.

Architecture contract

Pipeline

Records

  • ContextChunkV1: one unit of context (a user turn, file, symbol, tool input or output, diagnostic, plan, instruction, diff or summary) with its provenance, trust class, sensitivity and token estimates.
  • ContextVisibilityDecisionV1: for each chunk, HIDE, SHORT, LONG or FULL, with a relevance score and a reason code.
  • ContextProjectionV1: the selected chunks for a target capability, the instruction fragments, a token estimate and a context fingerprint.

Rules

  • Hide is not delete. Visibility is a projection. The chunk stays in state.
  • Conditional instructions are pinned by predicate, so they appear exactly when their condition holds.
  • Compress after the next operation is known, so compression keeps what that operation needs.
  • Projections are cacheable, fingerprinted and disposable. They can always be rebuilt from state.
  • Untrusted content is fenced, never concatenated into control instructions.
  • On failure, fall back to a minimal projection or deterministic retrieval, never a transcript dump.
Why: when context is a transcript, the agent’s behavior depends on how long it has run and which model’s window it fits. Compiling context from state makes each step reproducible and lets different components see different, right-sized views of the same truth.

Current implementation

The context compiler is on main behind a flag that is off by default; with the flag on it runs in shadow and does not change what a component sees. Separately, the work runtime builds deterministic context packs to rehydrate a work item, and wraps untrusted text (a predecessor node’s output, ledger payloads) in a fence with a random per-render nonce. These are internal and predate the compiler contract.

Availability

Developer relevance

Do not rely on a component “remembering” earlier turns. Put what matters in state, and expect each step to receive a compiled projection. Treat any content from outside the run as untrusted data.

Prompt-cache telemetry

The native Gizzi session stores optional tokens.cache.ttlSeconds and tokens.cache.refreshedAt (epoch milliseconds) after a cache-bearing response from the native cache-capable adapter. The timestamp is captured before that request; retries and later model steps refresh it. The native adapter’s ephemeral markers use the default 300-second TTL. Other provider paths omit these fields. Both the TypeScript compatibility bridge and Rust live/history bridges map these to finish usage fields cacheTtlSeconds, cacheExpiresAt (epoch milliseconds), and cacheRecacheTokens. The workspace preserves them through SSE parsing and persisted run telemetry. The countdown formatter is mirrored in Gizzi’s shared/util/cache-countdown.ts and the workspace’s lib/agents/cache-countdown.ts; update both together. The UI refreshes locally every 30 seconds, clears its timer on unmount, and labels expiry/recaching as estimates. It does not infer TTL from a model name in the workspace, fabricate misses, or issue background model requests.