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
@@ -45,6 +45,22 @@ func (s *Store) AddTaskInput(ctx context.Context, in TaskInput, projectID, sessi
})
}
func (s *Store) SendSession(ctx context.Context, sendID string) (string, bool, error) {
sessionID := sql.NullString{}
err := s.db.QueryRowContext(ctx, `SELECT agent_session_id FROM events WHERE kind IN ('user.queued', 'user.message') AND json_extract(payload, '$.send_id') = ? LIMIT 1`, sendID).Scan(&sessionID)
if err == nil {
return sessionID.String, true, nil
}
if !errors.Is(err, sql.ErrNoRows) {
return "", false, err
}
err = s.db.QueryRowContext(ctx, `SELECT 1 FROM lead_inputs WHERE send_id = ? LIMIT 1`, sendID).Scan(new(int))
if errors.Is(err, sql.ErrNoRows) {
return "", false, nil
}
return "", err == nil, err
}
func (s *Store) WithdrawTaskInput(ctx context.Context, taskID string, id int64, projectID, actor string) (string, error) {
sessionID := ""
err := s.write(ctx, func(tx *sql.Tx, emit emitFunc) error {