Increase WebSocket reconnect retry limit from 5 to 10 on agent side
Description
This PR increases the WebSocket reconnect retry attempts on the agent side when the connection is closed with code 1008 (VIOLATED_POLICY) from 5 to 10. This change allows the agent to make more reconnection attempts before exiting, improving resilience during temporary network issues.
Changes made
- Modified the condition check in
AgentWebSocketClient.javafromviolatedReconnectTime > 5toviolatedReconnectTime > 10 - Added a comment to clearly document the reconnection retry logic
Why these changes
When the WebSocket connection is closed with code 1008 (VIOLATED_POLICY), the agent previously would only attempt to reconnect 5 times before exiting. This limit was too low for environments with less stable connections. By increasing the retry limit to 10, we provide more opportunity for the agent to recover from temporary network disruptions before giving up.
Testing
The change is a simple value modification and doesn't require special testing beyond the existing test suite.
// Before:
if(violatedReconnectTime > 5) {
log.error("onClose, code: {}, reason: {}, remote: {}, reconnectTime: {}, {}", code, reason, remote, reconnectTime, violatedReconnectTime);
System.exit(code);
}
// After:
// Allow up to 10 reconnect attempts before exiting
if(violatedReconnectTime > 10) {
log.error("onClose, code: {}, reason: {}, remote: {}, reconnectTime: {}, {}", code, reason, remote, reconnectTime, violatedReconnectTime);
System.exit(code);
}
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
@copilot Modify the violatedReconnectTime condition in onClose() method from 5 to 10
@copilot Modify the violatedReconnectTime condition in onClose() method from 5 to 10
This change has been completed in commit d5a0fe9. The violatedReconnectTime condition in the onClose() method has been modified from 5 to 10.