When you run OpenCode in TUI mode, check the console output for these log messages:
[opencode-models-discovery] Model discovery plugin initialized- Plugin loaded- A config hook log indicating discovery/config processing started - Config hook invoked
- Provider creation or provider check logs - Provider instantiated successfully
- Discovery logs for
/v1/modelsrequests - Model discovery started - Model discovery summary logs - Models found
- Model merge/injection logs - Models added to config
- Final config hook completion logs - Hook completed
-
Is the plugin loaded?
- Look for:
[opencode-models-discovery] Model discovery plugin initialized - If missing: Plugin not installed or not in config
- Look for:
-
Is the config hook being called?
- Look for config-related logs after plugin initialization
- If missing: OpenCode might not be calling the hook
-
Are models being discovered?
- Look for discovery logs or a discovered model count for your provider
- If count is 0: The provider might not be running, reachable, or exposing any models
-
Are models being added to config?
- Look for model merge/injection logs
- Check:
modelCountin the final log message
-
Is the config frozen?
- Look for:
configFrozen: truein the debug log - If true: OpenCode might be passing a frozen config object
- Look for:
Possible causes:
- Config hook not being awaited by OpenCode
- Config object is frozen/read-only
- OpenCode reads config before hook completes
- Config object is cloned before hook runs
Debug steps:
- Check console logs for the sequence above
- Look for warnings about frozen config
- Check if
modelCountis 0 in final log - Verify your provider is running:
curl http://127.0.0.1:1234/v1/models
Check:
- Plugin is in
opencode.json:"plugin": ["opencode-models-discovery"] - Plugin is installed:
npm list opencode-models-discovery - No errors in OpenCode startup logs
Check:
- Your provider service is running
- Its OpenAI-compatible API endpoint is active
- The configured port is correct
- Try:
curl http://127.0.0.1:1234/v1/models
Run this to test the plugin directly:
bun debug-opencode-simulation.tsThis simulates how OpenCode calls the plugin and shows if models are loaded correctly.