Retry failed sends with their send_id until the server confirms them

This commit is contained in:
Ian Gulliver
2026-10-20 15:47:29 -07:00
parent 8fec4b9040
commit d096d604c9
9 changed files with 111 additions and 14 deletions
+16
View File
@@ -186,6 +186,22 @@ func (m *Manager) taskFor(ctx context.Context, sess api.AgentSession) (api.Task,
}
func (m *Manager) Create(ctx context.Context, task api.Task, creator api.User, prompt, model, sendID string, images ...string) (api.AgentSession, error) {
unlock := m.lockDelivery("create:" + task.Id)
defer unlock()
ctx = context.WithoutCancel(ctx)
prior, sent, err := m.priorSend(ctx, sendID)
if err != nil || sent {
return prior, err
}
unused, found, err := m.store.UnusedSession(ctx, task.Id, "")
if err != nil {
return api.AgentSession{}, err
}
if found {
slog.Info("first message to an unused session", "session", unused, "task", task.Id)
return m.Send(ctx, unused, creator.Login, prompt, model, sendID, images...)
}
return m.create(ctx, task, creator, "", prompt, model, creator.Login, sendID, images)
}