feat(agents): 3-layer recovery for agents stuck in summoning state

Add ResetStuckSummoning store method (PG + SQLite) + startup sweep to
flip ghost rows to summon_failed on boot. Drop 409 guards on resummon
and regenerate to allow retry. Add POST /v1/agents/{id}/cancel-summon
endpoint + audit event agent.summon_cancelled + i18n (en/vi/zh).
This commit is contained in:
viettranx committed 2026-04-17 19:02:53 +07:00
1 parent 7e2e66c095
commit d7342fbd6e
10 files changed
+91 -8

No files matched your search

+11
View File
@@ -143,6 +143,17 @@ func runGateway() {
}
pgStores, traceCollector, snapshotWorker := setupStoresAndTracing(cfg, dataDir, msgBus)
// Recover from crashes: flip ghost 'summoning' rows to 'summon_failed'.
// Summon goroutines don't survive process restart; stale DB rows would trap the UI.
if pgStores.Agents != nil {
if n, err := pgStores.Agents.ResetStuckSummoning(context.Background()); err != nil {
slog.Warn("agents.reset_stuck_summoning_failed", "err", err)
} else if n > 0 {
slog.Info("agents.reset_stuck_summoning", "count", n)
}
}
if traceCollector != nil {
defer traceCollector.Stop()
// OTel OTLP export: compiled via build tags. Build with 'go build -tags otel' to enable.