Unified Brain — the architecture direction (researched 2026-06-22)
Sam asked: knowing what we know, how would we have built the bot/brain differently, is the stack (Apps Script + Google + cloud) right, cost-aware, and what's the best way now. This is the grounded answer after researching the last few weeks of Claude Code / agent developments. Living doc.
The diagnosis (it has a name)
What Sam felt — "the bot's a problem, we never finished unifying the brain" — is the #1 documented agent-architecture failure of 2026: siloed memory. Running multiple AI surfaces with separate memory/brains means no single one has the complete picture. The field's fix: one unified memory layer every surface reads + writes. We've been hand-building exactly that.
Today we have N brains pretending to be one: the Telegram bot (its own Apps Script + Claude call + prompt + tools + transcript), the MIS, Claude Code (me), the portal — each siloed, sharing only storage, not live awareness or guardrails. That is why the bot guessed "NKE ~$77": it doesn't share the MIS price data or my no-guessing guardrail.
How we'd build it differently — one brain, many faces
A single brain: one unified memory, one tool set, one set of guardrails. The bot / portal / Claude Code / Chanie's / Mildred's all become thin faces that call it. Wire a rule once ("never quote a price without the MIS tool") and every face inherits it — the bot literally couldn't hallucinate.
Native primitives that now exist (stop hand-rolling)
- Agent Memory (GA, Apr 23) — cross-session memory; replaces hand-rolled D1 + MEMORY.md.
- "Dreaming" (research preview) — agent reviews past sessions + rebuilds its own memory store: merges duplicates, replaces stale/contradicted entries, surfaces new insights; input never modified, you review before keeping. = our nightly-consolidate + KB-health-check + reconciliation engine, native. Would auto-fix the 286-card dup sprawl + stale docs.
- Managed Agents + rubric-grader — define "what good looks like"; a separate grader sends the agent back until it meets the bar (+10 pts hardest tasks). = our proof-discipline + verify-loop, native.
- Sandbox + private MCP — the brain's tools run on YOUR infra (MIS sheet, inbox, Plaid); orchestration/context/error-recovery stays on Anthropic's. Data never leaves; smarts are managed.
- 1M-token context at flat pricing (GA Mar 13) — the "longer = stupider" ceiling moved.
Is the stack right? (cost-aware)
- Keep Google — great + free for: Sheets (human-editable surfaces), Gmail/Calendar/Drive (connectors). Don't rip out.
- The mistake = putting the BRAIN in Apps Script. Each Apps Script (bot/MIS/LevSMS) makes its own Claude call = N fragmented brains + the clasp/reauth/403 brittleness. Apps Script is fine as a connector/cron, wrong as the brain.
- Right move: one brain service — the Cloudflare Worker + D1 we already have (or Anthropic Managed Agents) holds unified memory + tools; bot/portal/Apps Script become thin faces.
- Cost: unifying is CHEAPER. Today N surfaces fire redundant Claude calls. One brain = fewer, smarter calls (Haiku for cheap, Opus for hard reasoning). Workers + D1 are pennies; 1M context is flat-priced. Saves money AND makes it smarter.
The punchline
The unified brain is the SINGLE answer to everything Sam asked: untether from the PC · smarter at day 100 · open the bottleneck · the bot shouldn't lie. Not five projects — one. First brick: wire the bot to the shared brain's MIS price tool (the NKE fix) + the no-guess guardrail.
Sources
Claude Code changelog · Releasebot (Anthropic updates) · The New Stack (dreaming) · 9to5Mac (managed agents) · Dotzlaw (Code with Claude 2026, infinite context) · SitePoint (personal AI agent OS).