-
-
Notifications
You must be signed in to change notification settings - Fork 69.2k
[Bug]: Performance bottleneck in resolveAgentRoute with large bindings configuration #36915
Copy link
Copy link
Closed
Closed
Copy link
Labels
bugSomething isn't workingSomething isn't workingbug:crashProcess/app exits unexpectedly or hangsProcess/app exits unexpectedly or hangs
Description
Bug type
Crash (process/app exits or hangs)
Summary
Environment
- OpenClaw Version: 2026.3.2
- Channel: DingTalk (https://github.com/soimy/openclaw-channel-dingtalk)
- Configuration: 83,043 bindings (9,000+ agents)
Problem
resolveAgentRoute() causes 10+ second delays when processing messages in deployments with large numbers of bindings.
Log evidence:
2026-03-05T09:48:02.012Z - Message received from DingTalk WebSocket
... ~10 second gap ...
2026-03-05T09:48:21.233Z - [dingtalk] Inbound: from=宋成好 text="..."
Root Cause
src/routing/resolve-route.ts Line 322-370: getEvaluatedBindingsForChannelAccount()
const evaluated: EvaluatedBinding[] = listBindings(cfg).flatMap((binding) => {
if (!matchesChannel(binding.match, channel)) { // ← O(n) linear scan on EVERY message
return [];
}
// ...
});- Time Complexity: O(n) where n = total bindings count
- With 83,043 bindings: Every message triggers full array scan
- Result: Prohibitive performance degradation
Proposed Solution
Add channel-specific peer index to EvaluatedBindingsIndex:
type EvaluatedBindingsIndex = {
byPeer: Map<string, EvaluatedBinding[]>;
byChannelPeer: Map<string, EvaluatedBinding[]>; // NEW: O(1) channel:peer lookup
// ... existing fields
};Benefits:
- Solves at framework level (all channels benefit)
- O(1) peer lookups instead of O(n)
- Maintains API compatibility
- Minimal memory overhead
Impact
- Enterprise deployments with 1000+ agents become unusable
- Poor user experience (10s message delays)
- Blocks scaling OpenClaw for large organizations
Use Case
Enterprise-wide DingTalk bot:
- 9,000+ employees, each with isolated agent/workspace
- Per-user routing via bindings:
peer.id(user ID) →agentId - Single bot, zero end-user configuration
Files
src/routing/resolve-route.ts(line 322-370, 530-719)
Steps to reproduce
above
Expected behavior
above
Actual behavior
above
OpenClaw version
2026.3.1
Operating system
Ubuntu
Install method
docker
Logs, screenshots, and evidence
Impact and severity
No response
Additional information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingbug:crashProcess/app exits unexpectedly or hangsProcess/app exits unexpectedly or hangs
Type
Fields
Give feedbackNo fields configured for issues without a type.