Skip to content

feat: add AgentRouter setup + improve /health endpoint#270

Open
Mayanks584 wants to merge 1 commit intoAlishahryar1:mainfrom
Mayanks584:feature-agentrouter
Open

feat: add AgentRouter setup + improve /health endpoint#270
Mayanks584 wants to merge 1 commit intoAlishahryar1:mainfrom
Mayanks584:feature-agentrouter

Conversation

@Mayanks584
Copy link
Copy Markdown

  1. AgentRouter setup added to README
    Added a new section in the README explaining how to use AgentRouter as an alternative to running the local proxy.
    Why:
    From experience, setting up the full local proxy (installing uv, cloning the repo, configuring .env, etc.) can feel like overkill for users who just want to get started quickly. AgentRouter makes that much easier by removing most of that setup.
    What’s added:
    A simple, step-by-step guide (login → generate API key → set env vars → run)
    Examples for different environments (Windows, Linux, macOS)
    A short note on when it makes sense to use AgentRouter vs the local proxy

  2. Improved /health endpoint
    Updated the /health endpoint to return more useful information instead of just a basic "healthy" response.
    Why:
    Previously, /health only confirmed that the server was running, but it didn’t really help when something was misconfigured. In most cases, debugging meant checking logs or going through the code, which wasn’t ideal.
    What’s changed:
    Now returns a detailed snapshot of the current configuration (models, providers, server info, etc.)
    Shows whether providers are properly configured and if credentials are present
    Includes rate-limit state (when available)
    Gives visibility into messaging and web tools status
    Security:
    Sensitive data like API keys or tokens are not exposed — only safe indicators (like booleans) are returned.

Copilot AI review requested due to automatic review settings April 29, 2026 17:58
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a richer /health endpoint (including provider/config/runtime diagnostics) and documents an AgentRouter-hosted alternative path for getting started without running the local proxy.

Changes:

  • Added api.health.build_health_payload() and wired GET /health to return a detailed runtime/config snapshot (with auth-gated GET and unauthenticated HEAD /health for liveness).
  • Exposed rate-limiter state via GlobalRateLimiter.snapshot() and a providers.registry.provider_rate_limit_snapshot() façade for diagnostics.
  • Added extensive documentation updates (AgentRouter setup in README.md, new PROJECT.md) and a comprehensive new test suite for /health.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
api/routes.py Updates /health route to return a richer payload and require auth on GET.
api/health.py Implements the rich /health payload builder and helper functions.
providers/rate_limit.py Adds limiter inspection helpers (get_existing_scoped_instance, snapshot).
providers/registry.py Adds a diagnostic façade to fetch per-provider rate-limit snapshots without importing limiter internals from the API layer.
tests/api/test_health.py New pytest coverage validating payload shape, redaction, auth gating, provider snapshot logic, and rate-limit reporting.
README.md Adds AgentRouter hosted setup instructions and TOC link.
PROJECT.md Adds a comprehensive codebase documentation file (but contains some config env var name mismatches vs Settings).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread PROJECT.md
| **Thinking** | `THINKING`, `THINKING_OPUS`, `THINKING_SONNET`, `THINKING_HAIKU` | Enable/disable per tier |
| **Auth** | `ANTHROPIC_AUTH_TOKEN` | Proxy auth token (optional) |
| **HTTP** | `HTTP_CONNECT_TIMEOUT`, `HTTP_READ_TIMEOUT`, `HTTP_WRITE_TIMEOUT` | Client timeouts |
| **Rate limits** | `RATE_LIMIT`, `RATE_WINDOW`, `MAX_CONCURRENCY` | Per-provider rate limiting |
Comment thread PROJECT.md
| **Rate limits** | `RATE_LIMIT`, `RATE_WINDOW`, `MAX_CONCURRENCY` | Per-provider rate limiting |
| **Messaging** | `MESSAGING_PLATFORM`, `TELEGRAM_BOT_TOKEN`, `DISCORD_BOT_TOKEN` | Bot config |
| **Voice** | `WHISPER_DEVICE`, `WHISPER_MODEL` | Transcription backend |
| **Workspace** | `CLAUDE_WORKSPACE`, `CLAUDE_ALLOWED_DIRS`, `PLANS_DIRECTORY` | Agent workspace |
Comment thread PROJECT.md
Comment on lines +813 to +815
- **Thinking control**: `THINKING=true`, `THINKING_SONNET=false`
- **Proxy/timeout**: `NVIDIA_NIM_PROXY`, `HTTP_READ_TIMEOUT=120`
- **Rate limits**: `RATE_LIMIT=40`, `RATE_WINDOW=60`, `MAX_CONCURRENCY=5`
Comment thread README.md

> Use `sudo` on Linux/macOS if you hit permission errors.

### 2. Get An AgentRouter API Key
Comment thread tests/api/test_health.py
Comment on lines +29 to +33
@pytest.fixture
def client(app: FastAPI) -> Generator[TestClient]:
with TestClient(app) as test_client:
yield test_client

Comment thread tests/api/test_health.py
Comment on lines +35 to +40
@pytest.fixture(autouse=True)
def _reset_rate_limiters() -> Generator[None]:
"""Clear scoped limiters between tests so snapshots stay deterministic."""
GlobalRateLimiter.reset_instance()
yield
GlobalRateLimiter.reset_instance()
Comment thread PROJECT.md
| **Provider keys** | `NVIDIA_NIM_API_KEY`, `OPENROUTER_API_KEY`, `DEEPSEEK_API_KEY` | API credentials |
| **Local providers** | `LM_STUDIO_BASE_URL`, `LLAMACPP_BASE_URL`, `OLLAMA_BASE_URL` | Base URLs |
| **Model routing** | `MODEL`, `MODEL_OPUS`, `MODEL_SONNET`, `MODEL_HAIKU` | Provider-prefixed model refs |
| **Thinking** | `THINKING`, `THINKING_OPUS`, `THINKING_SONNET`, `THINKING_HAIKU` | Enable/disable per tier |
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.

2 participants