Nomearod Claude Opus 4.6 (1M context) commited on
Commit
d3d39b4
·
1 Parent(s): d0f0142

fix: rerank_score falsy-value bug and double-getattr cleanup

Browse files

A 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>

Files changed (1) hide show
  1. agent_bench/tools/search.py +2 -2
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) or top.score,
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": getattr(r, 'rerank_score', None) if getattr(r, 'rerank_score', None) is not None else r.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: