parse_utils
Rust AI Agent SDK Parse Utilities Utility functions for parameter parsing:- URL detection and parsing
- Path detection
- Typo suggestion (only on error path)
- Error message generation
- String cleaning utilities
Import
Functions
detect_url_scheme()
Detect URL scheme from a string. O(1) operation.
is_path_like()
Check if a string looks like a file path. O(1) operation.
is_numeric_string()
Check if a string is numeric. O(1) operation.
is_policy_string()
Check if a string is a policy specification. O(1) operation. Policy strings have format: type:action (e.g., ‘policy:strict’, ‘pii:redact’)
parse_policy_string()
Parse a policy string into type and action. O(1) operation.
suggest_similar()
Find the most similar string from candidates using Levenshtein distance. This function is ONLY called on error paths, never on happy paths.
clean_triple_backticks()
Clean triple backticks from a string (common in LLM outputs) Removes markdown code block markers like or
clean_whitespace()
Clean and normalize whitespace in a string
extract_json()
Extract JSON from a string that may contain markdown code blocks
validate_keys()
Validate that all keys in a set are valid
make_preset_error()
Create a helpful error message for invalid preset
make_array_error()
Create a helpful error message for invalid array format

