Spaces:
Running
Running
fix: rerank_score falsy-value bug and double-getattr cleanup
Browse filesA rerank_score of 0.0 was falling through to r.score due to `or`
truthiness. Use walrus + `is not None` for correctness while keeping
getattr safety for mock objects without the field.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
agent_bench/tools/search.py
CHANGED
|
@@ -110,7 +110,7 @@ class SearchTool(Tool):
|
|
| 110 |
"refusal_threshold": self.refusal_threshold,
|
| 111 |
"pre_rerank_count": pre_rerank_count,
|
| 112 |
"chunks": [{"source": top.chunk.source,
|
| 113 |
-
"score": getattr(top, 'rerank_score', None)
|
| 114 |
"preview": top.chunk.content[:120]}],
|
| 115 |
"pii_redactions_count": 0,
|
| 116 |
},
|
|
@@ -136,7 +136,7 @@ class SearchTool(Tool):
|
|
| 136 |
source_chunks.append(content)
|
| 137 |
chunk_details.append({
|
| 138 |
"source": source,
|
| 139 |
-
"score":
|
| 140 |
"preview": content[:120],
|
| 141 |
})
|
| 142 |
if source not in sources:
|
|
|
|
| 110 |
"refusal_threshold": self.refusal_threshold,
|
| 111 |
"pre_rerank_count": pre_rerank_count,
|
| 112 |
"chunks": [{"source": top.chunk.source,
|
| 113 |
+
"score": rs if (rs := getattr(top, 'rerank_score', None)) is not None else top.score,
|
| 114 |
"preview": top.chunk.content[:120]}],
|
| 115 |
"pii_redactions_count": 0,
|
| 116 |
},
|
|
|
|
| 136 |
source_chunks.append(content)
|
| 137 |
chunk_details.append({
|
| 138 |
"source": source,
|
| 139 |
+
"score": rs if (rs := getattr(r, 'rerank_score', None)) is not None else r.score,
|
| 140 |
"preview": content[:120],
|
| 141 |
})
|
| 142 |
if source not in sources:
|