Validate Preset String • AI Agent SDK
validate_preset_string: Raise a helpful error when a string does not name a known preset.
validate_preset_string
Function
</div>
This function is defined in the parse_utils module.
Raise a helpful error when a string does not name a known preset.
Non-string values pass through untouched, so callers can hand this the raw parameter without pre-checking the type. Matching is case-insensitive, ignores surrounding whitespace, and treats `-/_ as interchangeable, mirroring the preset lookups performed by the parameter resolvers (e.g. PermissionMode.resolve accepts both accept_edits and accept-edits`). This keeps the guard from rejecting spellings the downstream resolver would happily accept.
Signature
def validate_preset_string(param_name: str, value: Any, presets: Iterable[str]) -> NoneParameters
strName of the parameter (for the error message)
AnyRaw parameter value
Iterable[str]Valid preset names
Exceptions
ValueError
If value is a string that is not a known preset
Uses
canonical_preset_keymake_preset_error
Source
View on GitHubpraisonaiagents/config/parse_utils.py at line 209