Skip to content

docs(adr): 0006 — Runtime contract (v1) [closes #214]#274

Open
EmersonBraun wants to merge 1 commit intomainfrom
foundation/adr-0006-runtime
Open

docs(adr): 0006 — Runtime contract (v1) [closes #214]#274
EmersonBraun wants to merge 1 commit intomainfrom
foundation/adr-0006-runtime

Conversation

@EmersonBraun
Copy link
Copy Markdown
Owner

Summary

Sixth and final core-contract ADR of Phase 0. The Runtime is the conductor of the substrate — where Adapter, Tool, Memory, Retriever, and Skill compose into an actual agent loop.

14 invariants (RT1-RT14) covering construction, the loop bound, resolution rules, confirmation, memory atomicity, retrieval, observers, delegation, errors, and abort.

This PR closes #214 (the 6 core contract ADRs).

Builds on #267, #270, #271, #272, #273.

Merge order: #267#270#271#272#273#274 (rebase each on main as merged; conflicts only on the ADR README index).

The substrate is now formal

ADR What Role
0001 Adapter LLM provider seam
0002 Tool Function the model calls
0003 Memory Chat history + vector store + embed
0004 Retriever Context fetching
0005 Skill Declarative persona
0006 Runtime The loop that composes them all

Highlight invariants

  • RT1 Construction is config onlycreateRuntime does no I/O, no surprise side effects on import
  • RT2 One entry pointrun(task, options). No start/init/step. Streaming via observers.
  • RT3 Options override config, never silently merge — debuggable resolution order
  • RT4 Hard maxSteps cap — non-negotiable. Every "infinite loop bug" in agent libs traces to a soft cap.
  • RT5 Tool resolution well-defined — option > config > skill-derived; missing tool → error chunk, not throw
  • RT6 Confirmation refuse-by-default — no auto-approve timeout (matches Tool T9)
  • RT7 Memory atomic at run boundary — failed runs don't save (preserves CM4)
  • RT8 Retrieval per-turn, not per-step — deliberate v1 simplification
  • RT9 Observers read-only — mutating logic = wrapper runtime, not observer
  • RT10 Delegation is a tool — unifies model's mental model; no special syntax
  • RT11 Bounded delegation depth — behavioral cap (delegates not even offered at limit)
  • RT13 Abort is prompt and clean — abort stream, skip save, reject with AbortError
  • RT14 Errors are categorized — adapter/tool/confirmation/memory/programmer; enables fallbacks ([F2] #34 — Declarative adapter fallback chain #147), self-debug ([F3] #64 — Memory adapters (pgvector, Pinecone, Qdrant, etc.) #177), durable execution ([F2] #43 — Durable execution (Temporal-style) #156)

Forward-compat carve-outs in v1.x (no v2 needed)

Trade-offs accepted

  • No per-step retrieval in v1 (custom runtime or tool-shaped retriever for ReAct-style)
  • No mutating middleware — wrap the runtime instead
  • Delegation depth is global, not per-branch (simpler, occasionally wasteful)
  • Tools don't receive abort signal (in Open Questions; v1.x add)

Unlocks

Test plan

  • Doc renders on GitHub
  • ADR index updated, all 6 contracts marked Accepted
  • No code changes — pure documentation
  • Reviewer: 14 invariants match packages/runtime/src/runner.ts and packages/core/src/agent-loop.ts?
  • Reviewer: forward-compat carve-outs cover the upcoming features (durability, replay, topologies)?
  • Reviewer: any invariant that would block a real runtime variant?

Closes #214
Refs #211

The conductor of the substrate. Where Adapter/Tool/Memory/Retriever/Skill
compose into an actual agent loop. 14 invariants (RT1-RT14).

Key decisions:
- One entry point: run(task, options) — no start/init/step
- Construction is config-only, no I/O at createRuntime (RT1)
- Hard maxSteps cap, never soft (RT4) — fixes universal regret pattern
- Confirmation refuse-by-default (RT6) — no auto-approve timeout
- Memory atomic at run boundary (RT7) — failed runs do not save
- Per-turn retrieval, not per-step (RT8) — simplification with escape hatch
- Observers read-only (RT9) — mutating logic uses wrapper runtimes
- Delegation as tool (RT10) — unifies the model's mental model
- Bounded delegation depth (RT11) — behavioral cap, not just counter
- Categorized errors (RT14) — adapter / tool / confirmation / memory / programmer
  enabling fallbacks, self-debug, durable execution

Forward-compat carve-outs in v1.x (additive, no v2 needed):
- Durability checkpoints (#156)
- Replay hooks (#134)
- Multi-agent topology helpers (#157)

This is the 6th and final core contract ADR. The substrate is now formal:

  ADR 0001 Adapter   - LLM provider seam
  ADR 0002 Tool      - executable function the model calls
  ADR 0003 Memory    - chat history + vector store + embed
  ADR 0004 Retriever - context fetching, single narrow interface
  ADR 0005 Skill     - declarative persona configuration
  ADR 0006 Runtime   - the loop that composes them all

Closes #214
EmersonBraun added a commit that referenced this pull request Apr 14, 2026
Reframes the README from a generic 'complete toolkit' pitch to an
opinionated, honest, story-driven entry point.

What's new:
- Tagline 'The agent toolkit JavaScript actually deserves' — opinion,
  not buzzwords
- 'Why this exists' section linking to ORIGIN.md and MANIFESTO.md
- 'Before and after' section showing the typical cobbled stack vs
  AgentsKit's two-import equivalent
- Honest 'When you should NOT use AgentsKit' section — directs people
  to single-OpenAI-call, Vercel AI SDK for chat-only, Python frameworks,
  mature observability platforms, or pre-1.0 caution
- Comparison table now includes formal contracts row and edge-readiness
- Stability tier column on the ecosystem table
- Architecture and contracts section linking the six ADRs
- 'For AI agents reading this' section — first-class doc consumers
- Status section linking Phase 0 and Master PRDs
- agentskit.io as canonical docs URL

What's preserved and tightened:
- Quickstart in 10 lines (single example, not three competing)
- Multi-agent delegation example
- Provider swap demonstration
- Terminal chat (Ink) callout

Aligns with stories #224 (README rewrite) and #16 (honest comparison
incl. when NOT to use). Builds on Manifesto + Origin (#265) and the
six contract ADRs (#267-#274).

Refs #224 #16 #211
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P0.3] ADRs for 6 core contracts (Adapter/Tool/Memory/Retriever/Skill/Runtime)

1 participant