feat(discover): match unscoped tags against dir-prefixed model short names#159
Merged
Merged
Conversation
…names Per-directory models.json prefixes model names with their directory (e.g. pyt_foo becomes dir/pyt_foo), which silently broke --tags pyt_foo for users referencing models by their original flat name. Fall back to matching the short name (the part after the last '/') for unscoped tags so existing --tags invocations keep working after the migration. Co-authored-by: Cursor <cursoragent@cursor.com>
coketaste
requested review from
Cemberk,
Rohan138,
gargrahul and
leconcio
as code owners
July 15, 2026 22:00
There was a problem hiding this comment.
Pull request overview
This PR restores backward compatibility for DiscoverModels.select_models() when per-directory models.json introduces directory-prefixed model names (e.g., dir/pyt_foo), by allowing unscoped --tags <name> inputs to also match a model’s short name (the segment after the last /). It also adds/updates unit tests to lock in the intended behavior, including scoped-tag behavior remaining unchanged.
Changes:
- Extend unscoped name-based model selection to also match
model["name"].split("/")[-1](and the equivalent forCustomModel.name). - Update an existing unit test to reflect the new backward-compat behavior for unscoped tags matching scoped models by short name.
- Add a new test suite covering dir-prefixed models, flat names, custom models, scoped tags, and ambiguous short-name scenarios.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/madengine/utils/discover_models.py |
Adds short-name fallback matching for unscoped --tags against both models.json models and CustomModels. |
tests/unit/test_discover_models.py |
Updates/expands unit tests to validate short-name backward compatibility and preserve scoped-tag semantics. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
2 tasks
coketaste
added a commit
that referenced
this pull request
Jul 16, 2026
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.
Summary
models.jsonfiles prefix each model name with their directory(e.g.
pyt_foobecomesdir/pyt_foo). This silently broke--tags pyt_fooforusers who referenced models by their original flat name, since the exact-name
match would no longer find them and no error was raised to explain why.
select_models()now also falls back to matching the model's short name (thepart after the last
/) for unscoped tags, for bothmodels.json-definedmodels and custom models from
get_models_json.py. This is purely additive —scoped tags (
scope/tag), tag-field matching, and flat (non-prefixed) modelnames are all unaffected.
TestShortNameBackwardCompatcovering: short-name resolution of adir-prefixed model, flat names still working, short-name resolution for custom
models, and scoped tags being unaffected by the new short-name fallback.
test_unscoped_tag_does_not_cross_scope_boundary(nowtest_unscoped_tag_matches_scoped_model_by_short_name), which previouslyasserted the old (pre-fix) behavior that unscoped tags could not cross scope
boundaries — that assumption is exactly what this change intentionally
relaxes for backward compatibility.
test_ambiguous_short_name_matches_both_flat_and_prefixed_modelto pindown current behavior for the edge case where both a flat model (
foo) and adir-prefixed model (
dir/foo) share the same short name — today both areselected, since there's no precedence between an exact match and a
short-name match.
Test plan
pytest tests/unit/test_discover_models.py -v— all 18 tests pass