Retry failed sends with their send_id until the server confirms them
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user