fix(claw-migrate): resolve model aliases against real OpenClaw catalog schema (salvage #16778) - #16977
Merged
Conversation
`hermes claw migrate` copied OpenClaw's model setting verbatim, which could be a display alias (e.g. "Claude Opus 4.6") instead of the actual API ID (e.g. "claude-opus-4-6"). Hermes then sent the alias to the API, causing HTTP 404 model not found. Fix: look up the model string in agents.defaults.models (plural) alias catalog. If found, use the resolved "id" field, prepending the provider prefix if needed. If not found (already an API ID), pass through unchanged. Fixes #16745
…w schema
Real OpenClaw configs key agents.defaults.models by full provider/model
API ID with an 'alias' field on the value (e.g.
{'anthropic/claude-opus-4-6': {'alias': 'Claude Opus 4.6'}}). Add
regression tests for issue #16745 covering:
- reverse-lookup of alias against real schema (keyed by API ID)
- alias resolution when model is a bare string vs {'primary': ...}
- passthrough when the value is already a provider/model API ID
- passthrough when the alias has no catalog match
- string-valued catalog entries (belt-and-suspenders)
- no catalog at all
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Salvages @vominh1919's PR #16778 with corrected lookup direction.
Summary
claw migratenow correctly resolves an OpenClaw model display-name alias to the real provider/model API ID before writing toconfig.yaml, so Hermes no longer sends"Claude Opus 4.6"to the Anthropic API and gets HTTP 404.Root cause
OpenClaw's
agents.defaults.modelscatalog is keyed by the full provider/model API ID, with analiasfield on the value:{ "anthropic/claude-opus-4-6": { "alias": "Claude Opus 4.6" } }The original PR assumed the catalog was keyed by display name with
{"id": ..., "provider": ...}as the value — the inverse shape. The forward lookupif model_str in model_catalogwould have missed on every real OpenClaw config, including the exact catalog shown in issue #16745's repro.Fix
Do a reverse lookup: if
model_strisn't already a catalog key, scan catalog items for one whosealias(or plain-string value) matchesmodel_str, then use that entry's key as the resolved API ID. Leavemodel_stralone when it's already an API ID or has no match.Changes
optional-skills/migration/openclaw-migration/scripts/openclaw_to_hermes.py(+23 / -0): reverse-lookup inmigrate_model_configtests/skills/test_openclaw_migration.py(+137 / -0): 6 regression tests covering real schema, bare-string model value, already-an-API-ID passthrough, unknown-alias passthrough, string-valued entries, no catalogValidation
Targeted suite: 100/100 passing (
tests/skills/test_openclaw_migration*.py+tests/hermes_cli/test_setup_openclaw_migration.py).E2E: real OpenClaw schema from issue #16745 resolves
{"primary": "Claude Opus 4.6"}→anthropic/claude-opus-4-6in the writtenconfig.yaml.Credit
Cherry-picked @vominh1919's commit (authorship preserved); lookup direction amended to match the real OpenClaw catalog shape, plus a follow-up commit adding regression tests. Closes #16778, fixes #16745.