Systems Architecture• ToolRecall v0.8.29• Stateless & Python Agent Loops

One Local Daemon.
Built for Stateless Agent Loops.

Stateless agents (Hermes, Google ADK, LangChain, LangGraph, Aider, and custom Python loops) rebuild their prompt on every turn. ToolRecall places one stdlib-only local daemon between the agent loop, the filesystem, and the LLM API — hashing keys deterministically at Layer-0, stubbing unchanged re-reads, pruning clean context, and pooling storage in SQLite WAL.

3 Tiers
Strict Separation
Stateless Client Surface → Local Daemon → Storage & Workers
0 Deps
Python 3.11+ Stdlib
562 KB wheel, 1.8 MB installed; optional libSQL / Turso extras
74 Modules
Acyclic Load Graph
64 eager / 106 lazy imports; zero circular load-time edges
Layer-0
Pure Key Contract
Content-addressed keys via keys.py + RFC 8785 JCS
01 // Execution Topology

3-Tier Execution Layer: Tracing Stateless Agent Requests

Select a runtime flow below or click any subsystem block to inspect how requests move from stateless Python agents through the local daemon into persistent storage.

Active Flow: Cached File Read (.pth Shim + Stub)
STEP 01
Tier 1: Intercepted Read
Agent calls open() via .pth shim or cached_read()
STEP 02
Tier 2: Stat + Stub Check
Daemon checks mtime + size; unchanged reads return 14-token stub
STEP 03
Tier 3: SQLite WAL
Warm LRU serves bytes in RAM; cache.db persists metadata
Tier 1 Stateless Agent & SDK Surfaces (Userspace)
Hermes • ADK • LangChain • Aider • Custom Loops
Python .pth Shim
Patches builtins.open() read-only at interpreter startup. Never intercepts subprocesses.
shim.py + shim_stub.py
Framework Adapters & Client
Thin UDS wrappers for Google ADK, LangChain, LangGraph, LiteLLM, GEPA, and custom Python loops.
client.py + adapters/
MCP / CI Replay & Hooks
Stdio JSON-RPC bridge for MCP pooling, headless CI replay (claude -p / opencode run), and WAF hooks.
mcp_bridge.py + replay.py
Tier 2 Local Execution Daemon (toolrecall daemon)
UDS /run/user/$UID/tc.sock • HTTP :8569 • TCP :8570 (opt-in)
Cache Core & Stubs
20 MB warm LRU + Layer-0 key hashing + unchanged-file stubs + TTL/SWR policy.
cache.py + stub_core.py
Context Tracker
Tracks clean vs dirty file state across turns and emits drop-clean eviction hints at checkpoints.
context_tracker.py
Forward Proxy & Dedup
Caches identical completions on :8569, stubs repeated large blocks, guards outbound secrets.
proxy.py + dedup.py + egress.py
MCP Multiplexer & Gate
Keeps stdio MCP subprocesses warm and enforces path-allowlist & sensitive-file security gates.
daemon.py + path_utils.py
Tier 3 Storage Substrates & Pooled Workers
RLock Singleton • SQLite WAL • Optional libSQL
Cache Store (cache.db)
Singleton RLock-guarded SQLite WAL handle; swappable to libsql or libsql-sync (Turso).
_db.py + storage/
Pooled Stdlib MCP Servers
Warm background workers (fetch, github, time, seqthink, cache-fs) with idle timeout reaper.
mcp_*.py
Opt-In FTS5 Knowledge DB
BM25 local index in knowledge.db (off by default for coding loops; enable via expose_docs_tools).
docs.py + mcp_docs.py
Active Node

Contract & Data Flow

            
02 // Physical Topology

Systems Architecture Schematic

End-to-end IPC, proxy, and storage topology for stateless Python agents and local daemon substrates.

[TIER 1: STATELESS AGENTS & PYTHON LOOPS] Hermes / Custom Python Loops .pth open() shim + Context Tracker ADK / LangChain / LangGraph adapters/* → UDS client.py Aider / CI Replay / MCP Clients HTTP :8569 proxy + stdio JSON-RPC [TIER 2: TOOLRECALL DAEMON — /run/user/$UID/tc.sock • :8569 Proxy • :8570 Network (opt-in)] Layer-0 Keys & Cache keys.py • jcs.py (RFC 8785) 20MB LRU + stub_core.py Context Tracker Clean/dirty register per turn Drop-clean checkpoint hints Forward Proxy (:8569) Body-hash cache + block dedup egress.py secret guard MCP Multiplexer & Gate Warm stdio worker pool Fail-closed path allowlist [TIER 3: STORAGE SUBSTRATES & POOLED WORKERS] SQLite WAL (cache.db) Singleton RLock • Optional libSQL/Turso Replay & Failure Ledger replay.py • failures.py • keytrace.py Stdlib MCP Worker Pool fetch • github • time • seqthink • docs (opt-in)
03 // Package Dependency Graph (v0.8.29)

Interactive 74-Module Import Graph

AST-extracted intra-package imports across all 140 modules in toolrecall v0.8.29. Click any module to inspect its imports, dependents, and transitive blast radius.

toolrecall · v0.8.29 · intra-package imports
The layout library failed to load. Check your connection and reload the page.
04 // Engineering Guarantees

Core Architectural Contracts

Where to find benchmarks and setup docs: performance data lives on Benchmarks; CLI flags, agent postures, and config keys live on Docs.

Layer-0 Deterministic Keys

All cache keys and content digests route through toolrecall/keys.py and RFC 8785 canonical JSON (jcs.py). Pure functions — no clock, no session IDs, no config state.

Zero-Trust Security & Egress Gate

Path allowlists, sensitive-file blocklists, and outbound secret scanning (egress.py) enforce fail-closed policy regardless of caller metadata. Never trusts agent_id for auth.

Single-Instance & Optional Network

run_daemon holds an atomic flock on /run/user/$UID/tc.sock. Opt-in team sharing (127.0.0.1:8570) uses HMAC-SHA256 challenge-response (network_auth.py) and optional TLS.

05 // Built-in Modules

Specialized Daemon Modules (CI, MCP & Security)

Included in the same daemon, scoped to the specific teams that need them.

Headless CI / Eval Replay

For teams running claude -p or opencode run repeatedly on the same commit. Replays identical reruns at $0 (−45% / −72% cumulative after 2 / 4 runs on Claude Code; −45.5% over 3 runs on OpenCode). Saves 0% on one-off runs.

MCP Multiplexer (--multiplexer-only)

Pools multiple slow local stdio MCP servers across CLI sessions to cut boot latency and RAM. Adds ~1.4k schema tokens/turn; net-negative if you have no third-party stdio MCPs.

Local FTS5 Doc Index (docs_search)

Fast offline keyword lookup over local skills and CLAUDE.md (0.6 ms). For retrieval only — measured +20% to +24% higher cost when added to SWE-bench coding tasks.

Antigravity Hooks & Auditor

PreToolUse WAF gate (blocks .env / dangerous commands), disk-drift alerts, and toolrecall audit antigravity for local security and drift guards.

06 // 30-Second Setup

Drop into any Python agent loop.

Pick the integration that matches your runtime. Full CLI options are in the Reference Manual.

Option A — Python SDK / Shim

pipx install toolrecall
toolrecall setup --yes

# Or decorate custom tools directly:
from toolrecall.adapters import adk

@adk.cached_tool(ttl=300)
def inspect_repo(path: str) -> str:
    ...

Option B — Forward Proxy (Input Dedup)

export OPENAI_BASE_URL=http://localhost:8569/v1
# or for Anthropic-compatible loops:
export ANTHROPIC_BASE_URL=http://localhost:8569

# Auto-starts the local daemon on first request.