Phase 2.5 — Provider Generalization & Foundation

Generalize the single-provider proxy into a pluggable, multi-backend platform before building the memory engine.

Phase 2.5 — Provider Generalization & Foundation

What Phase 2.5 Delivers

Phase 2 proved an OpenAI-compatible proxy works end-to-end. Phase 2.5 widens the foundation so that Phase 3's memory engine, Phase 3.5's context assembly, and Phase 4's multi-provider routing all build on proven abstractions instead of inventing them under pressure. Every track in this phase creates a seam that a later phase fills with real logic — the same "build the plumbing before the thing that uses it" pattern that made Phase 1 (auth/proxy skeleton) a clean foundation for Phase 2 (real forwarding).

Phase 2.5 Scope

Seven tracks

TrackThemeKey Deliverable
AMulti-provider adaptersAnthropic adapter proving Provider interface generalizes; model capability registry
BTokenizer registryPer-model token counting via Hugging Face tokenizers (CGo in proxy, Python service for context assembly)
CResponse-side processingResponsePipeline stage interface; typed decode/re-encode of upstream responses; streaming design ADR
DPluggable embedding serviceEmbedder interface + registry; TEI GPU backend, hosted OpenAI/Cohere backends, content-hash cache (CPU MiniLM stub)
ESchema pre-workTemporal validity columns, multi-label category support, relationship graph index — migrations only, no application code
FMCP server skeletonAuth-boundary-scoped MCP server exposing stub memory tools; resource-server auth via AuthService.ValidateToken
GExit / ops pack-upLocal LGTM observability, verify-phase25, thin K8s observability chart, roadmap sign-off
Track A (Multi-provider — start immediately):
 2.5.G1.M1 (Anthropic adapter) → 2.5.G1.M2 (capability registry) → 2.5.G1.M3 (self-hosted vLLM adapter)

Track B (Tokenizer — blocks context assembly):
 2.5.G2.M1 (tokenizer registry)

Track C (Response pipeline — seam for Phase 3 guardrails):
 2.5.G3.M1 (non-streaming response middleware) → 2.5.G3.M2 (streaming design spike / ADR)

Track D (Embedding — blocks memory writes):
 2.5.G4.M1 (Embedder interface + registry) → 2.5.G4.M2 (TEI backend)
 → 2.5.G4.M3 (hosted-API backend) → 2.5.G4.M4 (content-hash cache)

Track E (Schema — parallel with A/B):
 2.5.G5.M1 (temporal validity) → 2.5.G5.M2 (multi-label categories)
 → 2.5.G5.M3 (relationship graph index)

Track F (MCP skeleton — after A):
 2.5.G6.M1 (MCP server with stub tools)

Track G (Exit / ops — after A–F):
 2.5.G7 (exit gate, LGTM observability, verify-phase25)

Tech Stack Additions

ConcernChoiceReason
Response pipeline typed modelGo structs mirroring OpenAI chat response shape, in packages/responsepipelineKeeps decode/re-encode in the proxy's hot language
Embedding backend abstractionPython ABC (EmbeddingBackend), profile selected by EMBEDDER_PROFILE env at startupMirrors the proven provider.Provider/Registry pattern
Default production embedding modelBAAI/bge-m3 (1024-dim)Best available open retrieval-tuned model; multilingual + long-context
CPU MiniLM profileStub only (ADR-0046); real CPU path deferredAvoid shipping an unfinished local transformer path as a “real” backend
Embedding serving runtime (GPU)Hugging Face TEI (Apache-2.0)Eliminates hand-rolled batching code entirely
Hosted embeddingsOpenAI and/or Cohere HTTP backendsSecond real backend family for contract parity without GPU
MCP SDKOfficial mcp Python SDKTracks an evolving spec
MCP authReuse existing AuthService.ValidateToken gRPCOne identity system, not two
Local observabilityPrometheus + Grafana + Tempo + Loki + OTel Collector (compose)Pull-forward for Phase 2.5 exit (ADR-0051); HA platform remains later

Exit Criteria

  1. Anthropic adapter passes the same streaming/non-streaming/error-mapping test depth as the OpenAI adapter
  2. Registry.For(model) resolves both OpenAI and Anthropic models without handler/middleware changes
  3. ModelCapability struct queryable for context window, tool support, and tokenizer family
  4. Response pipeline decode/re-encode round trip is byte-for-byte identical to passthrough (zero stages) with p99 overhead < 2ms
  5. Embedder interface has at least two real backends (TEI + hosted OpenAI or Cohere) passing the same contract test suite (CPU MiniLM remains stub)
  6. All three schema migrations (temporal validity, multi-label, relationship graph index) apply cleanly via make db-migrate
  7. MCP server passes official MCP conformance against stub handlers with auth validated via gRPC
  8. All Phase 1 and Phase 2 tests still pass with zero regressions
  9. Local LGTM observability stack is operable (make observability-up / make observability-smoke) with Proxy Critical Path dashboard
  10. make verify-phase25 exits 0 (phase pack-up gate)
Edit on GitHub

Last updated on

On this page

0%