Name the unmet option, not just the capability, in resolution failures - #298
Draft
sarthak-19 wants to merge 1 commit into
Draft
sarthak-19 wants to merge 1 commit into
sarthak-19 wants to merge 1 commit into
Conversation
ModelResolver::resolve() built its "no models found" message from the primary required capability only. When resolution actually failed because of a required option that every otherwise-suitable model lacked, the message blamed the capability, which those models did support, misleading anyone debugging the failure. On an empty candidate map, re-run the lookup using only the required capabilities. If that also returns nothing, the capability itself is unsupported and the message is unchanged. If it returns models, intersect their unmet options and name the ones every one of them fails to support.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #298 +/- ##
============================================
+ Coverage 86.58% 86.66% +0.07%
- Complexity 1383 1394 +11
============================================
Files 69 69
Lines 4449 4483 +34
============================================
+ Hits 3852 3885 +33
- Misses 597 598 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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
ModelResolver::resolve()built its "no models found" failure message from the primary required capability only. When resolution actually failed because a required option (e.g.webSearch,inputModalities) eliminated every candidate, the message still blamed the capability — which those models did in fact support. That makes the message actively misleading: checking whether the capability is supported confirms that it is.ModelRequirements::getUnmetRequirements()already exists specifically so calling code can report why a model is unsuitable, butModelResolver's failure path never called it.Change
On an empty candidate map, before throwing:
getUnmetRequirements()['options']across them and append a clause naming the option(s) that every one of them fails to support.The extra lookup only happens on a path that's already about to throw, so it costs nothing in the normal case.
Before:
After (when
webSearchis what actually eliminated every candidate):Test plan
composer test:unit— 1205 tests pass, including newModelResolverTestcases: option named (unscoped and provider-scoped), several options named, and capability genuinely unsupported (no option named).PromptBuilderTest::testGenerateResultWithProviderNoModelsThrowsExceptionupdated: the registry mock's expectation widens fromonce()toexactly(2)sincefromPromptData()always addsinputModalitiesas a required option, so the diagnostic re-lookup fires; the thrown message is unchanged since that second lookup also finds nothing.composer lint(phpcs + phpstan) — clean.