Skip to content

fix: move provider hook models to config hook#17

Merged
goniz merged 6 commits into
mainfrom
fix/hook-config
May 10, 2026
Merged

fix: move provider hook models to config hook#17
goniz merged 6 commits into
mainfrom
fix/hook-config

Conversation

@goniz
Copy link
Copy Markdown
Owner

@goniz goniz commented May 9, 2026

Broken in OpenCode 1.14.31+

goniz added 3 commits May 9, 2026 23:49
Populate provider.models via the config hook instead of the
deprecated provider hook. Also unpin opencode image version
in the integration test compose file.
Write schema-valid provider model entries from the config hook so OpenCode can load local models without config validation errors. Also always pull the opencode test image so the integration container uses the latest CLI.
Comment thread src/plugin.ts Outdated
Comment on lines +127 to +134
const models = await probeModels(
{
id: LOCAL_PROVIDER_ID,
options,
models: (provider as Provider).models ?? ({} as Record<string, Model>),
} as unknown as Provider,
{} as ProviderHookContext,
)
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why keep passing this uneeded signature? Simplify this now that we are not being called from a hook

Comment thread src/plugin.ts Outdated
} as unknown as Provider,
{} as ProviderHookContext,
)
;(cfg.provider[LOCAL_PROVIDER_ID] as Record<string, unknown>).models = configModels(models)
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this semicolon?

Comment thread src/plugin.ts Outdated
}
}

function configModel(model: Model) {
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can simplify the underlying probe function to yield either ModelConfig or ProviderConfig? We can have two overrides . Instead of converting schemas

Keep runtime provider model construction available while giving the config hook a dedicated config-schema builder. This removes the stale hook-shaped probe call and simplifies config model assignment.
Comment thread src/plugin.ts
Comment on lines 63 to +77
cfg.provider[LOCAL_PROVIDER_ID] = {
...provider,
name: provider.name ?? LOCAL_PROVIDER_NAME,
npm: provider.npm ?? OPENAI_COMPATIBLE_NPM,
options,
}

const models = await probeModels({
options,
models: (provider as Provider).models,
})
cfg.provider[LOCAL_PROVIDER_ID] = {
...(cfg.provider[LOCAL_PROVIDER_ID] as Record<string, unknown>),
models,
}
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge this all into a single op

Comment thread src/models.ts
Comment on lines +147 to +154
export function buildConfig(target: string, url: string, list: LocalModel[], prev: Record<string, ConfigModel>) {
return Object.fromEntries(
list.map((model) => {
const key = id(target, model.id)
return [key, configItem(target, url, model, prev[key])]
}),
)
}
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want the ConfigModel return type to only contain what's actually been set! I don't want it to be full type verbose like now.

goniz added 2 commits May 10, 2026 00:53
Merge config hook model updates into a single assignment and keep the config model shape limited to fields we actually reuse. Also preserve attachments when vision support is present.
Drop verbose config-only fields and avoid forcing incorrect reasoning or tool-call flags into probed local models. Preserve attachments when vision support is present.
@goniz goniz merged commit f138b8f into main May 10, 2026
9 checks passed
@goniz goniz deleted the fix/hook-config branch May 10, 2026 05:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant