AGENTS.md
open-sse/services/AGENTS.mdAGENTS.md
Quality
52/100
Scores the file, not the repository.Length
515 words
11 headings · 0 code blocksRepository
38k
— · pushed 0 days agoLast changed
3 days ago
First indexed 3 days ago.1# open-sse/services/ — Routing Engine & Cross-Cutting Services23**Purpose**: 134 service modules (top-level) powering request routing, rate limiting, quota management, token refresh, fallback strategies, and runtime state. The combo routing engine (`combo.ts`) is the core; supporting services handle resilience, accounting, and decision-making.45Live count: `ls open-sse/services/*.ts | wc -l` (currently 134). More including sub-dirs like `autoCombo/` and `compression/`.67---89## Combo Routing Engine1011- **`combo.ts`** — Entry point for multi-model routing. **`handleComboChat()`** iterates through targets in order until success or all fail. **`resolveComboTargets()`** expands combo config into ordered `ResolvedComboTarget[]` (provider + model + account + credentials).12- **Strategies** (17): `priority`, `weighted`, `fill-first`, `round-robin`, `P2C`, `random`, `least-used`, `reset-aware`, `reset-window`, `cost-optimized`, `strict-random`, `auto`, `lkgp`, `context-optimized`, `context-relay`, `headroom`, `fusion`. Source: `ROUTING_STRATEGY_VALUES` in `src/shared/constants/routingStrategies.ts`.13- Each target calls **`handleSingleModel()`** which wraps `handleChatCore()` with per-target error handling and circuit breaker checks.1415## Key Services1617### Quota & Rate Limiting1819- **`rateLimitManager.ts`** — Token bucket per API key + provider combo. Rejects before dispatch.20- **`usage.ts`** — Per-request token/cost consumption tracking.21- **`quotaCache.ts`** — In-memory quota snapshots, pre-loaded at startup.2223### Account & Token Management2425- **`tokenRefresh.ts`** — OAuth token expiration detection and refresh.26- **`accountFallback.ts`** — Account switching on quota/rate-limit. Also houses model lockout.27- **`sessionManager.ts`** — Request session state across retries.2829### Request Routing & Intelligence3031- **`wildcardRouter.ts`** — Wildcard route matching in combo configs.32- **`intentClassifier.ts`** — Request intent classification for intelligent routing.33- **`taskAwareRouter.ts`** — Task-type-based routing (reasoning → o1, code-gen → Cursor).34- **`targetRequestSanitizer.ts`** — Final provider/model-aware parameter sanitation after routing resolution and before executor dispatch.35- **`thinkingBudget.ts`** — Thinking token allocation for o1/o3 models.36- **`contextManager.ts`** — Routing context injection (system prompts, memory).3738### Model Lifecycle & Fallback3940- **`modelDeprecation.ts`** — Deprecated model detection and successor routing.41- **`modelFamilyFallback.ts`** — T5 intra-family fallback chains.42- **`emergencyFallback.ts`** — Last-resort fallback to stable free providers.4344### State & Detection4546- **`workflowFSM.ts`** — Multi-turn workflow state machine.47- **`backgroundTaskDetector.ts`** — Long-running task detection for batch routing.48- **`ipFilter.ts`** — IP-based routing rules.49- **`signatureCache.ts`** — Request signature caching for deduplication.50- **`volumeDetector.ts`** — Volume spike detection for rate-limit escalation.51- **`contextHandoff.ts`** — Session context serialization for A2A handoff.5253### Prompt Compression Pipeline (`compression/`)5455- **`strategySelector.ts`** — Compression mode selection (off/lite/standard/aggressive/ultra/rtk/stacked).56- **`lite.ts`** — 5 lite techniques (whitespace, dedup, tool results, redundant removal, image URLs).57- **`caveman.ts` / `cavemanRules.ts`** — Caveman-style semantic condensation with rule packs.58- **`engines/rtk/`** — RTK tool-output compression (command detection, JSON filters, dedup, truncation).59- **`engines/registry.ts`** — Engine registry for standalone and stacked pipelines.60- **`stats.ts`** — Per-request compression stats.61- **`types.ts`** — Shared types (`CompressionMode`, `CompressionConfig`, `CompressionStats`).6263---6465## Adding a New Service66671. Create `open-sse/services/[serviceName].ts`682. Export main handler function693. Add unit tests in `tests/unit/services/`704. Integrate into `handlers/chatCore.ts` (if routing-related) or `combo.ts`715. Document in this file7273## Anti-Patterns7475- Synchronous DB calls in `combo.ts` hot path — pre-compute and cache76- Retry logic in handlers — use `retry()` from resilience service77- Direct provider config access — use `providerRegistry` getter functions78- Hardcoded fallback chains — define in `modelFamilyFallback.ts`79- State mutations across concurrent requests — use request-scoped context only80
Also in diegosouzapw/OmniRoute
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| diegosouzapw/OmniRoute.github/copilot-instructions.md · 38k | Copilot instructions | teststyletesting-strategygit+1 | 46/100 | 3 days ago | |
| diegosouzapw/OmniRouteAGENTS.md · 38k | AGENTS.md | buildtestlint-formatstyle+12 | 84/100 | 3 days ago | |
| diegosouzapw/OmniRouteCLAUDE.md · 38k | CLAUDE.md | setupbuildtestlint-format+9 | 84/100 | yesterday | |
| diegosouzapw/OmniRouteGEMINI.md · 38k | GEMINI.md | testlint-formatarchsecurity+2 | 87/100 | 3 days ago | |
| diegosouzapw/OmniRoutesrc/lib/db/AGENTS.md · 38k | AGENTS.md | stylearchsecuritydatabase | 72/100 | 3 days ago |
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| mui/material-uiAGENTS.md · 99k | AGENTS.md | setupbuildtestlint-format+9 | 100/100 | 3 days ago | |
| TryGhost/Ghoste2e/AGENTS.md · 55k | AGENTS.md | setupteststylearch+2 | 100/100 | 3 days ago | |
| code-yeongyu/oh-my-openagentpackages/web/AGENTS.md · 67k | AGENTS.md | setupbuildtestlint-format+6 | 100/100 | 2 days ago | |
| duckduckgo/content-scope-scriptsspecial-pages/AGENTS.md · 70 | AGENTS.md | buildteststylearch+3 | 100/100 | 3 days ago | |
| SkeneTechnologies/skene-cookbookAGENTS.md · 51 | AGENTS.md | setupbuildtestlint-format+7 | 100/100 | 2 days ago | |
| n8n-io/n8npackages/@n8n/agents/AGENTS.md · 199k | AGENTS.md | buildteststylearch+3 | 100/100 | 3 days ago | |
| aaif-goose/gooseAGENTS.md · 52k | AGENTS.md | setupbuildtestlint-format+6 | 100/100 | 3 days ago | |
| elastic/elasticsearchx-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/AGENTS.md · 78k | AGENTS.md | buildtestlint-formatstyle+2 | 100/100 | 3 days ago |
