cd /news/ai-agents/show-hn-ai-agent-infrastructure-and-… · home › topics › ai-agents › article
[ARTICLE · art-175267] src=github.com ↗ pub= topic=ai-agents verified=true sentiment=· neutral

Show HN: AI Agent Infrastructure and Memory Compaction Specifications

A Show HN post published by the Snowden SAY Deep Systems Engineering Lab lays out a three-tier rolling memory compaction architecture for long-running AI agents, arguing that 128k–1M token context windows create a false sense of infinite memory because attention dilutes across the KV cache in runs of 40+ tool turns. The post reports that grammar-constrained decoding via CFG logits masks before softmax achieves 99.97% JSON Schema validity versus 92% with prompt-based validation, and that the setup was tested on a SWE-bench Verified subset at 17,000 tool iterations per day with Llama-3.3-70B on 4×A100 GPUs. The post also recommends never summarizing failed tool calls, locking compaction routines with asyncio.Lock to prevent double-compaction in parallel async tool loops, and names xgrammar, outlines, guidance, Tree-sitter, gVisor, Firecracker and nsjail as supporting tooling.

recommendation

Use a three-tier rolling compactor — pinned invariants, a deduplicated ledger, and a raw tail of the last 4-6 turns — and guard compaction with asyncio.Lock to stop parallel tool loops from double-compacting.

more in playbook: Designing agent systems
read3 min views1 publishedNov 24, 2026
Show HN: AI Agent Infrastructure and Memory Compaction Specifications
Image: Michielbdejong (auto-discovered)

Curated Architecture Specifications, Memory Engines, Schema-Constrained Decoding, SWE-bench Evals & Production Tooling

⚡ Snowden SAY Deep Systems Engineering Lab: Ежедневные глубокие разборы аварий на проде, деградация внимания LLM (Lost in the Middle), rolling memory compactor и low-level агентные рантаймы — в нашем Telegram-канале: @snowdensay.

📖 Полная монография «Память и рантайм AI-агентов» (код + тесты): доступна в Telegram-боте @Snowden_book_bot

Modern LLMs with 128k–1M token context windows create a dangerous illusion of infinite memory. In long autonomous agent runs (40+ tool turns), attention weights irreversibly dilute across the KV cache (Lost in the Middle).

  1. Never summarize failed tool calls: Raw error tracebacks must remain verbatim until fixed, or the agent cycles infinitely.
  2. Grammar-constrained decoding over prompt validation: Enforce JSON Schemas via CFG logits masks prior to softmax (99.97% validity vs 92% with prompt prompting).
  3. Lock your compaction routines: Parallel tool invocations in async loops trigger race conditions and double-compaction withoutasyncio.Lock .

Three-tier rolling compaction architecture:

[ LAYER 1: Pinned Invariants ] ─── System contract, safety boundaries, tools (Raw, 0% drop)
           │
[ LAYER 2: Compacted Ledger ]  ─── Deduplicated facts of completed successful tool cycles
           │
[ LAYER 3: Hot Raw Tail ]      ─── Last 4-6 turns (Fresh local state + unresolved stacktraces)
  • Reference Implementations: - RollingMemoryCompactor (Python/Go): Automatic deduplication of idempotent file reads (head ,cat ) into SHA256 pointers.

    • Episodic KV Cache Off : Pruning intermediate layer KV tokens for background context.
  • xgrammar : Fast GPU-accelerated grammar-guided decoding for vLLM and SGLang.

  • outlines : Structured text generation via finite-state machine (FSM) index over model vocabulary.

  • guidance : Interleaved generation and control logic with token-level regex constraints.

from vllm import LLM, SamplingParams
from vllm.sampling_params import GuidedDecodingParams

schema = {
    "type": "object",
    "properties": {
        "tool": {"enum": ["patch_ast", "execute_test", "commit_fix"]},
        "file_path": {"type": "string", "pattern": r"^[\w\-\./]+\.[a-z]+$"},
        "patch_content": {"type": "string"}
    },
    "required": ["tool", "file_path", "patch_content"],
    "additionalProperties": False
}

params = SamplingParams(
    temperature=0.1,
    max_tokens=1024,
    guided_decoding=GuidedDecodingParams(json=schema)
)
  • Tree-sitter : Incremental concrete syntax tree parsing for AST-aware diffing.

  • SWE-bench : Benchmark for evaluating LLMs on resolving real-world GitHub issues.

  • Syntactic Rollback Guards : Reverting invalid patches at parse-time before invoking compilers.

  • Prompt Injection Defense in Tools : Strict sanitization of dynamic tool definitions from untrusted MCP servers.

  • Zombie Process Reaper : Automatic cleanup of stdio subprocesses exceeding idle TTL.

  • Concurrency Rate Limiting : Non-blockingselect token buckets to prevent LLM retry stampedes.

  • gVisor : Application kernel for container security, intercepting Linux syscalls in user space.

  • Firecracker : Ephemeral microVMs booting in < 5 ms for untrusted Python code execution.

  • nsjail : Lightweight Linux process isolation tool using namespaces and seccomp-bpf.

Tested on SWE-bench Verified subset (17,000 tool iterations/day, Llama-3.3-70B on 4×A100):

Metric Naive Context Buffer Linear Summarization Rolling Compaction (Ours)
System Rules Recall 68.2% 74.5% 97.8%
Token Cost Per Run 1.84M 1.12M 0.62M (-66%)
Infinite Loop Failures 14.3% 9.8% 0.2%
p99 Execution Latency 4.8s 8.2s 1.9s

Discussions and architecture blueprints are maintained by Snowden SAY.

── more in #ai-agents 4 stories · sorted by recency
── more on @snowden say deep systems engineering lab 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/show-hn-ai-agent-inf…] indexed:0 read:3min 2026-11-24 · —