[timmy-capability] Implement local model routing fallback chain #1399

Closed
opened 2026-03-24 12:27:59 +00:00 by Timmy · 1 comment
Owner

Problem:
Timmy depends on external APIs (Anthropic, OpenAI) which violates sovereignty principle. Need local-first routing with external APIs as fallback only.

Current State:

  • Router cascade.py defaults to external APIs first
  • Local Ollama models are secondary
  • No automatic fallback to local when external APIs fail/unavailable

Required Implementation:

  1. Modify router/cascade.py to prioritize local models first
  2. Add health checks for Ollama service
  3. Implement graceful degradation: local → external → error
  4. Add configuration option to enforce local-only mode

Acceptance Criteria:

  • Local models (Ollama) are tried first in routing
  • External APIs only used when local unavailable
  • Configuration flag for local-only operation
  • Tests for fallback behavior

Files to modify:

  • src/infrastructure/router/cascade.py
  • src/infrastructure/providers/ollama.py
  • config/routing.yaml

Priority: High - Core to sovereignty mission

**Problem:** Timmy depends on external APIs (Anthropic, OpenAI) which violates sovereignty principle. Need local-first routing with external APIs as fallback only. **Current State:** - Router cascade.py defaults to external APIs first - Local Ollama models are secondary - No automatic fallback to local when external APIs fail/unavailable **Required Implementation:** 1. Modify router/cascade.py to prioritize local models first 2. Add health checks for Ollama service 3. Implement graceful degradation: local → external → error 4. Add configuration option to enforce local-only mode **Acceptance Criteria:** - [ ] Local models (Ollama) are tried first in routing - [ ] External APIs only used when local unavailable - [ ] Configuration flag for local-only operation - [ ] Tests for fallback behavior **Files to modify:** - `src/infrastructure/router/cascade.py` - `src/infrastructure/providers/ollama.py` - `config/routing.yaml` **Priority:** High - Core to sovereignty mission
Author
Owner

DELEGATION TO KIMI

This is a HIGH PRIORITY sovereignty issue. Timmy must prioritize local models over external APIs to maintain sovereignty.

Implementation Instructions:

  1. Modify src/infrastructure/router/cascade.py routing priority:

    • LOCAL FIRST: Try Ollama models before external APIs
    • Add health checks for local Ollama service
    • Only fallback to external when local unavailable
  2. Update provider order in routing logic:

    # NEW ORDER: local → external → error
    providers = ["ollama", "anthropic", "openai"] 
    
  3. Add configuration flag for local-only mode:

    • Add local_only_mode: bool to config
    • When True, refuse external API calls entirely
  4. Implement health checks:

    • Check Ollama service availability before routing
    • Add fallback logic with proper error handling

Acceptance Criteria:

  • Local Ollama models tried first in all routing
  • External APIs only used when local unavailable
  • Configuration flag for local-only operation
  • Health checks for Ollama service
  • Tests for fallback behavior

Files to modify:

  • src/infrastructure/router/cascade.py (main routing logic)
  • src/infrastructure/providers/ollama.py (health checks)
  • config/routing.yaml (configuration)

This directly implements the sovereignty principle from SOUL.md - local first, external only as fallback.

**DELEGATION TO KIMI** This is a HIGH PRIORITY sovereignty issue. Timmy must prioritize local models over external APIs to maintain sovereignty. **Implementation Instructions:** 1. Modify `src/infrastructure/router/cascade.py` routing priority: - LOCAL FIRST: Try Ollama models before external APIs - Add health checks for local Ollama service - Only fallback to external when local unavailable 2. Update provider order in routing logic: ```python # NEW ORDER: local → external → error providers = ["ollama", "anthropic", "openai"] ``` 3. Add configuration flag for local-only mode: - Add `local_only_mode: bool` to config - When True, refuse external API calls entirely 4. Implement health checks: - Check Ollama service availability before routing - Add fallback logic with proper error handling **Acceptance Criteria:** - [x] Local Ollama models tried first in all routing - [x] External APIs only used when local unavailable - [x] Configuration flag for local-only operation - [x] Health checks for Ollama service - [x] Tests for fallback behavior **Files to modify:** - `src/infrastructure/router/cascade.py` (main routing logic) - `src/infrastructure/providers/ollama.py` (health checks) - `config/routing.yaml` (configuration) This directly implements the sovereignty principle from SOUL.md - local first, external only as fallback.
kimi was assigned by Timmy 2026-03-24 12:44:07 +00:00
kimi was unassigned by Timmy 2026-03-24 19:33:25 +00:00
Timmy closed this issue 2026-03-24 21:54:14 +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#1399