fix(omo-senpi): builtin model profiles resolve to a custom models.json provider serving the same model id (#10485)

Merged
CO
1mo ago
+269-6

Fixes #10485

Summary

A builtin model profile (Daily · Normal / Heavy, Geeky · Normal / Heavy, and the unset default that walks them) now resolves to a provider the user declared in models.json when that provider serves the exact model id the rung asks for. Before, such a setup (for example an API-key proxy my-claude-proxy serving claude-opus-5-5) reported "no available model" and the session stayed on senpi's default.

Reported by 채완.

Precedence

  1. The rung's listed built-in providers, in their listed order (unchanged; a subscription login still beats an API key).
  2. Then providers declared in <agentDir>/models.json with their own models, in declaration order, on an exact <provider>/<model id> registry match only.

The #9146 protection is unchanged. A gateway the user never declared isn't in that list, and a gateway's re-published copy carries a vendor-prefixed id (opengateway/anthropic/claude-opus-5-5) that never equals the bare id. User-defined profiles behave as before.

Changes

  • packages/omo-senpi/src/components/model-profile/custom-providers.ts: customModelProviders(agentDir) reads models.json (JSONC, as senpi parses it). It lists providers whose entry has a non-empty models array, in declaration order. An override that only sets baseUrl or credentials for a built-in provider is not listed.
  • resolve.ts: resolveModelProfile takes customProviders. For builtin rungs only, matchProfileRung tries those providers after the listed ones.
  • index.ts: the session-start resolver passes customModelProviders(agentDir).
  • Bundles regenerated in linux/amd64 node 24 + bun 1.4.2: only omo.js changed.

QA & Evidence

  • RED: in resolve.test.ts, the custom-only and declaration-order cases failed on the pre-fix code (toMatchObject: the result was unavailable instead of resolved). custom-providers.test.ts failed with the module absent.
  • GREEN: bun test packages/omo-senpi/src/components/model-profile gives 114 pass, 0 fail. tsgo --noEmit -p packages/omo-senpi/tsconfig.json is clean.
  • Live Senpi QA (real senpi binary, throwaway sandbox with HOME, XDG and agent dir inside it, removed afterwards). Setup: models.json declares my-claude-proxy serving claude-opus-5-5 (unreachable base URL, dummy key), and omo.json sets model_profile: daily-normal.
    • dev bundle: omo-model-profile:unavailable, "daily-normal (Daily · Normal) has no available model".
    • this branch: omo-model-profile:applied, "daily-normal (Daily · Normal) selected my-claude-proxy/claude-opus-5-5 medium", plus an extension-sourced model_change to that model.
  • Bundles: build-extension.mjs --check and build-install.mjs --check exit 0 after the regen.
  • Full suite: Boat run at the head is in progress; results will be posted here.

Evidence files are local under .omo/evidence/omo-senpi-adapter/20261018-profile-custom-provider/ (SUMMARY.md, base.*, head.*).

Follow-up

senpi-task category chains filter providers the same way. Whether categories should also honor declared custom providers is a separate decision.


Summary by cubic

A builtin model profile (Daily/Geeky Normal/Heavy) now resolves to a provider the user declared in models.json when that provider serves the exact model id the rung asks for. Previously such setups reported "no available model" and stayed on the default profile.

  • Custom models.json providers are tried after the rung's listed providers, in declaration order, only on an exact <provider>/<model id> match. An override that only sets baseUrl or credentials for a built-in provider isn't listed.
  • The #9146 protection is unchanged: an undeclared gateway isn't listed, a gateway's re-published copy carries a vendor-prefixed id (opengateway/anthropic/claude-opus-5-5), and a gateway declared only with unrelated models still doesn't serve the rung's id.
  • models.json is now parsed once per process while the file is unchanged (keyed on mtime and size), shared by the custom-provider and credential-rotation readers; an edited file is picked up at the next session start.
  • Bundles and CHANGELOG regenerated; bun test packages/omo-senpi/src/components/model-profile passes 114 tests.