Commit e9ac7cc
fix(llm-router): address Copilot review comments
Applied Copilot security/quality recommendations:
1. Fixed mutable default arguments - Changed `connection_kwargs: Dict[str, Any] = {}`
to `Optional[Dict[str, Any]] = None` in LLMRouter.__init__ and SemanticRouter.__init__
to avoid shared state across instances.
2. Added empty routes guard - Added `if not self.routes: return []` check in
both sync and async `_get_route_matches()` to prevent ValueError when calling
`max(route.distance_threshold for route in self.routes)` on empty sequence.
These changes address the same issues that were fixed in the original LLMRouter
implementation (commits e1cd469 and 9cba561), ensuring consistency across
the refactored codebase.
All 86 router tests passing.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent fed62ee commit e9ac7cc
2 files changed
+13
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
113 | 117 | | |
114 | 118 | | |
115 | 119 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
99 | 102 | | |
100 | 103 | | |
101 | 104 | | |
| |||
386 | 389 | | |
387 | 390 | | |
388 | 391 | | |
| 392 | + | |
| 393 | + | |
389 | 394 | | |
390 | 395 | | |
391 | 396 | | |
| |||
1438 | 1443 | | |
1439 | 1444 | | |
1440 | 1445 | | |
| 1446 | + | |
| 1447 | + | |
1441 | 1448 | | |
1442 | 1449 | | |
1443 | 1450 | | |
| |||
0 commit comments