Add health-aware routing and content-safe observability - #5
Conversation
|
Warning Review limit reached
Next review available in: 51 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Summary by CodeRabbit
WalkthroughUnifiedLLM now tracks provider health, applies transient-failure cooldowns, exposes health snapshots, and emits sanitized attempt callbacks. Configuration supports constructor and environment values. Tests, documentation, exports, and an observability example cover the new behavior. ChangesProvider health and attempt observability
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Application
participant UnifiedLLM
participant Provider
participant BackupProvider
participant on_attempt
Application->>UnifiedLLM: submit generation request
UnifiedLLM->>Provider: execute route attempt
Provider-->>UnifiedLLM: return transient failure
UnifiedLLM->>on_attempt: emit sanitized Attempt
UnifiedLLM->>BackupProvider: execute fallback route
BackupProvider-->>UnifiedLLM: return successful response
UnifiedLLM->>on_attempt: emit successful Attempt
UnifiedLLM-->>Application: return response
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.env.example:
- Around line 16-17: Reorder the environment configuration keys so
UNIFIED_LLM_HEALTH_COOLDOWN appears before UNIFIED_LLM_HEALTH_FAILURE_THRESHOLD,
and place both health keys before UNIFIED_LLM_MAX_ATTEMPTS_PER_ROUTE in the
.env.example configuration.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 2649c9c7-64fc-4364-b108-4697e48f8a2a
📒 Files selected for processing (12)
.env.exampleCHANGELOG.mdREADME.mdROADMAP.mddocs/API.mddocs/ARCHITECTURE.mdexamples/observability.pytests/test_configuration.pytests/test_health_observability.pytests/test_router.pyunified_llm/__init__.pyunified_llm/unified_llm.py
Outcome
Adds content-safe observability and cross-request provider health without adding exporters, persistence, or gateway infrastructure.
on_attemptcallback receives only immutable sanitizedAttemptmetadataprovider=selection can probe immediately and successful probes reset healthProviderHealthsnapshots and environment configurationVerification
python -m ruff format --check .python -m ruff check .python -m mypy unified_llm tests examplespython -m pytest --cov=unified_llm --cov-report=term-missing(118 passed, 94.73% coverage)python examples/observability.pypython -m build --no-isolationRollback
Revert commit
e9cd70b; bounded routing and both HTTP adapters remain independently available.