Skip to content

Extract shared Ollama /api/tags helper (DRY preflight + auto-select) #52

Description

@rosspeili

Problem Statement

Ollama tag discovery is implemented inline in rooms/ollama_preflight.py. PR #44 and issue #30 add a second urlopen + JSON parse path in settings.py. Tag matching rules (name vs model, :latest) should live in one place.

Proposed Solution

  1. Add e.g. rooms/ollama_client.py (or extend ollama_preflight.py) with:

    • fetch_ollama_tags(base_url, timeout=3.0) -> list[str]
    • tag_is_available(configured_tag, available_tags) -> bool
  2. Refactor run_ollama_preflight() to use the helper.

  3. When feat: support ollama.auto_select_first model resolution #44/Implement ollama.auto_select_first from settings #30 land, resolve_ollama_model() uses the same helper.

  4. Unit tests for tag matching edge cases (exact, :latest, empty list, unreachable server).

Acceptance criteria

  • One implementation of /api/tags fetch and tag normalization
  • Existing preflight tests still pass
  • No behavior change for default preflight path unless bugs found during refactor

Alternatives Considered

Priority

Medium 🟡

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestsession-logicChanges related to turn orchestration or agent selection.

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions