diff --git a/services/agent/src/boundary_evaluation.py b/services/agent/src/boundary_evaluation.py index 2402d6f45..acceecf7e 100644 --- a/services/agent/src/boundary_evaluation.py +++ b/services/agent/src/boundary_evaluation.py @@ -1005,6 +1005,7 @@ def _array_range_definition(text: str) -> bool: """ lowered = text.casefold() patterns = ( + r"(?:访问数组时(?:使用)?|访问)?(?:超出|超过)(?:了)?(?:数组(?:的)?|其)?(?:有效|合法)(?:索引|下标)?范围的(?:索引|下标)", r"(?:索引|下标)(?:落在)?(?:超出|超过|不在)[^。;;!??]{0,16}(?:有效|合法)[^。;;!??]{0,8}范围(?:内)?", r"(?:索引|下标)落在(?:有效|合法)范围(?:之外|以外)", r"(?:访问)?(?:超出|超过)[^。;;!??]{0,12}数组(?:的)?(?:有效|合法)?(?:索引|下标)?(?:范围|边界|长度)", diff --git a/services/agent/tests/test_boundary_evaluation.py b/services/agent/tests/test_boundary_evaluation.py index 6272d78d8..8d637306f 100644 --- a/services/agent/tests/test_boundary_evaluation.py +++ b/services/agent/tests/test_boundary_evaluation.py @@ -1001,6 +1001,8 @@ def test_case_records_provider_response_identity_unknown_when_absent() -> None: "数组越界指下标不在数组的有效范围内。", "Array out of bounds means an index outside the array's valid range.", "数组越界指访问超出数组长度的索引。", + "数组越界是访问数组时使用超出有效索引范围的下标。", + "数组越界指访问超过其合法下标范围的索引。", ]) def test_no_tool_equivalent_range_definitions(text): script = _all_met_script() @@ -1017,6 +1019,9 @@ def test_no_tool_equivalent_range_definitions(text): "数组是一种结构。索引超出有效范围。", "数组越界不是指访问超出该数组有效下标范围。", "数组越界不意味着索引超出有效范围。", + "数组越界不是指访问数组时使用超出有效索引范围的下标。", + "数组越界不意味着访问超过其合法下标范围的索引。", + "访问数组时使用超出有效索引范围的下标是合法操作。", ]) def test_no_tool_rejects_wrong_denied_and_unrelated_definitions(text): script = _all_met_script()