1- # AGENTS.md — Mux
1+ # AGENTS.md — Relay
22
33Universal LLM provider runtime. One interface for every model. Authentication, routing, streaming, retries, caching — handled.
44
@@ -10,7 +10,7 @@ When starting any new work (feature, fix, refactor, chore), always create a feat
1010
1111- ** Model-agnostic** — single interface for the 28 provider gateways in
1212 ` catalog/registry/providers.go ` (see README "Supported Providers")
13- - ** Host-neutral engine** — Mux owns provider routing, transport, caching,
13+ - ** Host-neutral engine** — Relay owns provider routing, transport, caching,
1414 retry/fallback, and normalized telemetry; hosts own product UX and semantics
1515- ** Streaming-first** — all responses are streamed; blocking is opt-in
1616
@@ -66,7 +66,7 @@ make ci # Full CI suite
6666 method set stable and use it across feature packages
6767- Streaming tests need careful goroutine management
6868- ` go.work ` here should stay minimal; the ` graycode-eco ` workspace connects
69- this independent ` mux ` checkout beside Decoder for local development.
69+ this independent ` relay ` checkout beside Decoder for local development.
7070 Do not add extra local ` replace ` directives here without coordinating with
7171 the parent workspace.
7272- There is usually ** no** ` go.work ` in the parent folder, and that is expected.
@@ -76,33 +76,33 @@ make ci # Full CI suite
7676 decoder against this checkout, use a gitignored module overlay in decoder instead —
7777 ` go test -modfile=go.local.mod ./... ` . See decoder/AGENTS.md
7878 "Workspace workflow" for the setup. Without that overlay, decoder compiles
79- against the * published* mux from the module cache, so a green decoder suite
80- does not exercise local mux changes at all.
79+ against the * published* relay from the module cache, so a green decoder suite
80+ does not exercise local relay changes at all.
8181
8282## Naming Conventions
8383
8484- ** Provider interface** : ` provider/core.Provider ` with ` Chat() ` , ` StreamChat() ` , ` Ping() ` , ` Name() `
85- - ** Core request types** : ` provider/core.MuxMessage ` , ` MuxResponse ` , ` MuxTool ` , ` MuxUsage `
86- - ** Config struct** : ` provider/core.MuxConfig ` with ` Provider ` , ` APIKey ` , ` BaseURL ` , ` Model ` , ` MaxRetries `
85+ - ** Core request types** : ` provider/core.RelayMessage ` , ` RelayResponse ` , ` RelayTool ` , ` RelayUsage `
86+ - ** Config struct** : ` provider/core.RelayConfig ` with ` Provider ` , ` APIKey ` , ` BaseURL ` , ` Model ` , ` MaxRetries `
8787- ** Provider implementations** : ` provider/adapters/anthropic.go ` (` AnthropicClient ` ), ` openai.go ` (` OpenAIClient ` ), ` gemini.go ` (` GeminiClient ` ), etc.
8888- ** Compatibility configs** : ` provider/adapters.OpenAICompat ` , ` GrokCompat ` , ` OpenRouterCompat `
89- - ** Error type** : ` MuxError ` with ` Provider ` , ` Op ` , ` StatusCode ` , ` RequestID ` , ` Message ` , ` Err ` fields
89+ - ** Error type** : ` RelayError ` with ` Provider ` , ` Op ` , ` StatusCode ` , ` RequestID ` , ` Message ` , ` Err ` fields
9090- ** Stream types** : ` StreamResult ` , ` SSEEvent ` , ` StreamEvent ` — streaming is SSE-based
9191- ** Retry config** : ` RetryConfig ` embeds ` types.RetryConfig ` + adds ` RetryOn []int ` for HTTP status codes
9292- ** Version wiring** : ` provider.Version ` set via ` SetVersion() ` from root package — avoids circular import
9393
9494## API Patterns
9595
9696- ** Provider auto-detection** : ` DetectProvider() ` checks env vars in priority order (ANTHROPIC_API_KEY, OPENAI_API_KEY, etc.)
97- - ** Client creation** : ` provider.NewMuxClient (&core.MuxConfig {...}) ` or ` provider.Client(&core.MuxConfig {...}) `
98- - ** Chat method** : ` c.Chat(ctx, messages, opts) ` — non-streaming, returns ` *MuxResponse `
97+ - ** Client creation** : ` provider.NewRelayClient (&core.RelayConfig {...}) ` or ` provider.Client(&core.RelayConfig {...}) `
98+ - ** Chat method** : ` c.Chat(ctx, messages, opts) ` — non-streaming, returns ` *RelayResponse `
9999- ** Stream method** : ` c.StreamChat(ctx, messages, opts) ` — returns ` *StreamResult ` , caller must ` defer sr.Close() `
100100- ** Auto-continuation** : ` StreamChatContinue() ` transparently retries when ` stop_reason == max_tokens `
101101- ** Provider fallback** : ` fallback.go ` implements fallback chains across providers
102102- ** Rate limiting** : ` ratelimit.go ` implements token bucket per provider — prevents hitting API limits
103103- ** Semantic caching** : ` semantic_cache.go ` caches similar prompts — optional, configurable TTL
104104- ** Retry with backoff** : ` retry.go ` — exponential backoff + jitter, respects ` Retry-After ` header, retries on 429/500/502/503/529
105- - ** Error hierarchy** : ` MuxError ` has ` IsRetriable() ` , ` IsAuthError() ` , ` IsRateLimited() ` methods for programmatic handling
105+ - ** Error hierarchy** : ` RelayError ` has ` IsRetriable() ` , ` IsAuthError() ` , ` IsRateLimited() ` methods for programmatic handling
106106- ** SSE parsing** : ` parseSSEStream() ` reads ` bufio.Scanner ` with 2MB buffer, emits ` SSEEvent ` to channel
107107
108108## Testing Patterns
@@ -125,17 +125,17 @@ make ci # Full CI suite
125125- ** Safe to refactor** : ` fallback.go ` , ` weighted.go ` — routing strategies, extend with new strategies
126126- ** Safe to refactor** : ` cost_estimator.go ` , ` cache_analytics.go ` — metrics and tracking
127127- ** Do not touch** : ` Provider ` interface (` Chat ` , ` StreamChat ` , ` Ping ` , ` Name ` ) — breaking change for all implementations
128- - ** Do not touch** : ` MuxMessage ` , ` MuxResponse ` , ` ChatOptions ` struct field names — serialization contract
129- - ** Do not touch** : ` MuxError ` struct — used by consumers for error type assertions
130- - ** Do not touch** : ` provider/core.MuxConfig ` — constructor contract for all consumers
128+ - ** Do not touch** : ` RelayMessage ` , ` RelayResponse ` , ` ChatOptions ` struct field names — serialization contract
129+ - ** Do not touch** : ` RelayError ` struct — used by consumers for error type assertions
130+ - ** Do not touch** : ` provider/core.RelayConfig ` — constructor contract for all consumers
131131- ** Safe to extend** : add new provider implementations, new SSE event types, new cache strategies
132132- ** When adding a provider** : create ` provider/<provider>.go ` , implement ` Provider ` interface, register in ` provider_registry.go `
133133
134134## Key File Locations
135135
136136| What | Where |
137137| ---| ---|
138- | Provider interface | ` provider/core/core.go ` (` Provider ` , ` MuxConfig ` , ` MuxMessage ` , ` ContentPart ` ) |
138+ | Provider interface | ` provider/core/core.go ` (` Provider ` , ` RelayConfig ` , ` RelayMessage ` , ` ContentPart ` ) |
139139| Chat implementation | ` provider/chat.go ` (` Chat() ` , ` StreamChat() ` , ` StreamChatContinue() ` ) |
140140| Host-facing engine facade | ` engine/ ` |
141141| Provider-neutral core | ` provider/core/ ` |
@@ -153,7 +153,7 @@ make ci # Full CI suite
153153| Caching | ` provider/cache/cache.go ` , ` provider/cache/semantic_cache.go ` |
154154| Fallback chains | ` router/router.go ` (fallback providers), ` router/deployment_router.go ` (fallback deployment stages) |
155155| Auto-continuation | ` provider/resilience/continuation.go ` |
156- | Error types | ` provider/core/errors.go ` (` MuxError ` , ` IsRetriable() ` , ` IsAuthError() ` ) |
156+ | Error types | ` provider/core/errors.go ` (` RelayError ` , ` IsRetriable() ` , ` IsAuthError() ` ) |
157157| Error constants | ` types/errors.go ` (API error messages, prompt-too-long parsing) |
158158| Model catalog | ` catalog/ ` (pricing, context windows, capabilities per provider) |
159159| Credentials | ` credentials/ ` (key storage, env detection, scrubbing) — ` HasSecret ` is silent on miss (boolean predicate); ` LookupSecret ` logs ` Debug ` on ` ErrNotFound ` and ` Warn ` on real backend errors |
@@ -162,6 +162,6 @@ make ci # Full CI suite
162162| Linter config | ` .golangci.yml ` (govet, ineffassign, misspell — minimal) |
163163
164164This is an independent repository consumed by Decoder. In the local
165- ` graycode-eco ` parent workspace it is checked out beside ` decoder ` as ` ../mux `
165+ ` graycode-eco ` parent workspace it is checked out beside ` decoder ` as ` ../relay `
166166and connected through the parent ` go.work ` ; publish changes here, then update
167167Decoder's module pin through a separate PR.
0 commit comments