Skip to content

Fetch models from models_gateway and prefer gateway-served models in picker #1606

@ThePlenkov

Description

@ThePlenkov

Summary

When a models_gateway is configured, cagent currently assumes gateway supports core providers and shows a static list (configured models + models.dev catalog). It does not query the gateway for a live list of models. This causes incorrect/irrelevant models to appear in the model picker.

Proposal

Add gateway model discovery when models_gateway is set: query <gateway>/v1/models (OpenAI-style) or a configurable metadata endpoint and use the returned model list to populate/suppress models in the picker.

Acceptance criteria

  • When models_gateway is set and /v1/models returns a list, the model picker shows only models served by that gateway (merged with explicitly defined models in config).
  • Provide an opt-in config flag models_gateway.discover: true/false to control discovery.
  • Add unit tests and an integration test that mocks gateway responses.
  • Document behavior in AGENTS.md and README.md.

Notes

  • If gateway does not support /v1/models, fall back to current behavior.
  • Consider caching the model list and exposing a refresh button in the TUI.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions