Runtime Overview (The “Lego Bricks”)
Most patterns are compositions of a few reusable runtime capabilities:
- Messages: a minimal chat format (
system/user/assistant/tool). - Model interface: a single
complete(messages) -> str. - Structured output: parse + validate JSON with repair retries.
- Tool calling: register tools and call them with tracing.
- Loop controller:
max_stepsbudget and deterministic termination. - Retrieval: a local index for offline RAG demos/tests.
- Memory: KV + session stores (offline-first).
- Reliability wrappers: retry/backoff, fallback, circuit breaker.
- Governance: tool policy, guardrails, HITL approval.
- Observability: tracing + eval harness.
Why a Minimal Runtime Matters
- Makes patterns comparable (same input/output discipline).
- Makes testing offline and deterministic (via
MockLLM). - Keeps the repo framework-free (no LangChain/LangGraph).
Where It Lives in This Repo
- Types + messages:
src/agent_patterns_lab/runtime/types.py - Model protocol + MockLLM:
src/agent_patterns_lab/runtime/model.py,src/agent_patterns_lab/runtime/mock_model.py - Structured output:
src/agent_patterns_lab/runtime/structured.py - Tools:
src/agent_patterns_lab/runtime/tools.py - Loop controller:
src/agent_patterns_lab/runtime/runner.py - Tracing:
src/agent_patterns_lab/runtime/tracing.py - Reliability:
src/agent_patterns_lab/runtime/reliability.py - Cache:
src/agent_patterns_lab/runtime/cache.py - Memory:
src/agent_patterns_lab/runtime/memory/ - Governance:
src/agent_patterns_lab/runtime/policy.py,src/agent_patterns_lab/runtime/guardrails.py,src/agent_patterns_lab/runtime/hitl.py - Eval harness:
src/agent_patterns_lab/runtime/evals/