feat: restore agent capabilities from heartbeat after server restart
The heartbeat now carries capabilities (per protocol v2 update). On each heartbeat, capabilities are updated in the agent registry. On auto-heal (server restart), capabilities from the heartbeat are used instead of empty Map.of(), so the agent's feature flags (replay, routeControl, logForwarding, etc.) are restored immediately on the first heartbeat. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -201,15 +201,17 @@ public class AgentRegistrationController {
|
||||
public ResponseEntity<Void> heartbeat(@PathVariable String id,
|
||||
@RequestBody(required = false) HeartbeatRequest request,
|
||||
HttpServletRequest httpRequest) {
|
||||
boolean found = registryService.heartbeat(id);
|
||||
Map<String, Object> capabilities = request != null ? request.getCapabilities() : null;
|
||||
boolean found = registryService.heartbeat(id, capabilities);
|
||||
if (!found) {
|
||||
// Auto-heal: re-register agent from JWT claims after server restart
|
||||
var jwtResult = (JwtService.JwtValidationResult) httpRequest.getAttribute(
|
||||
JwtAuthenticationFilter.JWT_RESULT_ATTR);
|
||||
if (jwtResult != null) {
|
||||
String application = jwtResult.application() != null ? jwtResult.application() : "default";
|
||||
Map<String, Object> caps = capabilities != null ? capabilities : Map.of();
|
||||
registryService.register(id, id, application, "unknown",
|
||||
List.of(), Map.of());
|
||||
List.of(), caps);
|
||||
registryService.heartbeat(id);
|
||||
log.info("Auto-registered agent {} (app={}) from heartbeat after server restart", id, application);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user