|
| 1 | +# Agentic Kit Redesign Decisions |
| 2 | + |
| 3 | +Date: 2026-04-18 |
| 4 | + |
| 5 | +This document records the redesign decisions made while evaluating `agentic-kit` |
| 6 | +against the comparable `pi-mono` architecture, especially `packages/ai` and |
| 7 | +`packages/agent`. |
| 8 | + |
| 9 | +## Scope and Package Boundaries |
| 10 | + |
| 11 | +1. `agentic-kit` remains the low-level provider portability layer. |
| 12 | +2. Stateful orchestration moves into a separate `@agentic-kit/agent` package. |
| 13 | +3. Tool execution stays out of `agentic-kit` core; the core only models tools, |
| 14 | + tool calls, and tool results. |
| 15 | +4. `@agentic-kit/agent` v1 should be intentionally minimal, shipping only the |
| 16 | + sequential tool loop, lifecycle events, abort/continue, and pluggable context |
| 17 | + transforms. Steering/follow-up queues and richer interruption policies are |
| 18 | + deferred to phase 2. |
| 19 | + |
| 20 | +## Core Type System |
| 21 | + |
| 22 | +5. Core tool definitions use plain JSON Schema. |
| 23 | +6. TypeBox/Zod support stays as helper adapters, not the core contract. |
| 24 | +7. Core models are represented by a provider-independent `ModelDescriptor` |
| 25 | + registry with capability metadata. |
| 26 | +8. The model registry must support both built-in descriptors and runtime |
| 27 | + registration of custom models/providers from day one. |
| 28 | +9. The core message model treats `image` input and `thinking` output as |
| 29 | + first-class content blocks in v1. |
| 30 | +10. `usage`, `cost`, `stopReason`, and abort-driven partial-result semantics are |
| 31 | + mandatory parts of the core contract in v1. |
| 32 | + |
| 33 | +## Streaming and Conversation Semantics |
| 34 | + |
| 35 | +11. Structured event streams become the primary streaming primitive; text-only |
| 36 | + chunk callbacks remain as convenience wrappers. |
| 37 | +12. Cross-provider replay and handoff is a hard requirement for v1, including |
| 38 | + normalization for reasoning blocks, tool-call IDs, aborted turns, and |
| 39 | + orphaned tool results. |
| 40 | + |
| 41 | +## Provider Strategy |
| 42 | + |
| 43 | +13. OpenAI-compatible backends should be handled by one generalized adapter path |
| 44 | + with compatibility flags, not many first-class provider packages. |
| 45 | +14. Embeddings stay out of the primary conversational core and live behind a |
| 46 | + separate optional capability interface or companion package. |
| 47 | + |
| 48 | +## Migration Strategy |
| 49 | + |
| 50 | +15. `agentic-kit` should ship a backward-compatibility layer for the current |
| 51 | + `generate({ model, prompt }, { onChunk })` API for one transition release. |
| 52 | + |
| 53 | +## Architectural Implications |
| 54 | + |
| 55 | +These decisions imply the following target architecture: |
| 56 | + |
| 57 | +- `agentic-kit` |
| 58 | + Low-level portability layer. Owns message/content types, model descriptors, |
| 59 | + provider registry, streaming event protocol, compatibility transforms, usage, |
| 60 | + and provider adapters. |
| 61 | +- `@agentic-kit/agent` |
| 62 | + Optional stateful runtime. Owns tool execution, sequential loop semantics, |
| 63 | + lifecycle events, context transforms, and abort/continue behavior. |
| 64 | +- Separate optional capabilities or companion packages |
| 65 | + For non-conversational workloads such as embeddings, and optional schema |
| 66 | + helpers such as TypeBox/Zod integration. |
| 67 | + |
| 68 | +## Design Principles Confirmed |
| 69 | + |
| 70 | +- Keep the protocol portable and runtime-agnostic. |
| 71 | +- Normalize provider differences in the core instead of leaking them upward. |
| 72 | +- Treat OpenAI-compatible APIs as a compatibility class, not a brand-specific |
| 73 | + architecture. |
| 74 | +- Avoid coupling the low-level layer to any single schema library or vendor SDK. |
| 75 | +- Preserve a migration path from the existing text-only API while moving the |
| 76 | + real architecture to structured messages and events. |
0 commit comments