Files
hermes-agent/agent
illidan bca2f0f3da perf(agent): avoid quadratic work in tool history pairing
_classify_tool_call_orphans rebuilt the surviving-result variant list and
scanned all of it for every declared tool call (O(calls x results)).
Orphan result variants are disjoint from every declared call, so matching
against the already-computed union of all result variants is equivalent
and O(1) per call. 1000 pairs: 50.9 ms -> 2.4 ms per classification.

Partial salvage of #105660: kept the _classify_tool_call_orphans union
reuse; dropped the messages[i+1:] slice -> range() hunk (sub-ms) and
tests/agent/test_tool_pairing_scaling.py (read-count assertions are a
change-detector). Hunk re-derived by hand: PR base was ~7.9k commits behind.

(cherry picked from commit 6879a69a7195c26162c63ba9474a07638e35e839)
2026-09-23 21:28:38 +05:30
..
…
…