Status: Reference Documentation Context: Explaining the architectural decisions behind BAZINGA's memory and orchestration systems. Based on: Agentic Context Engineering (Transcript Analysis)
"Agentic Context Engineering" is the discipline of managing an AI agent's memory not as a simple chat log, but as a structured, engineered system. The core premise is that "context is not a window, it is a compiled view."
This document outlines the theoretical frameworks (Google ADK, ACCE, Manus) that define modern agent architecture and details how the BAZINGA system implements these principles to solve the "context window fallacy"—the mistaken belief that larger context windows equal better performance.
While LLM context windows have grown (128k, 1M+ tokens), simply dumping entire session logs into the prompt leads to:
- Signal Dilution: Irrelevant history drowns out critical instructions.
- Context Rot: Outdated constraints ("don't use library X") persist even after decisions change.
- Log Bloat: Debugging becomes impossible as prompts grow to megabytes of unstructured text.
The industry has converged on three key patterns to solve this:
Instead of a flat log, memory is split into four distinct tiers mirroring computer architecture:
| Tier | Analogy | Description |
|---|---|---|
| Working Context | Cache | The minimal set of instructions and immediate history needed for the current step |
| Sessions | RAM | Structured event logs of the current trajectory |
| Memory | Disk | Durable, searchable insights that survive across sessions |
| Artifacts | File System | Large objects (code files, PDFs) referenced by pointers, not pasted as text |
Contexts must evolve. Static system prompts fail in long-horizon tasks. The Agentic Context Engineering (ACE) framework treats context as a "living playbook" that accumulates strategies and prunes failures using a loop of Generation, Reflection, and Curation.
For autonomous agents, heavy state (e.g., a 5,000-line file or a browser DOM) must be offloaded to a sandbox or file system. The agent receives only a handle/pointer to the data. Furthermore, sub-agents (Planner, Executor, Verifier) must have isolated scopes to prevent "hallucinated teamwork" where one agent confuses another's internal monologue for a task instruction.
The transcript identifies nine principles for production-grade agents:
- Context as a Compiled View: Every prompt is a fresh projection, not a transcript.
- Tiered Memory Model: Separate storage (DB) from presentation (Prompt).
- Scope by Default: Default context is empty; retrieval is an active decision.
- Retrieval Beats Pinning: Search for relevant memories; don't pin everything.
- Schema-Driven Summarization: Use structured schemas (JSON/YAML) over loose text summaries.
- Offload Heavy State: Keep large data in files/DB; pass pointers to LLM.
- Isolate Sub-Agent Scope: Distinct views for different roles (Dev vs. QA).
- Caching & Prefix Stability: Design prompts to maximize KV-cache hits.
- Evolving Strategies: Agents should update their own instructions/strategies.
The BAZINGA system was explicitly architected to align with these principles. Below is the mapping of theory to actual code and database structures.
Theory: Separate storage from the "view" presented to the LLM.
BAZINGA Implementation: The Orchestrator does not simply read a log file. Instead, it compiles the prompt dynamically using bazinga-db:
| Tier | BAZINGA Component | Implementation Details |
|---|---|---|
| Working Context | Capsules & Summaries | The prompt receives only the summaries of relevant Context Packages and the last few "Capsule" status messages |
| Sessions | sessions & orchestration_logs Tables |
Structured SQL tables track every interaction (id, timestamp, agent_type) |
| Memory | Context Packages (DB) | The context_packages table stores metadata (priority, summary) for research and decisions |
| Artifacts | Context Files (.md) | Actual heavy content (e.g., 20KB research reports) is stored in bazinga/artifacts/{SESSION_ID}/context/ |
Theory: Don't paste 50 pages of research into the prompt. Pass a pointer.
BAZINGA Implementation: We implemented the Context Package System to handle this exact problem.
The Problem: A "Research Agent" generates 20KB of analysis. Pasting this into the "Developer Agent" prompt wastes tokens and dilutes attention.
The Fix:
- Research Agent saves content to
bazinga/artifacts/.../research-group-A.md - Agent calls
save_context_packageto register the file path and a 1-sentence summary in the database - Developer Agent receives only the summary and file path in its prompt
- Active Retrieval: The Developer must explicitly call the
Readtool to access the full content if needed
# From bazinga_db.py - The "Pointer" approach
def get_context_packages(...):
# Returns only metadata (summary + path), NOT full content
return cursor.execute("SELECT summary, file_path, priority ...")Theory: Prevent "crosstalk" where agents see irrelevant information from other sub-teams.
BAZINGA Implementation: We use a Join Table approach for strict scoping.
Table: context_package_consumers
Mechanism: When a package is created, it is assigned specific consumers (e.g., ['developer', 'qa_expert']).
Result: A "Tech Lead" architecture decision package is not visible to a "Junior Developer" unless explicitly routed. This prevents the developer from being confused by high-level architectural debates that are irrelevant to their specific coding task.
Theory: Naive text summaries ("The dev worked on auth") lose critical details. Use schemas.
BAZINGA Implementation:
- Context Packages: Use strictly validated YAML Front Matter for metadata (Priority, Type, Consumers)
- Capsule Messages: Agents communicate status using a strict format:
🔨 Group {id} | {summary} | {status} → {next_phase}. This allows the Orchestrator to parse the state deterministically without guessing.
Theory: Agents should learn and update their strategies, not just execute.
BAZINGA Implementation: The orchestration_logs table includes specific columns for Reasoning Capture:
log_type='reasoning'reasoning_phase: Tracks where in the thought process the agent is (understanding, strategy, pivot, conclusion)confidence_level: Allows the system to weigh high-confidence insights more heavily in future prompts
This allows the system to reconstruct why a decision was made (the "Playbook") separately from what was done (the "Log").
- Concept: Tiered Memory Architecture (Sessions vs. Memory Bank)
- Source: Google Agent Development Kit (ADK) Documentation
- Concept: "Agentic Context Engineering" and evolving contexts
- Paper: Agentic Context Engineering: Evolving Contexts for Self-Improving Language Models (ArXiv:2510.04618)
- Concept: Autonomous agent architecture, offloading state, and sub-agent isolation
- Paper: From Mind to Machine: The Rise of Manus AI as a Fully Autonomous Digital Agent (ArXiv:2505.02024)
Here is a relevant video on the topic: Agentic Context Engineering: Evolving Contexts for Self-Improving Language Models. This video provides a comprehensive overview of the ACE framework discussed in the document.
Last Updated: 2025-12-11