fix: relax memory_kv key validation to allow digits after first letter - #1327
Open
octo-patch wants to merge 1 commit into
Open
octo-patch wants to merge 1 commit into
octo-patch wants to merge 1 commit into
Conversation
fixes ShishirPatil#1272) The previous regex pattern `^[a-z]+(_[a-z0-9]+)*$` required the first segment to contain only lowercase letters, which incorrectly rejected valid snake_case keys like 'q1_report', 'user123_profile', and 'v2_config'. Updated pattern to `^[a-z][a-z0-9]*(_[a-z0-9]+)*$` which: - Requires the first character to be a lowercase letter - Allows digits after the first character in any segment - Still rejects keys starting with digits, uppercase, spaces, or underscores
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 #1272
Problem
The
_is_valid_key_formatmethod inmemory_kv.pyused a regex pattern^[a-z]+(_[a-z0-9]+)*$that required the first segment of a key to contain only lowercase letters. This incorrectly rejected valid snake_case keys that contain digits after the first character, such as:q1_report(quarterly reports)user123_profile(user profiles with IDs)v2_config(versioned configurations)s3_bucket_name(cloud resource names)This caused false negative evaluation results during BFCL v4 multi-turn evaluation.
Solution
Updated the regex pattern from:
to:
This change:
Testing
Verified with manual tests:
q1_report,user123_profile,v2_config,s3_bucket_name→ now correctly accepted ✓MyKey,my key,_key,1key,key_→ still correctly rejected ✓