hermes - ✅(Solved) Fix [Bug]: fuzzy_match.py strategy ordering makes indentation_flexible dead code [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#14781Fetched 2026-04-24 06:14:46
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Timeline (top)
labeled ×3commented ×1cross-referenced ×1

Root Cause

In tools/fuzzy_match.py, the indentation_flexible strategy is positioned after a catch-all strategy that always matches first, making it unreachable dead code. Users relying on indentation-flexible matching never get it because the generic strategy absorbs the match first.

Fix Action

Fixed

PR fix notes

PR #14777: fix(tools): reorder fuzzy match strategies so indentation_flexible is no longer dead code

Description (problem / solution / changelog)

What does this PR do?

The indentation_flexible strategy in fuzzy_match.py was positioned after a catch-all strategy that always matched first, making it unreachable dead code. Reorders the strategy list so more specific strategies are evaluated before generic fallbacks.

Related Issue

Fixes #14781

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • tools/fuzzy_match.py: Reordered strategy list so specific strategies precede generic fallbacks
  • tests/tools/test_fuzzy_match.py: Tests for strategy ordering and match priority

How to Test

python -m pytest -o 'addopts=' tests/tools/test_fuzzy_match.py -v

Result: 36 passed.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs
  • My PR contains only changes related to this fix
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes
  • I've tested on my platform: macOS 15 (Darwin 24.6.0), Python 3.14.2

Documentation & Housekeeping

  • N/A for all documentation items

Changed files

  • tests/tools/test_fuzzy_match.py (modified, +38/-0)
  • tools/fuzzy_match.py (modified, +13/-7)
RAW_BUFFERClick to expand / collapse

Describe the bug

In tools/fuzzy_match.py, the indentation_flexible strategy is positioned after a catch-all strategy that always matches first, making it unreachable dead code. Users relying on indentation-flexible matching never get it because the generic strategy absorbs the match first.

Steps to reproduce

  1. Call fuzzy_match with input that should trigger indentation_flexible
  2. Observe that the catch-all strategy matches instead

Expected behavior

More specific strategies (like indentation_flexible) should be evaluated before generic fallbacks.

Environment

  • Hermes Agent version: current main
  • OS: any

extent analysis

TL;DR

Reorder the strategies in tools/fuzzy_match.py to place indentation_flexible before the catch-all strategy.

Guidance

  • Verify the current strategy order in tools/fuzzy_match.py to confirm indentation_flexible is indeed after the catch-all.
  • Consider reordering strategies based on specificity, with more specific ones like indentation_flexible evaluated first.
  • Test the fuzzy_match function with inputs that should trigger indentation_flexible after reordering to ensure it now matches correctly.
  • Review the logic for adding or removing strategies to prevent similar issues in the future.

Example

# Example strategy order correction
strategies = [
    'indentation_flexible',  # More specific strategies first
    'catch_all'  # Generic fallbacks last
]

Notes

This fix assumes that the order of strategies directly influences their evaluation order, which may not be the case if there are other factors at play in the fuzzy_match function.

Recommendation

Apply workaround: Reorder strategies to prioritize specific ones like indentation_flexible to ensure they are evaluated before generic catch-all strategies.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

More specific strategies (like indentation_flexible) should be evaluated before generic fallbacks.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING