Skip to content

Add health-aware routing and content-safe observability - #5

Merged
Deathcharge merged 2 commits into
mainfrom
codex/health-observability
Aug 8, 2026
Merged

Add health-aware routing and content-safe observability#5
Deathcharge merged 2 commits into
mainfrom
codex/health-observability

Conversation

@Deathcharge

Copy link
Copy Markdown
Owner

Outcome

Adds content-safe observability and cross-request provider health without adding exporters, persistence, or gateway infrastructure.

  • sync/async on_attempt callback receives only immutable sanitized Attempt metadata
  • observer failures are isolated while cancellation still propagates
  • transient failures maintain provider-local health and bounded cooldown state
  • cooling routes move behind healthy routes but remain last-resort fallbacks
  • explicit provider= selection can probe immediately and successful probes reset health
  • exposes content-free ProviderHealth snapshots and environment configuration

Verification

  • python -m ruff format --check .
  • python -m ruff check .
  • python -m mypy unified_llm tests examples
  • python -m pytest --cov=unified_llm --cov-report=term-missing (118 passed, 94.73% coverage)
  • python examples/observability.py
  • python -m build --no-isolation

Rollback

Revert commit e9cd70b; bounded routing and both HTTP adapters remain independently available.

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Deathcharge, you've reached your PR review limit, so we couldn't start this review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 7d592b3a-8157-481d-9217-ef5223ebcb8c

📥 Commits

Reviewing files that changed from the base of the PR and between e9cd70b and 1107a17.

📒 Files selected for processing (1)
  • .env.example

Summary by CodeRabbit

  • New Features

    • Added provider health monitoring with configurable failure thresholds and cooldown periods.
    • Temporarily deprioritizes repeatedly failing providers while preserving fallback behavior.
    • Added provider health inspection and sanitized attempt notifications for observability.
    • Added environment-variable configuration for health settings.
    • Assistant responses can now include tool calls for function continuation.
  • Documentation

    • Updated API, architecture, README, changelog, roadmap, and examples with health and observability guidance.
  • Tests

    • Added coverage for cooldown, recovery, configuration validation, callback isolation, and route behavior.

Walkthrough

UnifiedLLM 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.

Changes

Provider health and attempt observability

Layer / File(s) Summary
Health contracts and configuration
unified_llm/unified_llm.py, unified_llm/__init__.py, .env.example, tests/test_configuration.py, tests/test_router.py, docs/API.md, README.md
UnifiedLLM adds health configuration, ProviderHealth, AttemptHook, environment parsing, health inspection, validation, and public exports. API documentation also describes tool-call assistant messages.
Cooldown routing and recovery
unified_llm/unified_llm.py, tests/test_health_observability.py, README.md, docs/ARCHITECTURE.md, CHANGELOG.md, ROADMAP.md
Retryable failures increment provider health, open cooldowns, reorder routes, preserve fallback, support explicit probing, and reset after recovery.
Attempt observation and example
unified_llm/unified_llm.py, tests/test_health_observability.py, examples/observability.py, README.md, docs/API.md
Attempts report provider outcomes through synchronous or asynchronous callbacks. Callback failures are isolated, cancellation is preserved, and the example aggregates sanitized results.

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
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 17.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the health-aware routing and content-safe observability changes.
Title check ✅ Passed The title clearly and concisely summarizes the pull request's main routing and observability changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/health-observability

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Deathcharge
Deathcharge marked this pull request as ready for review August 8, 2026 08:42

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 775aecb and e9cd70b.

📒 Files selected for processing (12)
  • .env.example
  • CHANGELOG.md
  • README.md
  • ROADMAP.md
  • docs/API.md
  • docs/ARCHITECTURE.md
  • examples/observability.py
  • tests/test_configuration.py
  • tests/test_health_observability.py
  • tests/test_router.py
  • unified_llm/__init__.py
  • unified_llm/unified_llm.py

Comment thread .env.example Outdated
@Deathcharge
Deathcharge merged commit 402b9f7 into main Aug 8, 2026
11 checks passed
@Deathcharge
Deathcharge deleted the codex/health-observability branch August 8, 2026 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant