Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions services/agent/src/boundary_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,7 @@ def _array_range_definition(text: str) -> bool:
"""
lowered = text.casefold()
patterns = (
r"(?:访问数组时(?:使用)?|访问)?(?:超出|超过)(?:了)?(?:数组(?:的)?|其)?(?:有效|合法)(?:索引|下标)?范围的(?:索引|下标)",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve negation across the usage verb

For a response such as 数组越界是指没有使用超过其合法下标范围的索引。, this alternative falls back to matching only 超过其合法下标范围的索引. The prefix then ends in 使用, so _unnegated_claim cannot see the preceding 没有 and incorrectly accepts this denied definition; the parent rejected the same input. This can falsely mark the no-tool boundary case as passing, so the grammar needs to retain or otherwise check negation across intervening usage verbs.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Bind the range phrase to the array subject

When 数组 is merely mentioned elsewhere in the same punctuation-delimited sentence, the new alternative can match an unrelated subject because both the array prefix and 其 are optional. For example, 数组用于连续存储元素,链表访问超过其合法下标范围的索引是非法的。 now passes _array_range_definition even though the out-of-range claim refers to a linked list, whereas the parent rejected it. Require the matched range phrase itself, or an unambiguous antecedent, to identify the array.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject interrogative matches of the range phrase

A response that only asks 数组越界是否指访问超过其合法下标范围的索引? now passes _array_range_definition: sentence splitting removes the question delimiter, the bridge stripping leaves 是否, and the new range alternative is then treated as an asserted definition. The parent rejected this input, and the existing negative cases establish that merely asking what array bounds means must not satisfy the no-tool case. Detect the interrogative form before accepting this match.

Useful? React with 👍 / 👎.

r"(?:索引|下标)(?:落在)?(?:超出|超过|不在)[^。;;!??]{0,16}(?:有效|合法)[^。;;!??]{0,8}范围(?:内)?",
r"(?:索引|下标)落在(?:有效|合法)范围(?:之外|以外)",
r"(?:访问)?(?:超出|超过)[^。;;!??]{0,12}数组(?:的)?(?:有效|合法)?(?:索引|下标)?(?:范围|边界|长度)",
Expand Down
5 changes: 5 additions & 0 deletions services/agent/tests/test_boundary_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down
Loading