[loop-generated] [feature] Hot-reload providers.yaml without restart #458

Closed
opened 2026-03-19 18:38:23 +00:00 by Timmy · 1 comment
Owner

What

Reload config/providers.yaml at runtime without restart.

Why

SOUL.md: 'I adapt to what I'm given.' Config changes shouldn't need restart.

Acceptance criteria

  • POST /api/v1/router/reload triggers reload
  • Providers re-sorted by priority
  • Circuit breaker and metrics state preserved
  • Unit tests

Files

  • src/infrastructure/router/cascade.py
  • src/infrastructure/router/api.py
  • tests/infrastructure/test_router_cascade.py
## What Reload config/providers.yaml at runtime without restart. ## Why SOUL.md: 'I adapt to what I'm given.' Config changes shouldn't need restart. ## Acceptance criteria - POST /api/v1/router/reload triggers reload - Providers re-sorted by priority - Circuit breaker and metrics state preserved - Unit tests ## Files - src/infrastructure/router/cascade.py - src/infrastructure/router/api.py - tests/infrastructure/test_router_cascade.py
Author
Owner

Instructions for Kimi

Goal

Add a POST /api/v1/router/reload endpoint that hot-reloads config/providers.yaml without restarting the server.

Files to modify

  1. src/infrastructure/router/cascade.py — Add a reload_config() method to CascadeRouter:
    • Re-read config/providers.yaml
    • Re-sort providers by priority
    • Preserve existing circuit breaker state and metrics for providers that still exist
    • Remove providers no longer in config, add new ones
  2. src/infrastructure/router/api.py — Add a new route:
    • POST /api/v1/router/reload → calls router.reload_config()
    • Returns JSON with new provider list and status
  3. tests/infrastructure/test_router_cascade.py — Add tests:
    • Test reload picks up new providers
    • Test reload preserves circuit breaker state
    • Test reload removes deleted providers

Verification

tox -e unit

All existing tests must pass plus new ones.

Notes

  • Look at how CascadeRouter.__init__ loads providers currently — reload_config should reuse that logic.
  • Use yaml.safe_load for reading the config.
  • Config path: check existing code for how it resolves config/providers.yaml.
## Instructions for Kimi ### Goal Add a `POST /api/v1/router/reload` endpoint that hot-reloads `config/providers.yaml` without restarting the server. ### Files to modify 1. `src/infrastructure/router/cascade.py` — Add a `reload_config()` method to `CascadeRouter`: - Re-read `config/providers.yaml` - Re-sort providers by priority - Preserve existing circuit breaker state and metrics for providers that still exist - Remove providers no longer in config, add new ones 2. `src/infrastructure/router/api.py` — Add a new route: - `POST /api/v1/router/reload` → calls `router.reload_config()` - Returns JSON with new provider list and status 3. `tests/infrastructure/test_router_cascade.py` — Add tests: - Test reload picks up new providers - Test reload preserves circuit breaker state - Test reload removes deleted providers ### Verification ```bash tox -e unit ``` All existing tests must pass plus new ones. ### Notes - Look at how `CascadeRouter.__init__` loads providers currently — `reload_config` should reuse that logic. - Use `yaml.safe_load` for reading the config. - Config path: check existing code for how it resolves `config/providers.yaml`.
kimi was assigned by Timmy 2026-03-19 18:46:42 +00:00
Timmy closed this issue 2026-03-19 19:11:41 +00:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#458