Skip to content

Commit fdbf36e

Browse files
Andrey Golovanovclaude
andcommitted
Fix citation verifier to handle backtick-quoted paths
LLMs commonly format dot-paths with backticks (`steps.x.y` = 3.0). The regex now strips optional backticks before matching. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1799a8f commit fdbf36e

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

netlab/autoresearch/citation_verifier.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,10 @@ def verify_claims(claims: list[Claim], data: dict) -> VerificationResult:
111111

112112
# --- Claim extraction from structured LLM output ---
113113

114-
# Pattern: "path = value" or "path: value" in LLM-structured output
114+
# Pattern: "path = value" or "path: value" in LLM-structured output.
115+
# Handles optional backtick quoting (e.g., `steps.msd.data.alpha_star` = 3.0).
115116
_CLAIM_PATTERN = re.compile(
116-
r"(?P<path>[\w.]+(?:\.[\w.]+)+)\s*[=:]\s*(?P<value>-?[\d.]+)"
117+
r"`?(?P<path>[\w.]+(?:\.[\w.]+)+)`?\s*[=:]\s*(?P<value>-?[\d.]+)"
117118
)
118119

119120

tests/autoresearch/test_citation_verifier.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,13 @@ def test_colon_separator(self) -> None:
133133
claims = extract_claims_from_text(text)
134134
assert len(claims) == 1
135135

136+
def test_backtick_quoted_path(self) -> None:
137+
text = "`steps.msd_baseline.data.alpha_star` = 3.0"
138+
claims = extract_claims_from_text(text)
139+
assert len(claims) == 1
140+
assert claims[0].path == "steps.msd_baseline.data.alpha_star"
141+
assert claims[0].claimed_value == 3.0
142+
136143
def test_no_claims(self) -> None:
137144
text = "The results look good overall."
138145
claims = extract_claims_from_text(text)

0 commit comments

Comments
 (0)