Repository navigation
Description
Context
The intended role of llm-providers is provider abstraction: normalize Anthropic, OpenAI, Groq, Cerebras, NVIDIA, Cloudflare Workers AI, and future vendor-specific request/response shapes into one StackBilt execution contract.
This matters for AEGIS CLI and llm-gateway: Codex/Claude/Ollama-style clients may speak different wire protocols, but downstream routing should be based on task capability and model catalog metadata, not vendor-shaped request objects.
Desired Outcome
Define and harden a canonical provider request/response contract that captures the capabilities StackBilt needs independent of vendor API shape.
The contract should support at least:
- normalized messages and system prompt
- tool schemas and tool choice
- structured output / JSON response format
- streaming and non-streaming output
- vision/media inputs where supported
- use-case metadata such as
TOOL_CALLING,LONG_CONTEXT,COST_EFFECTIVE,VISION,BALANCED - provider/model capability checks
- normalized tool-call and tool-result semantics
- normalized errors/fallback metadata
- normalized usage/cost/latency metadata
Acceptance Criteria
- There is a documented canonical
LLMRequestandLLMResponseboundary that is not Anthropic-shaped or OpenAI-shaped by default. - Provider adapters translate from the canonical request into vendor-specific APIs.
- Provider responses translate back into one canonical response shape.
- Tool calling behavior is explicitly marked by capability, including graceful degradation where a provider cannot preserve a requested tool protocol.
- Model selection remains catalog-driven through
MODEL_CATALOG/rankModels, not hardcoded in gateway clients. - Tests cover at least OpenAI-compatible, Anthropic-compatible, Groq/Cerebras, NVIDIA, and Cloudflare Workers AI paths where available.
Notes
This is the foundation for running AEGIS/Codex-style harnesses primarily through NVIDIA, Cerebras, Groq, and Cloudflare Workers AI without depending on Anthropic API as the default backend.
Activity
stackbilt-admin commentedon Jun 5, 2026
Related gateway implementation issue: Stackbilt-dev/llm-gateway#4
stackbilt-admin commentedon Jun 5, 2026
Reviewing current
main, I think this issue is valid and should stay open. The repo has good primitives already, but the canonical boundary is still partly implicit and partly mixed with provider/client dialects.Findings:
LLMRequest/LLMResponseexist, butLLMRequestis still partly vendor-shaped.toolChoiceandresponse_formatmirror OpenAI-style wire naming/shape, while provider-specific knobs likelora,topP,frequencyPenalty,reasoning, andpredictionlive directly on the canonical request surface. This makes the boundary harder forllm-gatewayto target as a truly provider-neutral contract.LLMResponsehas a genericmetadata?: Record<string, unknown>, and provider adapters attach provider-specific metadata. Factory fallback is mostly hook-based rather than expressed in a normalized response contract, so callers do not get a stable shape for fallback chain, degradation, selected provider/model reason, or unsupported capability handling.Already covered / useful foundation:
MODEL_CATALOG/rankModels; this part is aligned with the desired architecture.Recommended implementation lane:
Baseline checked locally on
main:npm testpasses, 19 test files / 421 tests.stackbilt-admin commentedon Jun 5, 2026
Specific guidance for the implementation session:
Treat this as an additive hardening pass, not a breaking rewrite. The win is to make the canonical boundary explicit and testable while preserving current
LLMRequest/LLMResponsecallers as compatibility input.Recommended first PR shape
src/canonical.tsor a clearly marked section ofsrc/types.ts.LLMRequestinto the canonical request shape.response_format,toolChoice,lora,topP,frequencyPenalty,reasoning, orpredictionyet.Canonical request target
The canonical center should be capability-oriented, not vendor-oriented. Suggested shape:
Exact names can change. The important part is that OpenAI wire names like
response_formatand provider knobs likeloraare aliases into the canonical shape, not the canonical shape itself.Canonical response target
Add stable response metadata instead of relying on open-ended
metadata.Tests to add first
LLMRequesttoCanonicalLLMRequest.response_formatmaps tooutput.toolChoicemaps totoolMode.lora,topP,frequencyPenalty,reasoning, andpredictionland underproviderOptions.Non-goals for the first pass
Gateway handoff
Once this lands,
llm-gateway#4should consume the canonical normalizer and stop constructing provider-shaped requests itself. Gateway should only translate client protocols into the canonical request, then delegate selection/execution tollm-providers.