Skip to content

OpenCode model discovery fails β€” gentle-ai doesn't detect models from SQLite databaseΒ #1015

Description

@naujrevilo

Pre-flight Checklist

  • I have searched existing issues and this is not a duplicate
  • I understand that PRs will be rejected if the linked issue does not have status:approved

πŸ“ Bug Description

Gentle-AI fails to discover OpenCode models (including MiniMax, Xiaomi, and other custom providers) when configuring models via gentle-ai install or the TUI. The model picker shows no available models, even though opencode providers list and the /models command in OpenCode correctly display all connected providers and their models.

πŸ”„ Steps to Reproduce

  1. Install and configure OpenCode with custom API providers (e.g., MiniMax, Xiaomi)
  2. Verify providers are connected: run opencode providers list β†’ shows all providers correctly
  3. Run gentle-ai install or launch gentle-ai TUI
  4. Navigate to: Configure Models β†’ Configure OpenCode models
  5. The model picker shows no available providers/models

βœ… Expected Behavior

Gentle-AI should discover and display all OpenCode models (including custom providers like MiniMax, Xiaomi) in the model configuration picker.

❌ Actual Behavior

  • The OpenCode model picker shows: "OpenCode has not been run yet β€” model cache not found."
  • No providers or models appear in the selection list
  • However, opencode providers list correctly shows all 4 providers: MiniMax Token Plan, Xiaomi, GitHub Copilot, MiniMax

Gentle AI Version

  • Gentle AI Version: 1.43.3

Operating System

Windows (WSL)

AI Agent / Client

OpenCode

πŸ“‹ Affected Area

Other

πŸ’‘ Logs / Error Output

**Gentle-AI detection output:**

Detected Configs
  claude-code: present
  opencode: present
  kilocode: missing
  gemini-cli: missing
  cursor: missing
  vscode-copilot: present
  codex: missing
  ...


**OpenCode providers (working correctly):**

β”Œ  Credentials ~/.local/share/opencode/auth.json
β”‚
●  MiniMax Token Plan (minimax.io) api
●  Xiaomi api
●  GitHub Copilot oauth
●  MiniMax (minimax.io) api
β””  4 credentials


**Gentle-AI model picker error:**

OpenCode has not been run yet β€” model cache not found.
Run 'opencode' once, then re-run 'gentle-ai sync' to assign models.
Using default model assignments for now.

Additional Context

Root Cause Analysis

Gentle-AI searches for OpenCode models in the old models.cache location:

~/.config/opencode/models.cache  ← File does not exist

However, OpenCode stores provider credentials and model information in:

~/.local/share/opencode/auth.json       ← Contains API keys and provider configs
~/.local/share/opencode/opencode.db    ← SQLite database with model data

File System Evidence

Existing gentle-ai search path (no models found):

~/.config/opencode/
β”œβ”€β”€ AGENTS.md
β”œβ”€β”€ opencode.json
β”œβ”€β”€ tui.json
β”œβ”€β”€ skills/
β”œβ”€β”€ profiles/
β”œβ”€β”€ node_modules/
└── NO models.cache file exists

Actual OpenCode data locations (working):

~/.config/opencode/
β”œβ”€β”€ opencode.json     ← SDD orchestrator config only
└── ...

~/.local/share/opencode/
β”œβ”€β”€ auth.json         ← API credentials (minimax, xiaomi, github-copilot)
β”œβ”€β”€ opencode.db       ← SQLite database with models/providers
β”œβ”€β”€ opencode.db-wal
β”œβ”€β”€ opencode.db-shm
└── ...

Code Reference

The gentle-ai code in internal/tui/screens/model_picker.go loads models from:

providers, err := opencode.LoadModelsOrEmpty(cachePath)

Where cachePath appears to point to models.cache in ~/.config/opencode/, which no longer exists in current OpenCode versions.

Suggested Fix Direction

Gentle-AI should:

  1. Query the SQLite database ~/.local/share/opencode/opencode.db for available models, OR
  2. Detect that OpenCode uses the new data storage format and fall back to opencode providers list CLI output, OR
  3. Support reading from ~/.local/share/opencode/ as an additional search path

Related: This also explains why Trae IDE models from subscriptions are not visible β€” the same model discovery mechanism would need to query Trae's own data storage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstatus:approvedApproved for implementation β€” PRs can now be opened

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions