Skip to content

docs(adr): 0001 — Adapter contract (v1)#267

Merged
EmersonBraun merged 1 commit intomainfrom
foundation/adr-0001-adapter
Apr 14, 2026
Merged

docs(adr): 0001 — Adapter contract (v1)#267
EmersonBraun merged 1 commit intomainfrom
foundation/adr-0001-adapter

Conversation

@EmersonBraun
Copy link
Copy Markdown
Owner

Summary

First ADR of Phase 0 — formalizes the Adapter contract that has been implicit in packages/core/src/types/adapter.ts.

What's included

  • docs/architecture/adrs/0001-adapter-contract.md — the contract itself: 4 types + 10 invariants (A1-A10), stability tier (stable), rationale, consequences, alternatives considered, and open questions.
  • docs/architecture/adrs/README.md — ADR process (what, when, format, index).

Why this matters

Before Fase 3 adds 10+ new adapters (Mistral, Cohere, Groq, Bedrock, xAI/Grok, local models via Ollama/llama.cpp, etc.), we need a verifiable contract. Today "plug-and-play" is aspirational. After this ADR:

Key invariants (the important ones)

  • A1 Pure factorycreateSource does no work until stream() is called (enables retry/replay)
  • A3 Terminal chunk — every stream ends with done, error, or caller-initiated abort (no silent endings)
  • A4 Chunk purity — text chunks are meaningful in isolation (unlocks speculative execution)
  • A7 No input mutation — required for replay and ensemble
  • A9 Error-as-chunk — failures do not throw from stream(), they emit a chunk

Trade-offs made explicit

  • Partial-args tool calling deferred to a v2 ADR — v1 requires complete args in a single chunk
  • metadata is untyped (Record<string, unknown>) — provider-specific data lives there, consumers must not depend on its shape
  • Cost/token counting intentionally NOT in the contract — belongs in observability layer

Follow-ups (tracked in #214)

  • ADR 0002 — Tool contract
  • ADR 0003 — Memory contract
  • ADR 0004 — Retriever contract
  • ADR 0005 — Skill contract
  • ADR 0006 — Runtime contract

Test plan

  • Doc renders on GitHub
  • ADR index updated
  • No code changes — pure documentation
  • Reviewer: agree A1-A10 match current adapters in packages/adapters?
  • Reviewer: any invariant missing or too strong?

Refs #214 #211

Promotes the implicit adapter contract in packages/core/src/types/adapter.ts
to a formal, versioned artifact. Defines 10 invariants (A1-A10) that every
conformant adapter must satisfy, covering:

- Pure factory construction (no work until stream() is called)
- Single iteration per StreamSource
- Explicit terminal chunks (done | error | caller abort)
- Chunk purity for speculative execution and streaming
- Tool-call atomicity (deferring partial-args streaming to a future ADR)
- Safe abort at any point
- No input mutation (required for replay and ensemble adapters)
- Error-as-chunk, not throw
- Closed-over configuration at construction time

Also adds docs/architecture/adrs/README.md with ADR process and index
listing the five follow-up contracts tracked in #214.

Refs #214
@EmersonBraun EmersonBraun merged commit eafae62 into main Apr 14, 2026
1 check failed
@EmersonBraun EmersonBraun deleted the foundation/adr-0001-adapter branch April 14, 2026 17:14
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
EmersonBraun added a commit that referenced this pull request Apr 15, 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.

1 participant