@@ -145,18 +145,29 @@ def claude_model_catalog() -> ModelCatalog:
145145 return _CLAUDE_CATALOG
146146
147147
148+ def _catalog_id (provider : Optional [str ], model_id : str ) -> str :
149+ """Build the ``provider/model`` join key.
150+
151+ Catalog ids carry a lowercase provider, and the rest of the system (environment resolver,
152+ connection matching) treats provider names case-insensitively, so a caller-supplied
153+ ``"OpenAI"`` must still join.
154+ """
155+ head , separator , tail = model_id .partition ("/" )
156+ if provider is None :
157+ return f"{ head .lower ()} /{ tail } " if separator else model_id
158+ if separator and head .lower () == provider .lower ():
159+ return f"{ provider .lower ()} /{ tail } "
160+ return f"{ provider .lower ()} /{ model_id } "
161+
162+
148163def model_input_modalities (
149164 harness : Optional [str ], model_id : str , * , provider : Optional [str ] = None
150165) -> Optional [List [str ]]:
151166 """Look up input modalities using the model id form accepted by ``harness``."""
152167 entry : Optional [ModelCatalogEntry ]
153168 if harness in ("pi_core" , "pi_agenta" ):
154169 catalog = pi_model_catalog ()
155- catalog_id = (
156- model_id
157- if provider is None or model_id .startswith (f"{ provider } /" )
158- else f"{ provider } /{ model_id } "
159- )
170+ catalog_id = _catalog_id (provider , model_id )
160171 elif harness == "claude" :
161172 catalog = claude_model_catalog ()
162173 catalog_id = model_id
@@ -166,9 +177,7 @@ def model_input_modalities(
166177 entry = next ((item for item in catalog .models if item .id == catalog_id ), None )
167178 if harness == "claude" and entry is None :
168179 # Reuse the same sourced Anthropic fact from Pi's generated catalog; do not guess.
169- pi_catalog_id = (
170- model_id if model_id .startswith ("anthropic/" ) else f"anthropic/{ model_id } "
171- )
180+ pi_catalog_id = _catalog_id ("anthropic" , model_id )
172181 entry = next (
173182 (item for item in pi_model_catalog ().models if item .id == pi_catalog_id ),
174183 None ,
0 commit comments