The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
perf(agent): avoid quadratic work in tool history pairing
illidanbca2f0f3da52
diff --git a/agent/agent_runtime_helpers.py b/agent/agent_runtime_helpers.pyindex bca7769eb65..cfb6e700272 100644--- a/agent/agent_runtime_helpers.py+++ b/agent/agent_runtime_helpers.py@@ -2692,10 +2692,10 @@ def _classify_tool_call_orphans(messages: List[Dict[str, Any]]):]result_call_ids: set[str] = set().union(*(v for _, v in result_entries))orphaned_results = [msg for msg, v in result_entries if v and not (v & surviving_call_ids)]- orphaned_ids = {id(msg) for msg in orphaned_results}- surviving_result_variants = [v for msg, v in result_entries if v and id(msg) not in orphaned_ids]+ # Orphan result variants are disjoint from every declared call, so they+ # cannot contribute a match. Reuse the union instead of scanning each result.missing_tool_calls = [- tc for tc, v in assistant_call_variants if not any(v & rv for rv in surviving_result_variants)+ tc for tc, v in assistant_call_variants if not (v & result_call_ids)]return surviving_call_ids, result_call_ids, orphaned_results, missing_tool_calls