dsh-cortex
a local context management stack for coding agents
2 min readupdated
A set of three lightweight quantized models by author Logic-z, designed for local memory control and context quality management in AI programming agents. Instead of bloating chat history, the stack compresses each agent step into a single line, searches through action archives, and evaluates the risk of context degradation directly on a CPU or integrated graphics using llama.cpp. Two of the included models are based on Qwen3.5-0.8B (fine-tuned via LoRA [a method for efficient weight adaptation]), while the third uses original embeddinggemma-2 weights. This solution is useful for developers of local agent systems who need fast session state monitoring without relying on external APIs.
Key features
- Agentic Summarizer: a fine-tuned
Qwen3.5-0.8Bmodel (distilled fromQwen3.5-2B) that collapses tool calls and agent responses into a compact, single-line card. - Agentic Monitor: a
Qwen3.5-0.8Bversion with a linear classification head (head.json) that computes a context degradation score based on the step history. - Semantic search: the original
embeddinggemma-2model inQ8_0quantization for generating 768-dimensional embeddings and searching through dialogue archives. - Lightweight local run: all weights are packaged in GGUF format (
Q4_K_MandQ8_0) for fast inference on CPUs and iGPUs usingllama-server.
What you can do
- Integrate it into your own AI programming agent to automatically compress long tool call logs and save context window space.
- Set up an automatic session cleanup or restart trigger when the
agentic-monitorsignals a high risk of context degradation. - Organize local hybrid search across past agent actions and decisions using
embeddinggemma-2.
Example
# Запуск суммаризатора шагов и монитора качества через llama-server
llama-server -m qwen3.5-0.8b-agentic-summarizer/qwen3.5-0.8b-agentic-summarizer-Q4_K_M.gguf -c 4096 --port 8082
llama-server -m qwen3.5-0.8b-agentic-monitor/qwen3.5-0.8b-agentic-monitor-Q4_K_M.gguf \
--embeddings --pooling last --embd-normalize -1 -c 8192 -b 8192 -ub 4096 --port 8083Read more
DetailsContents:
embeddinggemma-2-Q8_0.gguf, qwen3.5-0.8b-agentic-summarizer-Q4_K_M.gguf, qwen3.5-0.8b-agentic-monitor-Q4_K_M.gguf + head.json.Training: models based on
Qwen/Qwen3.5-0.8B were fine-tuned using LoRA (merged with base weights), and the summarizer was distilled from Qwen3.5-2B.Degradation scoring: extracts the hidden state of the last token via
/v1/embeddings and runs it through sigmoid(dot(h, weight) + bias).Licenses: Apache-2.0 for Qwen3.5-based models, Gemma Terms of Use for
embeddinggemma-2.









Comments