Auto Correction Policy
Feeds the error back to the LLM with a fuzzy-match suggestion, allowing it to self-correct. Uses a two-tier matching strategy for performance. Throws ToolNotFoundException after maxRetries consecutive failures.
Matching strategy:
Fast path: Simple normalization (lowercase + remove non-alphanumeric) for exact matches
Fallback: Token-based similarity (Jaccard index) for fuzzy matches
Handles:
Delimiter variations:
vector_search↔vectorSearch↔vector-search(simple normalization)Case insensitivity:
VECTORSEARCH→vectorSearch(simple normalization)Prefix hallucinations:
ragbot_vectorSearch→vectorSearch(token-based)Wrapped names:
my_vectorSearch_v2→vectorSearch(token-based)
Performance optimizations:
Simple normalization fast path handles ~80% of cases with O(n) complexity
Token-based matching only used when needed with O(n*m) complexity
Skips fuzzy matching for very short tool names (<minTokenLength)
Returns top 3 closest matches only
Parameters
maximum number of consecutive failures before throwing
minimum token length to include in matching (performance optimization)
minimum Jaccard similarity (0.0-1.0) to consider a match