Skip to content
Closed
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
12 changes: 7 additions & 5 deletions agentrace/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,20 @@ def check_unverified_claim(run: AgentRun) -> list[Finding]:
r"\bcould not (?:independently )?verify\b",
r"\bunverified\b",
]
hits = []
hits = 0
first_context = ""
for p in hedges:
for m in re.finditer(p, run.result, re.I):
hits.append(_context(run.result, m.start()))
break
if hits == 0:
first_context = _context(run.result, m.start())
hits += 1
if hits:
return [
Finding(
"hedged_claim",
"low",
f"{len(hits)} hedged claim(s). Fine if the hedge survives downstream, a problem if it gets flattened into fact.",
hits[0],
f"{hits} hedged claim(s). Fine if the hedge survives downstream, a problem if it gets flattened into fact.",
first_context,
)
]
return []
Expand Down
6 changes: 6 additions & 0 deletions tests/test_agentrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ def test_hedged_claim_is_caught_but_only_low():
assert findings and findings[0].severity == "low"


def test_hedged_claim_counts_every_occurrence():
r = _run(result="probably one. probably two. probably three. " + "x" * 200)
findings = [f for f in analyse(r) if f.check == "hedged_claim"]
assert findings and "3 hedged claim(s)" in findings[0].message


def test_many_urls_without_verification_is_flagged():
urls = " ".join(f"https://example{i}.com/careers" for i in range(8))
assert "unverified_urls" in _codes(_run(result=urls + " " + "x" * 200))
Expand Down
Loading