feat: model capability pre-flight validation#5443
Open
kshitijk4poor wants to merge 1 commit into
Open
Conversation
64cb628 to
9ceb66a
Compare
|
Not sure this is worth the complexity. |
10 tasks
13 tasks
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.
Fixes #5437. Also addresses #5452 (model deprecation warnings) and #5455 (API key format validation).
Summary
Adds advisory pre-flight validation covering model capabilities, deprecation status, and API key format — all before the first API call.
1. Model capability pre-flight
Problem: Hermes sends tool schemas, vision content, and reasoning params to all models regardless of capability. Failures discovered only at API call time.
Introduces
agent/model_capabilities.pywith:ModelCapabilitiesdataclass andKNOWN_CAPABILITIES(30+ regex patterns)get_model_capabilities(): Pure pattern-matching lookup, no API callsvalidate_preflight(): Warns about tools/vision/reasoning mismatches2. Model deprecation warnings
Problem: No warning when a model is deprecated. Users discover it via API errors.
Adds
check_model_deprecation():"deprecated"3. API key format validation
Problem:
has_usable_secret()only filters obvious placeholders. A garbled or wrong-provider key passes and fails with a cryptic 401 on first API call.Adds
validate_api_key_format():sk-, Anthropicsk-ant-, OpenRoutersk-or-, DeepSeeksk-, Groqgsk_)Design Decisions
Independent of #5441 (P0) and #5442 (P1) — no cross-dependencies.
Tests
84 tests covering pattern matching, preflight warnings, deprecation checks (with mocked models.dev), API key format validation for all known providers, and edge cases.