Building & Shipping Durable Client Agents
How we take a client engagement from a hand-tuned QuickBooks sandbox to a versioned domain ontology, isolate it inside a two-plane Client Environment on GCP with proxy-level audit & tracing, and expose it over A2A 1.0.
Wire QuickBooks safely through a credential proxy, sit with the SME, fork tricky turns.
Turn tribal accounting definitions into GLOSSARY.md, rules, and probes.
Lock invariants via verify-deploy; deploy the two-container Client Env to GCP.
Serve traced A2A 1.0 + /.well-known/agent-card.json to Pi, Slack, and peers.
Four Layers, Split Cleanly Across a Trusted Client Perimeter
Rethinking GaiaHost as a Client Environment: LLM + HTTP proxying, credentials, and wire-level audit live on the perimeter — never inside the agent runtime.
Two Planes, Zero Shared Secrets
The Perimeter Gateway holds keys, routes LLM/HTTP traffic, and logs traces; Habitat Runtime has no direct internet and zero upstream credentials.
Correlated Wire Audit
Every inbound A2A request mints one trace_id carried across Mycel LLM completions and QuickBooks/MCP egress calls.
Testable Offline First
Swap real providers for fauxProvider + mock upstreams locally (`examples/client-env/`) to test ACLs, redaction, and traces in milliseconds.
Why DurableHabitat Beats Stateless Agent Scripts
Built directly on @earendil-works/pi-durable's transactional Harness and Node 24's built-in node:sqlite.
Typical Ephemeral Agent Wrapper
- In-memory chat arrays lost on deploy or process crash.
- Unbounded workspace file access when tools are enabled.
- No safe way to branch from Turn 7 and test a prompt fix.
- Cron jobs live in external scripts disconnected from session context.
- Single global conversation leaks across callers or channels.
Transactional Habitat Store (habitat.sqlite)
- Crash-safe resume: Commit turns atomically;
harness.resume()recovers cleanly across restarts. - Zero-copy
fork(entryId): Test fixes against real client state without mutating history. - Scoped execution: Omit
ExecutionEnv(API-only) or enforce Owned R/W vs. Mounted R/O roots. - Armed sleep/wake: Durable
HabitatCronTaskstays scheduled even when idle Harnesses evict after 10m.
Zero external DB required per agent.
Cold on disk, auto-reopened on request.
ConversationAnnotationsDoc flags.
Rich HTML without bloating LLM context.
Connect QuickBooks, Hand-Tune & Build the Ontology
Walkthrough scenario: a client wants an internal Finance & Ops agent over their QuickBooks Online ledger — answering A/R questions, spotting uncategorized spend, and preparing month-end variance briefs.
QuickBooks OAuth 2.0 stays in mcp-serve / bearer proxy — zero secrets inside the Habitat.
Engineer + Controller test live queries via Pi, fork edge cases, promote FACTS.md.
Commit GLOSSARY.md + GL mappings, extract specs, freeze Evals before GCP.
Hybrid Proxy: Named Egress Routes + Correlated LLM Tracing
The Habitat holds zero QuickBooks OAuth tokens or LLM keys — every request crosses the Perimeter carrying x-trace-id.
1. Hybrid Egress Control
Named /egress/quickbooks & /egress/mcp routes enforce GET-only ACLs with zero TLS CA setup; optional CA forward proxy covers shell tools.
2. Wire-Level Traceability
Even if the agent stays silent, the proxy records every URL queried, method blocked (403), secret scrubbed, and micro-dollar spent.
3. ui:// Keeps Context Slim
Large 200-row aging schedules travel in _uiResources for the human while the LLM receives a 20-token summary.
Hand-Tune with the Client SME Before Automating Anything
Sit next to the bookkeeper using pi + DurableHabitat: turn messy edge cases into durable memory, not one huge brittle prompt.
Run Real Questions
"What was net SaaS margin in Q3 excluding AWS pass-through?" Watch real tool queries against sandbox/R-O QBO.
Catch Domain Quirks
Agent treated Account 4120 ("Setup Fees") as recurring ARR or missed vendor alias AMZN MKTP.
fork(entryId) A/B
Fork right before the mistake. Test refined instructions or swap frontier vs. local models cleanly.
PromotionRouter
Distill confirmed rules with umwelten_promote_knowledge straight into FACTS.md & AGENTS.md.
Session Discovery: Customer "Acme Corp (Legacy)" and "Acme Holdings LLC" share one parent billing contract in QBO notes, and GL 6410 is reimbursable client hardware — never include in internal COGS.
→ FACTS.md + docs/ontology/
Crystallize Tribal Accounting Knowledge into a Mounted Ontology
Raw QuickBooks tables do not know how the client defines ARR, COGS, or entity rollups. Version that meaning in Git.
Mounted Read-Only Guard
The Habitat can always read updated rules from /ontology, but write/edit calls are rejected so runtime chats never silently corrupt client policy.
Automatic Drift Detection
TurnAnnotationProbe inspects every completed turn and flags new unmapped GL codes or split invoices in ConversationAnnotationsDoc for human review.
Graduate Prototype Sessions via spec-extract & verify-deploy
Turn conversation discoveries and SME quirks into verifiable contracts before pushing a container to GCP.
spec-extract
Distills code diff + conversation transcript into modular packs:
docs/specs/agent/quickbooks-ops.md[zero-secret-habitat-runtime]invariant[perimeter-correlated-audit-trace]docs/decisions.jsonl(D-1..Nwhy-log)
EvalSuite + Matrix
Turns gnarly client scenarios into repeatable regression checks:
- Accrual vs. cash cutoff test tasks
- Pass-through GL exclusion accuracy
- Benchmark
fablevs.hydrogenvs. localqwen4 - Zero-cost offline
fauxProvidercontract gate
verify-deploy
No green verdict from prose — proves every invariant with live & sandbox checks:
- Mode 1: read-only SQLite + trace ledger audit
- Mode 2:
403egress block + secret scrub drill - Writes immutable
docs/runs/<ts>_<sha>/verdicts.jsonl
Deploy the Client Environment to GCP & Expose via A2A 1.0
Two containers on an internal: true Docker network inside the client's GCP VM: a trusted Perimeter Gateway (dedicated Mycel LLM tracer + Hybrid HTTP/MCP proxy + secrets + audit ledger) isolating a zero-secret Habitat Runtime.
Two-Container Client Environment Inside Client GCP
habitat-runtime sits on an internal: true network with zero internet route and zero secrets; perimeter-gateway owns Mycel + proxies + audit.
Zero-Secret Execution Plane
Even with CodingTools shell enabled, habitat-runtime has no route past the Docker internal net and zero Intuit or Anthropic keys in env.
Complete Client Auditability
Client-local Mycel + HTTP proxy log every prompt, completion, QuickBooks query, and blocked verb under one shared trace_id.
Safe CI/CD Rollback
redeploy.sh snapshots habitat:previous, verifies /health + 401 + A2A Card + trace write, and rolls back automatically on failure.
One Verified & Audited A2A 1.0 Endpoint Powers Every Consumer
Inbound POST /a2a authenticates at the perimeter, mints x-trace-id, dispatches to habitat-runtime, and records the full tree.
taskId to inspect the exact Mycel model cost, prompt, and QuickBooks API spans it triggered.
The 5-Day Client Agent Playbook
Zero-Secret Boundary
Wrap QuickBooks in hybrid OAuth MCP / bearer proxy; verify 403 & response scrubbing.
Tune with the SME
Sit with Finance, fork() wrong answers, lock GLOSSARY.md + GL maps + probes.
Lock Invariants
Run spec-extract, freeze QBO edge cases in EvalSuite, pass verify-deploy Mode 2.
Client Env + Mesh
Deploy two-container Client Env (Mycel + HTTP proxy + zero-secret runtime) on GCE, hand out A2A Card.
Client Env demo: pnpm run demo:client-env · Multi-A2A: pnpm run demo:multi-a2a · Prompt Labs: examples/labs/README.md