Show agent liveness, stuck/zombie detection and parse errors in admin
This commit is contained in:
@@ -50,6 +50,9 @@ type Manager struct {
|
||||
|
||||
deliverMu sync.Mutex
|
||||
capMu sync.Mutex
|
||||
|
||||
bad *badLines
|
||||
watchStop chan struct{}
|
||||
}
|
||||
|
||||
type live struct {
|
||||
@@ -82,6 +85,8 @@ func New(st *store.Store, limits Limits, worktreeRoot string) *Manager {
|
||||
live: map[string]*live{},
|
||||
rateLimits: map[api.AgentSessionVendor]map[string]any{},
|
||||
merges: map[string]string{},
|
||||
bad: newBadLines(),
|
||||
watchStop: make(chan struct{}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,6 +267,8 @@ func (m *Manager) Recover(ctx context.Context) error {
|
||||
}
|
||||
|
||||
func (m *Manager) Close() {
|
||||
close(m.watchStop)
|
||||
|
||||
m.mu.Lock()
|
||||
m.closing = true
|
||||
all := []*live{}
|
||||
@@ -559,6 +566,7 @@ func (m *Manager) ensureLive(ctx context.Context, sess api.AgentSession, task ap
|
||||
"UserPromptSubmit": {{Func: remindGuidance}},
|
||||
"Stop": {{Func: m.bounceProseQuestion(l)}},
|
||||
},
|
||||
OnBadLine: func(line []byte, reason string) { m.recordBadLine(l, line, reason) },
|
||||
}
|
||||
started, err := m.store.SessionStarted(ctx, sess.Id)
|
||||
if err != nil {
|
||||
@@ -595,6 +603,9 @@ func (m *Manager) pump(l *live) {
|
||||
if err != nil {
|
||||
slog.Error("record agent event", "session", l.id, "type", ev.Type, "err", err)
|
||||
}
|
||||
if isDecodeError(err) {
|
||||
m.recordBadLine(l, ev.Raw, fmt.Sprintf("decode %s: %s", ev.Type, err))
|
||||
}
|
||||
if took := time.Since(start); took > 200*time.Millisecond {
|
||||
slog.Info("agent event slow", "session", l.id, "type", ev.Type, "took", took)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user