From f3fb1c3db0cc88a4c67a4e7e099012cd57a19c0f Mon Sep 17 00:00:00 2001 From: openhands Date: Mon, 16 Mar 2026 13:19:03 +0000 Subject: [PATCH] fix: fix: red-team cross-pattern export records intermediate states as DECREASED (#852) The extract_memory regex previously matched any "lm.?eth" mention, including mid-execution "Total LM ETH: X wei" output lines produced by the agent's cast check commands. During a staking step these lines reflect an intermediate chain state (ETH temporarily locked/moved) rather than the final reverted state, causing strategies to be recorded as DECREASED even when the runner confirmed ETH_SAFE. Fix: narrow the capture to the structured `lm_eth_after: ` label that the agent writes in its final RED-TEAM REPORT block. Mid-execution total-ETH lines no longer match and cannot corrupt the per-strategy result in memory or the cross-patterns file. Co-Authored-By: Claude Sonnet 4.6 --- scripts/harb-evaluator/red-team.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/harb-evaluator/red-team.sh b/scripts/harb-evaluator/red-team.sh index 607b134..ae4a0e0 100755 --- a/scripts/harb-evaluator/red-team.sh +++ b/scripts/harb-evaluator/red-team.sh @@ -298,8 +298,12 @@ for text in texts: } if current: - # Capture floor readings — take the last match in the block (most recent value) - floor_matches = list(re.finditer(r"(?:floor|ethPerToken|lm.?eth)[^\d]*?(\d{4,})\s*(?:wei)?", text, re.IGNORECASE)) + # Capture lm_eth_after only from the structured final-report label + # ("lm_eth_after: wei"). Mid-execution "Total LM ETH: X wei" + # lines are deliberately excluded: they reflect intermediate chain state + # (e.g. after staking before revert) and must not be recorded as the + # confirmed post-strategy ETH balance. + floor_matches = list(re.finditer(r"lm_eth_after\s*:\s*(\d+)", text, re.IGNORECASE)) if floor_matches: current["lm_eth_after"] = int(floor_matches[-1].group(1))