Add input/output modality validation to TargetRequirements.validate()#1778
Merged
hannahwestra25 merged 3 commits intoMay 22, 2026
Conversation
TargetRequirements.validate() previously only checked boolean capabilities (required / native_required). It did not verify that the target's input_modalities and output_modalities satisfy consumer expectations. Add required_input_modalities and required_output_modalities fields, and extend validate() to check each required modality combo is covered by at least one of the target's supported combos. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Move PromptDataType import into TYPE_CHECKING block (TC001) - Use list comprehension in _check_modalities (PERF401) - Apply ruff formatting - Update 0_prompt_targets.md, 6_1_target_capabilities.py/.ipynb to document required_input_modalities / required_output_modalities Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1f3dacd to
74b8e41
Compare
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.
Problem
TargetRequirements.validate() checks boolean capabilities (MULTI_TURN, EDITABLE_HISTORY, etc.) but does not check modalities. A consumer that requires image input can be wired to a text-only target with no error at construction time -- the mismatch is only caught at runtime in _validate_request.
Solution
Add two optional fields to TargetRequirements:
validate() checks that each required modality combo is covered by at least one of the target's supported combos (superset check), consistent with the runtime check in _validate_request.
Both fields default to frozenset() so existing consumers are unaffected.
Test coverage
7 new tests covering match, superset pass-through, missing input/output errors, mixed modality + capability error aggregation, and backward compatibility.