Skip to content

refactor: consolidate strict provider/model reference parsing #99674

Description

@RomneyDa

Summary

OpenClaw has repeated implementations of the same mechanical provider/model reference grammar across model catalog, config, Gateway startup, and plugin runtime paths. These copies trim and split on the first slash, normalize the provider id, preserve slash-containing model ids, and reject missing provider/model segments.

Exact Contract

  • Input is a string provider/model reference.
  • Trim surrounding whitespace and segment-edge whitespace.
  • Split on the first / only.
  • Require non-empty provider and model segments.
  • Normalize the provider id through the model-catalog provider-id contract.
  • Preserve model-id casing and any additional / characters.

Scope

  • Add the mechanical parser to @openclaw/model-catalog-core.
  • Migrate callers that already implement the exact normalized contract.
  • Delete local copies and retain caller-specific return-shape adaptation only where necessary.
  • Add focused canonical and migrated-caller tests.

Non-Goals

  • Provider selection or fallback choice.
  • Authentication, retryability, aliases, runtime routing, or provider-specific model-id normalization.
  • Bare-model default-provider resolution.
  • Compatibility or doctor migration behavior.
  • A universal option-heavy parser.

Evidence / Completion

  • Focused Vitest coverage for the canonical helper and migrated callers.
  • Changed typecheck/lint/guard lanes and import-cycle proof.
  • Package build proof because the model-catalog package surface changes.
  • Production LOC reduction and search proof for removed duplicate implementations.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low-priority cleanup, docs, polish, ergonomics, or speculative work.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.issue-rating: 🌊 off-meta tidepoolIssue quality rating does not apply to this item.maintainerMaintainer-authored PR

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions